# HG changeset patch # User Paul Boddie # Date 1411398537 -7200 # Node ID bcc012bf5481250003e38ca854b9a19362788e8b # Parent cd6361a07eba178e830b0b14d63c9c4ef68949d4 Added support for hierarchical output to the write method of the stream writer. diff -r cd6361a07eba -r bcc012bf5481 vCalendar.py --- a/vCalendar.py Mon Sep 22 17:08:22 2014 +0200 +++ b/vCalendar.py Mon Sep 22 17:08:57 2014 +0200 @@ -41,6 +41,9 @@ # Format details. +SECTION_TYPES = set([ + "VALARM", "VCALENDAR", "VEVENT", "VFREEBUSY", "VJOURNAL", "VTIMEZONE", "VTODO" + ]) QUOTED_PARAMETERS = set([ "ALTREP", "DELEGATED-FROM", "DELEGATED-TO", "DIR", "MEMBER", "SENT-BY" ]) @@ -146,6 +149,21 @@ # Overridden methods. + def write(self, name, parameters, value): + + """ + Write a content line, serialising the given 'name', 'parameters' and + 'value' information. + """ + + if name in SECTION_TYPES: + self.write_content_line("BEGIN", {}, name) + for n, p, v in value: + self.write(n, p, v) + self.write_content_line("END", {}, name) + else: + vContent.StreamWriter.write(self, name, parameters, value) + def encode_parameters(self, parameters): """