[Calendarserver-maintainers] Bug#849924: python-vobject: Fail to return end date for ended recurring VEVENT
Petter Reinholdtsen
pere at hungry.com
Mon Jan 2 10:50:14 UTC 2017
Package: python-vobject
Version: 0.8.1c-4
I ran into this problem while trying to find all recurring VEVENT that
are no longer relevant in my iCalendar file. The documented way to find
the last time the event would trigger give an exception. Here is a
small program demonstrating the problem:
#!/bin/sh
# Minimal example code to demonstrate problem with vobject python
# library. Running it give this error:
# Traceback (most recent call last):
# File "test.py", line 12, in <module>
# print ruleset[-1]
# File "/usr/lib/python2.7/dist-packages/dateutil/rrule.py", line 151, in __getitem__
# return list(iter(self))[item]
# File "/usr/lib/python2.7/dist-packages/dateutil/rrule.py", line 897, in _iter
# while exlist and exlist[0] < ritem:
# File "/usr/lib/python2.7/dist-packages/dateutil/rrule.py", line 849, in __lt__
# return self.dt < other.dt
# TypeError: can't compare offset-naive and offset-aware datetimes
cat > test.ics <<EOF
BEGIN:VCALENDAR
PRODID:-//Manual test example//NONSGML pere 1.0//EN
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Europe/Oslo
BEGIN:STANDARD
TZNAME:CET
TZOFFSETFROM:+0043
TZOFFSETTO:+0100
DTSTART:19011213T212852
RDATE;VALUE=DATE-TIME:19011213T212852
END:STANDARD
BEGIN:DAYLIGHT
TZNAME:CEST
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
DTSTART:19810329T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
END:DAYLIGHT
BEGIN:DAYLIGHT
TZNAME:CEST
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
DTSTART:19160522T010000
RDATE;VALUE=DATE-TIME:19160522T010000
RDATE;VALUE=DATE-TIME:19400810T230000
RDATE;VALUE=DATE-TIME:19430329T020000
RDATE;VALUE=DATE-TIME:19440403T020000
RDATE;VALUE=DATE-TIME:19450402T020000
RDATE;VALUE=DATE-TIME:19590315T020000
RDATE;VALUE=DATE-TIME:19600320T020000
RDATE;VALUE=DATE-TIME:19610319T020000
RDATE;VALUE=DATE-TIME:19620318T020000
RDATE;VALUE=DATE-TIME:19630317T020000
RDATE;VALUE=DATE-TIME:19640315T020000
RDATE;VALUE=DATE-TIME:19650425T020000
RDATE;VALUE=DATE-TIME:19800406T020000
END:DAYLIGHT
BEGIN:STANDARD
TZNAME:CET
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
DTSTART:19800928T030000
RRULE:FREQ=YEARLY;COUNT=16;BYDAY=-1SU;BYMONTH=9
END:STANDARD
BEGIN:STANDARD
TZNAME:CET
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
DTSTART:19961027T030000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
END:STANDARD
BEGIN:STANDARD
TZNAME:CET
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
DTSTART:19160930T000000
RDATE;VALUE=DATE-TIME:19160930T000000
RDATE;VALUE=DATE-TIME:19421102T030000
RDATE;VALUE=DATE-TIME:19431004T030000
RDATE;VALUE=DATE-TIME:19441002T030000
RDATE;VALUE=DATE-TIME:19451001T030000
RDATE;VALUE=DATE-TIME:19590920T030000
RDATE;VALUE=DATE-TIME:19600918T030000
RDATE;VALUE=DATE-TIME:19610917T030000
RDATE;VALUE=DATE-TIME:19620916T030000
RDATE;VALUE=DATE-TIME:19630915T030000
RDATE;VALUE=DATE-TIME:19640920T030000
RDATE;VALUE=DATE-TIME:19650919T030000
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
UID:3a29cf0e-b2de-430b-894f-9a07634fc875
DTSTART;TZID=Europe/Oslo:20160427T180000
DTEND;TZID=Europe/Oslo:20160427T190000
CREATED:20160412T202645Z
DTSTAMP:20160529T080325Z
EXDATE;VALUE=DATE:20160504
EXDATE;VALUE=DATE:20160608
LAST-MODIFIED:20160529T080325Z
RRULE:FREQ=WEEKLY;UNTIL=20160615T160000Z;BYDAY=WE
SEQUENCE:2
SUMMARY:Something is about to happen
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR
EOF
cat > test.py <<EOF
#!/usr/bin/env python
import vobject
icalstream = open("test.ics")
components = vobject.readComponents(icalstream, validate=True)
cal = components.next()
print cal.prettyPrint();
for event in cal.vevent_list:
print event.prettyPrint()
ruleset = event.getrruleset()
print ruleset[-1] # XXX This one fail
EOF
python test.py
rm test.py test.ics
Am I using the library wrong? Is there some other way to figure out the
last date for a recurring event, if there is a limit?
--
Happy hacking
Petter Reinholdtsen
More information about the Calendarserver-maintainers
mailing list