Skip to content

Commit

Permalink
Remove SEQUENCE lines in VTIMEZONE (fixes #90)
Browse files Browse the repository at this point in the history
  • Loading branch information
C4ptainCrunch committed Jul 22, 2019
1 parent ebe80a0 commit 33a0fdd
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Ics.py changelog
- Added LAST-MODIFIED attribute support
- Event equality now checks all fields (except uid)
- alarms in Event and Todo are now consistently lists and not a mix between set() and list()
- Fix SEQUENCE in VTIMEZONE error

**************
0.4
Expand Down
3 changes: 2 additions & 1 deletion ics/icalendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
ContentLine,
Container,
)
from .utils import remove_x
from .utils import remove_x, remove_sequence


class Calendar(Component):
Expand Down Expand Up @@ -188,6 +188,7 @@ def timezone(calendar, vtimezones):
"""
for vtimezone in vtimezones:
remove_x(vtimezone) # Remove non standard lines from the block
remove_sequence(vtimezone) # Remove SEQUENCE lines because tzical does not understand them
fake_file = StringIO()
fake_file.write(str(vtimezone)) # Represent the block as a string
fake_file.seek(0)
Expand Down
8 changes: 7 additions & 1 deletion ics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from arrow.arrow import Arrow
from datetime import timedelta
from six import StringIO, string_types, text_type, integer_types

from uuid import uuid4
from dateutil.tz import gettz
Expand All @@ -24,6 +23,13 @@ def remove_x(container):
del container[i]


def remove_sequence(container):
for i in reversed(range(len(container))):
item = container[i]
if item.name == 'SEQUENCE':
del container[i]


DATE_FORMATS = dict((len(k), k) for k in (
'YYYYMM',
'YYYYMMDD',
Expand Down
15 changes: 15 additions & 0 deletions tests/fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,21 @@
END:VCALENDAR
"""

clas33 = """
BEGIN:VTIMEZONE
TZID:Australia/Sydney
TZURL:http://tzurl.org/zoneinfo/Australia/Sydney
SEQUENCE:498
SEQUENCE:498
BEGIN:STANDARD
TZOFFSETFROM:+1100
TZOFFSETTO:+1000
TZNAME:EST
DTSTART:20080406T030000
RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU
END:STANDARD
"""

unfolded_cal2 = [
'BEGIN:VCALENDAR',
'BEGIN:VEVENT',
Expand Down
6 changes: 6 additions & 0 deletions tests/misc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from ics.icalendar import Calendar
from .fixture import cal32


def test_issue_90():
Calendar(cal32)

0 comments on commit 33a0fdd

Please sign in to comment.