Compare commits
2 commits
29d6d1d2b5
...
58f295cc54
| Author | SHA1 | Date | |
|---|---|---|---|
| 58f295cc54 | |||
| 80714978d3 |
1 changed files with 20 additions and 1 deletions
|
|
@ -82,14 +82,33 @@ class CalEvent(BaseModel):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
data = {}
|
data = {}
|
||||||
|
keys = ("summary", "description", "dtstart", "dtend", "duration")
|
||||||
|
|
||||||
for key in cls().dict().keys():
|
for key in keys:
|
||||||
try:
|
try:
|
||||||
data[key] = event.contents[key][0].value # type: ignore
|
data[key] = event.contents[key][0].value # type: ignore
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
print(data)
|
||||||
|
|
||||||
|
if "dtend" not in data:
|
||||||
|
data["dtend"] = data["dtstart"]
|
||||||
|
|
||||||
|
if "duration" in data:
|
||||||
|
try:
|
||||||
|
data["dtend"] += data["duration"]
|
||||||
|
|
||||||
|
except (ValueError, TypeError, AttributeError):
|
||||||
|
_logger.warn(
|
||||||
|
"Could not add duration %s to %s",
|
||||||
|
repr(data["duration"]),
|
||||||
|
repr(data["dtstart"]),
|
||||||
|
)
|
||||||
|
|
||||||
|
del data["duration"]
|
||||||
|
|
||||||
return cls.parse_obj(data)
|
return cls.parse_obj(data)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue