Skip to content

Commit

Permalink
Merge pull request #116 from Unrud/patch-3
Browse files Browse the repository at this point in the history
RRULE: Fix VTODO without DTSTART
  • Loading branch information
wpercy authored Jul 8, 2018
2 parents 9bbc631 + 25379b7 commit 4b72717
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions vobject/icalendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,21 @@ def getrruleset(self, addRDate=False):
if addfunc is None:
addfunc = getattr(rruleset, name)

dtstart = self.dtstart.value
try:
dtstart = self.dtstart.value
except (AttributeError, KeyError):
# Special for VTODO - try DUE property instead
try:
if self.name == "VTODO":
dtstart = self.due.value
else:
# if there's no dtstart, just return None
logging.error('failed to get dtstart with VTODO')
return None
except (AttributeError, KeyError):
# if there's no due, just return None
logging.error('failed to find DUE at all.')
return None

if name in DATENAMES:
if type(line.value[0]) == datetime.datetime:
Expand All @@ -426,22 +440,6 @@ def getrruleset(self, addRDate=False):
# ignore RDATEs with PERIOD values for now
pass
elif name in RULENAMES:
try:
dtstart = self.dtstart.value
except (AttributeError, KeyError):
# Special for VTODO - try DUE property instead
try:
if self.name == "VTODO":
dtstart = self.due.value
else:
# if there's no dtstart, just return None
logging.error('failed to get dtstart with VTODO')
return None
except (AttributeError, KeyError):
# if there's no due, just return None
logging.error('failed to find DUE at all.')
return None

# a Ruby iCalendar library escapes semi-colons in rrules,
# so also remove any backslashes
value = line.value.replace('\\', '')
Expand Down

0 comments on commit 4b72717

Please sign in to comment.