[Calypso] [PATCH 2/3] Add support for per calendar colors.
Guido Günther
agx at sigxcpu.org
Sat Apr 9 15:15:58 PDT 2016
On Sat, Apr 09, 2016 at 06:09:42PM +0000, Jelmer Vernooij wrote:
> From: Jelmer Vernooij <jelmer at jelmer.uk>
>
> ---
> calypso/webdav.py | 8 ++++++++
> calypso/xmlutils.py | 3 +++
> 2 files changed, 11 insertions(+)
>
> diff --git a/calypso/webdav.py b/calypso/webdav.py
> index 5573997..4ed095c 100644
> --- a/calypso/webdav.py
> +++ b/calypso/webdav.py
> @@ -581,6 +581,14 @@ class Collection(object):
> return _text
>
> @property
> + def color(self):
> + """Color."""
> + try:
> + return "#%s" % self.metadata.get('collection', 'color')
> + except (ConfigParser.NoSectionError, ConfigParser.NoOptionError, ValueError):
> + return None
> +
> + @property
> def headers(self):
> """Find headers items in collection."""
> return []
> diff --git a/calypso/xmlutils.py b/calypso/xmlutils.py
> index 127076c..e705588 100644
> --- a/calypso/xmlutils.py
> +++ b/calypso/xmlutils.py
> @@ -46,6 +46,7 @@ NAMESPACES = {
> "C": "urn:ietf:params:xml:ns:caldav",
> "A": "urn:ietf:params:xml:ns:carddav",
> "D": "DAV:",
> + "E": "http://apple.com/ns/ical/",
> "CS": "http://calendarserver.org/ns/"}
>
> log = logging.getLogger(__name__)
> @@ -177,6 +178,8 @@ def propfind(path, xml_request, collection, depth, context):
> element.text = item.etag
> elif tag == _tag("D", "displayname") and is_collection:
> element.text = collection.name
> + elif tag == _tag("E", "calendar-color") and is_collection:
> + element.text = collection.color
> elif tag == _tag("D", "principal-URL"):
> # TODO: use a real principal URL, read rfc3744-4.2 for info
> tag = ET.Element(_tag("D", "href"))
Looks good to me.
Cheers,
-- Guido
More information about the Calypso
mailing list