class Collection(object):
"""Internal collection class."""
+ def get_description(self):
+ f = codecs.open(os.path.join(self.path, ".git/description"), encoding='utf-8')
+ try:
+ return f.read()
+ finally:
+ f.close()
+
def read_file(self, path):
text = codecs.open(path,encoding='utf-8').read()
item = Item(text, None, path)
tag = ET.Element(_tag("D", "href"))
tag.text = config.get("server", "user_principal") % context
element.append(tag)
- elif tag == _tag("A", "addressbook-description") and is_collection:
- element.text = collection.read_file(".git/description")
- elif tag == _tag("C", "calendar-description") and is_collection:
- element.text = collection.read_file(".git/description")
+ elif tag in (_tag("A", "addressbook-description"),
+ _tag("C", "calendar-description")) and is_collection:
+ element.text = collection.get_description()
prop.append(element)
status = ET.Element(_tag("D", "status"))