I think a print trace of the problem is worth 1,000 words:
# Case 1
BEGIN:VEVENT
SUMMARY:Recurrence with 2 deleted days
DTSTART;TZID=Europe/Paris:20170502T100000
DTEND;TZID=Europe/Paris:20170502T110000
DTSTAMP:20170504T085344Z
UID:uid-0
EXDATE;TZID=Europe/Paris:20170523T100000
EXDATE;TZID=Europe/Paris:20170516T100000
RRULE:FREQ=WEEKLY;BYDAY=TU
STATUS:CONFIRMED
END:VEVENT
[<icalendar.prop.vDDDLists object at 0x7fe2ed87ef28>, <icalendar.prop.vDDDLists object at 0x7fe2ed87ebe0>]
type(event['EXDATE']) = <class 'list'>
# Case 2
BEGIN:VEVENT
SUMMARY:Recurrence with one deleted day
DTSTART;TZID=Europe/Paris:20170502T023000
DTEND;TZID=Europe/Paris:20170502T033000
DTSTAMP:20170504T085344Z
UID:uid-1
EXDATE;TZID=Europe/Paris:20170509T023000
RRULE:FREQ=WEEKLY;BYDAY=TU
STATUS:CONFIRMED
END:VEVENT
<icalendar.prop.vDDDLists object at 0x7fe2ed4234e0>
type(event['EXDATE']) = <class 'icalendar.prop.vDDDLists'>
As you can see, we can't rely on the type of EXDATE, since it can either be a Python list of vDDDLists or just one vDDDLists instance. In my own application, I had to do this workaround to have a generic way of handling:
exdates = event['EXDATE']
if isinstance(event['EXDATE'], icalendar.prop.vDDDLists):
exdates = [exdates]
Either vDDDLists objects should be merged in a single one (best abstraction API I think), either EXDATE should always return a list of lists. But not both behaviour...
I think a print trace of the problem is worth 1,000 words:
As you can see, we can't rely on the type of EXDATE, since it can either be a Python list of
vDDDLists
or just onevDDDLists
instance. In my own application, I had to do this workaround to have a generic way of handling:Either
vDDDLists
objects should be merged in a single one (best abstraction API I think), either EXDATE should always return a list of lists. But not both behaviour...