Duplicate code: Use list and get methods

This commit is contained in:
Unrud 2016-09-04 13:12:55 +02:00
parent 5dbf9df876
commit e7d8b4816c

View File

@ -698,17 +698,9 @@ class Collection(BaseCollection):
return time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(last))
def serialize(self):
if not os.path.exists(self._filesystem_path):
return None
items = []
for href in os.listdir(self._filesystem_path):
if not is_safe_filesystem_path_component(href):
self.logger.debug("Skipping component: %s", href)
continue
path = os.path.join(self._filesystem_path, href)
if os.path.isfile(path):
with open(path, encoding=self.encoding, newline="") as fd:
items.append(vobject.readOne(fd.read()))
for href in self.list():
items.append(self.get(href).item)
if self.get_meta("tag") == "VCALENDAR":
collection = vobject.iCalendar()
for item in items: