1.1 --- a/README.txt Thu Apr 25 22:11:23 2013 +0200
1.2 +++ b/README.txt Thu Apr 25 22:14:56 2013 +0200
1.3 @@ -34,3 +34,6 @@
1.4 * Added support for writing resources through a specific write method
1.5 instead of using a stream, thus changing the iterwrite function's
1.6 signature.
1.7 + * Added support for multiple property values, producing lists for
1.8 + collections of such values when parsing, and accepting lists of such
1.9 + values when writing.
2.1 --- a/tests/test.ics Thu Apr 25 22:11:23 2013 +0200
2.2 +++ b/tests/test.ics Thu Apr 25 22:14:56 2013 +0200
2.3 @@ -13,6 +13,7 @@
2.4 SUMMARY:Testing
2.5 DTSTART;TZID=CEST:20081018T150000
2.6 DTEND;TZID=CEST:20081018T153000
2.7 +RDATE;VALUE=DATE:20081025,20081101
2.8 LOCATION:Oslo\, Norway
2.9 END:VEVENT
2.10 END:VCALENDAR
3.1 --- a/vCalendar.py Thu Apr 25 22:11:23 2013 +0200
3.2 +++ b/vCalendar.py Thu Apr 25 22:14:56 2013 +0200
3.3 @@ -32,6 +32,7 @@
3.4 """
3.5
3.6 import vContent
3.7 +import re
3.8
3.9 try:
3.10 set
3.11 @@ -48,6 +49,8 @@
3.12 ])
3.13 QUOTED_TYPES = set(["URI"])
3.14
3.15 +unquoted_comma_regexp = re.compile(r"(?<!\\),")
3.16 +
3.17 # Parser classes.
3.18
3.19 class vCalendarStreamParser(vContent.StreamParser):
3.20 @@ -66,6 +69,15 @@
3.21
3.22 def decode_content(self, value):
3.23
3.24 + """
3.25 + Decode the given 'value' (which may represent a collection of distinct
3.26 + values), replacing quoted separator characters.
3.27 + """
3.28 +
3.29 + return [self.decode_content_value(v) for v in unquoted_comma_regexp.split(value)]
3.30 +
3.31 + def decode_content_value(self, value):
3.32 +
3.33 "Decode the given 'value', replacing quoted separator characters."
3.34
3.35 # Replace quoted characters (see 4.3.11 in RFC 2445).
3.36 @@ -141,6 +153,18 @@
3.37
3.38 def encode_content(self, value):
3.39
3.40 + """
3.41 + Encode the given 'value' (which may be a list or tuple of separate
3.42 + values), quoting characters and separating collections of values.
3.43 + """
3.44 +
3.45 + if not isinstance(value, (list, tuple)):
3.46 + value = [value]
3.47 +
3.48 + return ",".join([self.encode_content_value(v) for v in value])
3.49 +
3.50 + def encode_content_value(self, value):
3.51 +
3.52 "Encode the given 'value', quoting characters."
3.53
3.54 # Replace quoted characters (see 4.3.11 in RFC 2445).