Default implementation for BaseCollection.serialize
This commit is contained in:
parent
47d311b101
commit
dbd06a1952
@ -504,7 +504,16 @@ class BaseCollection:
|
|||||||
|
|
||||||
def serialize(self):
|
def serialize(self):
|
||||||
"""Get the unicode string representing the whole collection."""
|
"""Get the unicode string representing the whole collection."""
|
||||||
raise NotImplementedError
|
if self.get_meta("tag") == "VCALENDAR":
|
||||||
|
collection = vobject.iCalendar()
|
||||||
|
for item in self.get_all():
|
||||||
|
for content in ("vevent", "vtodo", "vjournal"):
|
||||||
|
for component in getattr(item, "%s_list" % content, ()):
|
||||||
|
collection.add(component)
|
||||||
|
return collection.serialize()
|
||||||
|
elif self.get_meta("tag") == "VADDRESSBOOK":
|
||||||
|
return "".join(item.serialize() for item in self.get_all())
|
||||||
|
return ""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@contextmanager
|
@contextmanager
|
||||||
|
Loading…
Reference in New Issue
Block a user