[icalendar-checkins] r19611 - in
iCalendar/branch/sidnei-schooltool-compat: doc src/icalendar
dreamcatcher at codespeak.net
dreamcatcher at codespeak.net
Mon Nov 7 18:37:52 CET 2005
Author: dreamcatcher
Date: Mon Nov 7 18:37:44 2005
New Revision: 19611
Modified:
iCalendar/branch/sidnei-schooltool-compat/doc/groupscheduled.txt
iCalendar/branch/sidnei-schooltool-compat/doc/small.txt
iCalendar/branch/sidnei-schooltool-compat/src/icalendar/prop.py
Log:
- Fix more tests
- Fix weekday rule
Modified: iCalendar/branch/sidnei-schooltool-compat/doc/groupscheduled.txt
==============================================================================
--- iCalendar/branch/sidnei-schooltool-compat/doc/groupscheduled.txt (original)
+++ iCalendar/branch/sidnei-schooltool-compat/doc/groupscheduled.txt Mon Nov 7 18:37:44 2005
@@ -6,16 +6,16 @@
>>> cal = Calendar.from_string(
... open(os.path.join(directory, 'groupscheduled.ics'),'rb').read())
>>> cal
- VCALENDAR({'VERSION': '2.0', 'PRODID': '-//RDU Software//NONSGML HandCal//EN'})
-
+ VCALENDAR({'VERSION': vText(u'2.0'), 'PRODID': vText(u'-//RDU Software//NONSGML HandCal//EN')})
+
>>> timezones = cal.walk('VTIMEZONE')
>>> len(timezones)
1
-
+
>>> tz = timezones[0]
>>> tz
- VTIMEZONE({'TZID': 'US-Eastern'})
-
+ VTIMEZONE({'TZID': vText(u'US-Eastern')})
+
>>> std = tz.walk('STANDARD')[0]
>>> std.decoded('TZOFFSETFROM')
datetime.timedelta(-1, 72000)
Modified: iCalendar/branch/sidnei-schooltool-compat/doc/small.txt
==============================================================================
--- iCalendar/branch/sidnei-schooltool-compat/doc/small.txt (original)
+++ iCalendar/branch/sidnei-schooltool-compat/doc/small.txt Mon Nov 7 18:37:44 2005
@@ -6,23 +6,23 @@
>>> cal = Calendar.from_string(
... open(os.path.join(directory, 'small.ics'),'rb').read())
>>> cal
- VCALENDAR({'VERSION': '2.0', 'METHOD': 'Request', 'PRODID': '-//My product//mxm.dk/'})
+ VCALENDAR({'VERSION': vText(u'2.0'), 'METHOD': vText(u'Request'), 'PRODID': vText(u'-//My product//mxm.dk/')})
>>> for component in cal.walk():
... component.name
'VCALENDAR'
'VEVENT'
'VEVENT'
-
+
>>> cal['prodid']
- '-//My product//mxm.dk/'
-
+ vText(u'-//My product//mxm.dk/')
+
>>> cal.decoded('prodid')
u'-//My product//mxm.dk/'
-
+
>>> first_event = cal.walk('vevent')[0]
>>> first_event['description'][:75]
- 'This is a very long description that will be folded This is a very long des'
+ u'This is a very long description that will be folded This is a very long des'
>>> first_event['summary']
- 'A second event'
+ vText(u'A second event')
Modified: iCalendar/branch/sidnei-schooltool-compat/src/icalendar/prop.py
==============================================================================
--- iCalendar/branch/sidnei-schooltool-compat/src/icalendar/prop.py (original)
+++ iCalendar/branch/sidnei-schooltool-compat/src/icalendar/prop.py Mon Nov 7 18:37:44 2005
@@ -58,6 +58,8 @@
WEEKS_PART = r'(\d+)W'
DURATION_REGEX = re.compile(r'([-+]?)P(?:%s|%s)$'
% (WEEKS_PART, DATETIME_PART))
+WEEKDAY_RULE = re.compile('(?P<signal>[+-]?)(?P<relative>[\d]?)'
+ '(?P<weekday>[\w]{2})$')
class vBinary:
"""
@@ -551,7 +553,7 @@
datetime.timedelta(31)
>>> vDDDTypes.from_ical('-P31D')
- datetime.timedelta(31)
+ datetime.timedelta(-31)
Bad input
>>> vDDDTypes(42)
@@ -722,6 +724,9 @@
>>> vWeekday.from_ical('mo')
'MO'
+ >>> vWeekday.from_ical('+3mo')
+ '+3MO'
+
>>> vWeekday.from_ical('Saturday')
Traceback (most recent call last):
...
@@ -731,23 +736,30 @@
>>> a.ical()
'+MO'
+ >>> a = vWeekday('+3mo')
+ >>> a.ical()
+ '+3MO'
+
>>> a = vWeekday('-tu')
>>> a.ical()
'-TU'
"""
- week_days = CaselessDict({"SU":0, "MO":1, "TU":2, "WE":3, "TH":4, "FR":5, "SA":6})
+ week_days = CaselessDict({"SU":0, "MO":1, "TU":2, "WE":3,
+ "TH":4, "FR":5, "SA":6})
def __init__(self, *args, **kwargs):
str.__init__(self, *args, **kwargs)
- if len(self) == 2:
- sign = '+'
- weekday = self
- else:
- sign = self[0]
- weekday = self[1:]
+ match = WEEKDAY_RULE.match(self)
+ if match is None:
+ raise ValueError, 'Expected weekday abbrevation, got: %s' % self
+ match = match.groupdict()
+ sign = match['signal']
+ weekday = match['weekday']
+ relative = match['relative']
if not weekday in vWeekday.week_days or sign not in '+-':
raise ValueError, 'Expected weekday abbrevation, got: %s' % self
+ self.relative = relative and int(relative) or None
self.params = Parameters()
def ical(self):
@@ -922,7 +934,6 @@
recur[key] = vRecur.parse_type(key, vals)
return dict(recur)
except:
- raise
raise ValueError, 'Error in recurrence rule: %s' % ical
from_ical = staticmethod(from_ical)
More information about the icalendar-checkins
mailing list