[Calypso] [PATCH] Add support for addressbook-description and calendar-description attributes.
Jelmer Vernooij
jelmer at jelmer.uk
Tue Jan 12 18:22:27 PST 2016
From: Jelmer Vernooij <jelmer at samba.org>
See RFC4791, par 5.2.1.
---
calypso/webdav.py | 7 +++++++
calypso/xmlutils.py | 7 +++----
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/calypso/webdav.py b/calypso/webdav.py
index b533a57..238067a 100644
--- a/calypso/webdav.py
+++ b/calypso/webdav.py
@@ -232,6 +232,13 @@ class CalypsoError(Exception):
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)
diff --git a/calypso/xmlutils.py b/calypso/xmlutils.py
index 3dfbcff..f9d73d7 100644
--- a/calypso/xmlutils.py
+++ b/calypso/xmlutils.py
@@ -218,10 +218,9 @@ def propfind(path, xml_request, collection, depth, context):
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"))
--
2.7.0.rc3
More information about the Calypso
mailing list