diff options
author | Christian Geier <christian.geier@justadd.ai> | 2023-05-23 15:55:42 +0200 |
---|---|---|
committer | Christian Geier <geier@lostpackets.de> | 2023-05-23 16:50:19 +0200 |
commit | a6657fd828c582615ca34a9c5a5fb8bfa2979c97 (patch) | |
tree | 7316796e627342c2fcd18bd561c10226cf2da4bd | |
parent | d7d33bb4472a8aa6001df1bf8aef23719063004a (diff) |
more warnings on failing to import events
-rw-r--r-- | khal/icalendar.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/khal/icalendar.py b/khal/icalendar.py index b9d6334a..6bacc5ec 100644 --- a/khal/icalendar.py +++ b/khal/icalendar.py @@ -72,8 +72,18 @@ def split_ics(ics: str, random_uid: bool=False, default_timezone=None): events_grouped[item['UID']].append(item) else: continue - return [ics_from_list(events, tzs, random_uid, default_timezone) for uid, events in - sorted(events_grouped.items())] + out = [] + saved_exception = None + for uid, events in sorted(events_grouped.items()): + try: + ics = ics_from_list(events, tzs, random_uid, default_timezone) + except Exception as exception: + logger.warn(f'Error when trying to import the event {uid}') + saved_exception = exception + out.append(ics) + if saved_exception: + raise saved_exception + return out def new_vevent(locale, @@ -418,6 +428,9 @@ def sanitize_timerange(dtstart, dtend, duration=None): "Assuming it's the same timezone as the end time" ) dtstart = dtend.tzinfo.localize(dtstart) + if dtend is not None and type(dtstart) != type(dtend): + raise ValueError( + 'The event\'s end time (DTEND) and start time (DTSTART) are not of the same type.') if dtend is None and duration is None: if isinstance(dtstart, dt.datetime): |