1.1 --- a/README.txt Thu Apr 25 22:14:56 2013 +0200
1.2 +++ b/README.txt Thu Apr 25 22:43:38 2013 +0200
1.3 @@ -36,4 +36,5 @@
1.4 signature.
1.5 * Added support for multiple property values, producing lists for
1.6 collections of such values when parsing, and accepting lists of such
1.7 - values when writing.
1.8 + values when writing. Tuples of values are also handled where such values
1.9 + are separated by semicolons.
2.1 --- a/tests/test.ics Thu Apr 25 22:14:56 2013 +0200
2.2 +++ b/tests/test.ics Thu Apr 25 22:43:38 2013 +0200
2.3 @@ -15,5 +15,6 @@
2.4 DTEND;TZID=CEST:20081018T153000
2.5 RDATE;VALUE=DATE:20081025,20081101
2.6 LOCATION:Oslo\, Norway
2.7 +GEO:59.95;10.76
2.8 END:VEVENT
2.9 END:VCALENDAR
3.1 --- a/vCalendar.py Thu Apr 25 22:14:56 2013 +0200
3.2 +++ b/vCalendar.py Thu Apr 25 22:43:38 2013 +0200
3.3 @@ -49,7 +49,7 @@
3.4 ])
3.5 QUOTED_TYPES = set(["URI"])
3.6
3.7 -unquoted_comma_regexp = re.compile(r"(?<!\\),")
3.8 +unquoted_separator_regexp = re.compile(r"(?<!\\)([,;])")
3.9
3.10 # Parser classes.
3.11
3.12 @@ -74,7 +74,22 @@
3.13 values), replacing quoted separator characters.
3.14 """
3.15
3.16 - return [self.decode_content_value(v) for v in unquoted_comma_regexp.split(value)]
3.17 + sep = None
3.18 + values = []
3.19 +
3.20 + for i, s in enumerate(unquoted_separator_regexp.split(value)):
3.21 + if i % 2 != 0:
3.22 + if not sep:
3.23 + sep = s
3.24 + continue
3.25 + values.append(self.decode_content_value(s))
3.26 +
3.27 + if sep == ",":
3.28 + return values
3.29 + elif sep == ";":
3.30 + return tuple(values)
3.31 + else:
3.32 + return values[0]
3.33
3.34 def decode_content_value(self, value):
3.35
3.36 @@ -158,10 +173,15 @@
3.37 values), quoting characters and separating collections of values.
3.38 """
3.39
3.40 - if not isinstance(value, (list, tuple)):
3.41 + if isinstance(value, list):
3.42 + sep = ","
3.43 + elif isinstance(value, tuple):
3.44 + sep = ";"
3.45 + else:
3.46 value = [value]
3.47 + sep = ""
3.48
3.49 - return ",".join([self.encode_content_value(v) for v in value])
3.50 + return sep.join([self.encode_content_value(v) for v in value])
3.51
3.52 def encode_content_value(self, value):
3.53