File: namespace.py

package info (click to toggle)
python-caldav 1.3.9-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 636 kB
  • sloc: python: 6,824; makefile: 91; sh: 7
file content (22 lines) | stat: -rw-r--r-- 668 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python
# -*- encoding: utf-8 -*-

nsmap = {
    "D": "DAV:",
    "C": "urn:ietf:params:xml:ns:caldav",
}

## silly thing with this one ... but quite many caldav libraries,
## caldav clients and caldav servers supports this namespace and the
## calendar-color and calendar-order properties.  However, those
## attributes aren't described anywhere, and the I-URL even gives a
## 404!  I don't want to ship it in the namespace list of every request.
nsmap2 = nsmap.copy()
nsmap2["I"] = ("http://apple.com/ns/ical/",)


def ns(prefix, tag=None):
    name = "{%s}" % nsmap2[prefix]
    if tag is not None:
        name = "%s%s" % (name, tag)
    return name