[CalendarServer-changes] [11788] CalendarServer/branches/users/cdaboo/scheduling-queue-refresh
source_changes at macosforge.org
source_changes at macosforge.org
Fri Oct 4 09:40:38 PDT 2013
Revision: 11788
http://trac.calendarserver.org//changeset/11788
Author: cdaboo at apple.com
Date: 2013-10-04 09:40:38 -0700 (Fri, 04 Oct 2013)
Log Message:
-----------
Whitespace and clean-up.
Modified Paths:
--------------
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/contrib/performance/loadtest/ampsim.py
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/support/version.py
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/base/datastore/subpostgres.py
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/base/datastore/test/test_subpostgres.py
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/caldav/datastore/scheduling/imip/inbound.py
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/caldav/datastore/scheduling/imip/test/test_inbound.py
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/base.py
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/element.py
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/parser.py
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/parser_base.py
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/parser_etree.py
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/parser_sax.py
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc2518.py
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc3253.py
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc3744.py
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc4331.py
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc5397.py
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc5842.py
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc5995.py
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/test/test_base.py
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/test/test_xml.py
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/test/test_xml_rfc3744.py
CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/xmlext.py
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/contrib/performance/loadtest/ampsim.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/contrib/performance/loadtest/ampsim.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/contrib/performance/loadtest/ampsim.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -34,7 +34,7 @@
from twisted.internet import reactor
from twisted.internet.stdio import StandardIO
- from contrib.performance.loadtest.ampsim import Worker
+ #from contrib.performance.loadtest.ampsim import Worker
from contrib.performance.loadtest.sim import LagTrackingReactor
StandardIO(Worker(LagTrackingReactor(reactor)))
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/support/version.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/support/version.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/support/version.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -36,7 +36,7 @@
"trunk",
)
)
-
+
source_root = dirname(dirname(__file__))
for branch in branches:
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/base/datastore/subpostgres.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/base/datastore/subpostgres.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/base/datastore/subpostgres.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -469,7 +469,7 @@
log.failure("starting postgres", f)
self.deactivateDelayedShutdown()
self.reactor.stop()
-
+
self.monitor.completionDeferred.addCallback(
gotReady).addErrback(reportit)
@@ -549,6 +549,7 @@
# d.addCallback(maybeStopSubprocess)
# return d
+
def hardStop(self):
"""
Stop postgres quickly by sending it SIGQUIT
@@ -556,5 +557,5 @@
if self._postgresPid is not None:
try:
os.kill(self._postgresPid, signal.SIGQUIT)
- except OSError:
+ except OSError:
pass
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/base/datastore/test/test_subpostgres.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/base/datastore/test/test_subpostgres.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/base/datastore/test/test_subpostgres.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -189,5 +189,3 @@
cursor.execute("select * from import_test_table")
values = cursor.fetchall()
self.assertEquals(values, [["value1"], ["value2"]])
-
-
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/caldav/datastore/scheduling/imip/inbound.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/caldav/datastore/scheduling/imip/inbound.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/caldav/datastore/scheduling/imip/inbound.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -143,6 +143,7 @@
yield scheduleNextMailPoll(self.store, seconds)
+
def shouldDeleteAllMail(serverHostName, inboundServer, username):
"""
Given the hostname of the calendar server, the hostname of the pop/imap
@@ -165,6 +166,7 @@
)
+
@inlineCallbacks
def scheduleNextMailPoll(store, seconds):
txn = store.newTransaction()
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/caldav/datastore/scheduling/imip/test/test_inbound.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/caldav/datastore/scheduling/imip/test/test_inbound.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/caldav/datastore/scheduling/imip/test/test_inbound.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -436,13 +436,13 @@
self.assertEquals(self.flagDeletedResult, "xyzzy")
+
class StubFactory(object):
def __init__(self, actionTaken, deleteAllMail):
self.actionTaken = actionTaken
self.deleteAllMail = deleteAllMail
+
def handleMessage(self, messageData):
return succeed(self.actionTaken)
-
-
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/base.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/base.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/base.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -80,6 +80,7 @@
return sname.encode("utf-8")
+
def decodeXMLName(name):
"""
Decodes an XML (namespace, name) pair from an ASCII string as
@@ -97,7 +98,7 @@
invalid()
namespace = name[1:index].decode("utf-8")
- localname = name[index+1:].decode("utf-8")
+ localname = name[index + 1:].decode("utf-8")
if not namespace:
namespace = None
@@ -108,25 +109,27 @@
else:
namespace = None
localname = name.decode("utf-8")
-
+
if "{" in localname or "}" in localname:
invalid()
return (namespace, localname)
+
class WebDAVElement (object):
"""
WebDAV XML element. (RFC 2518, section 12)
"""
- namespace = dav_namespace # Element namespace (class variable)
- name = None # Element name (class variable)
- allowed_children = None # Types & count limits on child elements
+ namespace = dav_namespace # Element namespace (class variable)
+ name = None # Element name (class variable)
+ allowed_children = None # Types & count limits on child elements
allowed_attributes = None # Allowed attribute names
- hidden = False # Don't list in PROPFIND with <allprop>
- protected = False # See RFC 3253 section 1.4.1
- unregistered = False # Subclass of factory; doesn't register
+ hidden = False # Don't list in PROPFIND with <allprop>
+ protected = False # See RFC 3253 section 1.4.1
+ unregistered = False # Subclass of factory; doesn't register
+
def __init__(self, *children, **attributes):
super(WebDAVElement, self).__init__()
@@ -138,7 +141,7 @@
my_children = []
- allowPCDATA = self.allowed_children.has_key(PCDATAElement)
+ allowPCDATA = PCDATAElement in self.allowed_children
for child in children:
if child is None:
@@ -155,14 +158,17 @@
self.children = tuple(my_children)
self.attributes = attributes
+
@classmethod
def qname(cls):
return (cls.namespace, cls.name)
+
@classmethod
def sname(cls):
return encodeXMLName(cls.namespace, cls.name)
+
def validate(self):
children = self.children
attributes = self.attributes
@@ -187,7 +193,7 @@
for child in children:
assert isinstance(child, (WebDAVElement, PCDATAElement)), "Not an element: %r" % (child,)
-
+
child.validate()
for allowed, (min, max) in allowed_children.items():
@@ -244,36 +250,43 @@
self.attributes = my_attributes
+
def __str__(self):
return self.sname()
+
def __repr__(self):
if hasattr(self, "attributes") and hasattr(self, "children"):
return "<%s %r: %r>" % (self.sname(), self.attributes, self.children)
else:
return "<%s>" % (self.sname())
+
def __eq__(self, other):
if isinstance(other, WebDAVElement):
return (
- self.name == other.name and
- self.namespace == other.namespace and
+ self.name == other.name and
+ self.namespace == other.namespace and
self.attributes == other.attributes and
- self.children == other.children
+ self.children == other.children
)
else:
return NotImplemented
+
def __ne__(self, other):
return not self.__eq__(other)
+
def __contains__(self, child):
return child in self.children
+
def writeXML(self, output, pretty=True):
output.write("<?xml version='1.0' encoding='UTF-8'?>" + ("\n" if pretty else ""))
self._writeToStream(output, "", 0, pretty)
+
def _writeToStream(self, output, ns, level, pretty):
"""
Fast XML output.
@@ -283,11 +296,11 @@
@param level: C{int} containing the element nesting level (starts at 0).
@param pretty: C{bool} whether to use 'pretty' formatted output or not.
"""
-
+
# Do pretty indent
if pretty and level:
output.write(" " * level)
-
+
# Check for empty element (one with either no children or a single PCDATA that is itself empty)
if (len(self.children) == 0 or
(len(self.children) == 1 and isinstance(self.children[0], PCDATAElement) and len(str(self.children[0])) == 0)):
@@ -314,7 +327,7 @@
output.write(">")
else:
output.write("<%s>" % (self.name,))
-
+
# Determine nature of children when doing pretty print: we do
# not want to insert CRLFs or any other whitespace in PCDATA.
hasPCDATA = False
@@ -322,13 +335,13 @@
if isinstance(child, PCDATAElement):
hasPCDATA = True
break
-
+
# Write out the children.
if pretty and not hasPCDATA:
output.write("\r\n")
for child in self.children:
- child._writeToStream(output, ns, level+1, pretty)
-
+ child._writeToStream(output, ns, level + 1, pretty)
+
# Close the element.
if pretty and not hasPCDATA and level:
output.write(" " * level)
@@ -337,18 +350,21 @@
if pretty and level:
output.write("\r\n")
+
def _writeAttributeToStream(self, output, name, value):
-
+
# Quote any single quotes. We do not need to be any smarter than this.
value = value.replace("'", "'")
- output.write(" %s='%s'" % (name, value,))
-
+ output.write(" %s='%s'" % (name, value,))
+
+
def toxml(self, pretty=True):
output = StringIO.StringIO()
self.writeXML(output, pretty)
return str(output.getvalue())
+
def element(self, document):
element = document.createElementNS(self.namespace, self.name)
if hasattr(self, "attributes"):
@@ -359,6 +375,7 @@
element.setAttributeNodeNS(attribute)
return element
+
def addToDOM(self, document, parent):
element = self.element(document)
@@ -375,6 +392,7 @@
log.error("Unable to add child %r of element %s to DOM" % (child, self))
raise
+
def childrenOfType(self, child_type):
"""
Returns a list of children with the same qname as the given type.
@@ -384,8 +402,9 @@
else:
qname = child_type.qname()
- return [ c for c in self.children if c.qname() == qname ]
+ return [c for c in self.children if c.qname() == qname]
+
def childOfType(self, child_type):
"""
Returns a child of the given type, if any, or None.
@@ -398,6 +417,7 @@
found = child
return found
+
def removeWhitespaceNodes(self):
""" Removes all of the whitespace-only text decendants of a DOM node. """
# prepare the list of text nodes to remove (and recurse when needed)
@@ -418,6 +438,7 @@
self.children = tuple(newchildren)
+
class PCDATAElement (object):
def __init__(self, data):
super(PCDATAElement, self).__init__()
@@ -431,29 +452,36 @@
self.data = data
+
@classmethod
def qname(cls):
return (None, "#PCDATA")
+
@classmethod
def sname(cls):
return "#PCDATA"
+
def validate(self):
pass
+
def __str__(self):
return str(self.data)
+
def __repr__(self):
return "<%s: %r>" % (self.__class__.__name__, self.data)
+
def __add__(self, other):
if isinstance(other, PCDATAElement):
return self.__class__(self.data + other.data)
else:
return self.__class__(self.data + other)
+
def __eq__(self, other):
if isinstance(other, PCDATAElement):
return self.data == other.data
@@ -462,18 +490,22 @@
else:
return NotImplemented
+
def __ne__(self, other):
return not self.__eq__(other)
+
def isWhitespace(self):
for char in str(self):
if char not in string.whitespace:
return False
return True
+
def element(self, document):
return document.createTextNode(self.data)
+
def addToDOM(self, document, parent):
try:
parent.appendChild(self.element(document))
@@ -481,6 +513,7 @@
log.error("Invalid PCDATA: %r" % (self.data,))
raise
+
def _writeToStream(self, output, ns, level, pretty):
# Do escaping/CDATA behavior
if "\r" in self.data or "\n" in self.data:
@@ -498,38 +531,40 @@
output.write(cdata)
+
class WebDAVOneShotElement (WebDAVElement):
"""
Element with exactly one WebDAVEmptyElement child and no attributes.
"""
__singletons = {}
- def __new__(clazz, *children):
+ def __new__(cls, *children):
child = None
for next in children:
if isinstance(next, WebDAVEmptyElement):
if child is not None:
raise ValueError("%s must have exactly one child, not %r"
- % (clazz.__name__, children))
+ % (cls.__name__, children))
child = next
elif isinstance(next, PCDATAElement):
pass
else:
raise ValueError("%s child is not a WebDAVEmptyElement instance: %s"
- % (clazz.__name__, next))
+ % (cls.__name__, next))
- if clazz not in WebDAVOneShotElement.__singletons:
- WebDAVOneShotElement.__singletons[clazz] = {
- child: WebDAVElement.__new__(clazz)
+ if cls not in WebDAVOneShotElement.__singletons:
+ WebDAVOneShotElement.__singletons[cls] = {
+ child: WebDAVElement.__new__(cls)
}
- elif child not in WebDAVOneShotElement.__singletons[clazz]:
- WebDAVOneShotElement.__singletons[clazz][child] = (
- WebDAVElement.__new__(clazz)
+ elif child not in WebDAVOneShotElement.__singletons[cls]:
+ WebDAVOneShotElement.__singletons[cls][child] = (
+ WebDAVElement.__new__(cls)
)
- return WebDAVOneShotElement.__singletons[clazz][child]
+ return WebDAVOneShotElement.__singletons[cls][child]
+
class WebDAVUnknownElement (WebDAVElement):
"""
Placeholder for unknown element tag names.
@@ -546,32 +581,36 @@
child.name = name
return child
+
def qname(self):
return (self.namespace, self.name)
+
def sname(self):
return encodeXMLName(self.namespace, self.name)
+
class WebDAVEmptyElement (WebDAVElement):
"""
WebDAV element with no contents.
"""
__singletons = {}
- def __new__(clazz, *args, **kwargs):
+ def __new__(cls, *args, **kwargs):
assert not args
if kwargs:
- return WebDAVElement.__new__(clazz)
+ return WebDAVElement.__new__(cls)
else:
- if clazz not in WebDAVEmptyElement.__singletons:
- WebDAVEmptyElement.__singletons[clazz] = (WebDAVElement.__new__(clazz))
- return WebDAVEmptyElement.__singletons[clazz]
+ if cls not in WebDAVEmptyElement.__singletons:
+ WebDAVEmptyElement.__singletons[cls] = (WebDAVElement.__new__(cls))
+ return WebDAVEmptyElement.__singletons[cls]
allowed_children = {}
children = ()
+
def __hash__(self):
"""
Define a hash method, so that an empty element can serve as dictionary
@@ -581,6 +620,7 @@
return hash((self.name, self.namespace))
+
class WebDAVTextElement (WebDAVElement):
"""
WebDAV element containing PCDATA.
@@ -594,20 +634,23 @@
else:
return clazz(PCDATAElement(str(string)))
- allowed_children = { PCDATAElement: (0, None) }
+ allowed_children = {PCDATAElement: (0, None)}
+
def toString(self):
"""
@return: a unicode string containing the text in this element.
"""
return self.__str__().decode("utf-8")
+
def __str__(self):
"""
@return: a byte string containing the text in this element.
"""
return b"".join([c.data for c in self.children])
+
def __repr__(self):
content = str(self)
if content:
@@ -615,6 +658,7 @@
else:
return "<%s>" % (self.sname(),)
+
def __eq__(self, other):
if isinstance(other, self.__class__):
return str(self) == str(other)
@@ -624,6 +668,7 @@
return NotImplemented
+
class WebDAVDateTimeElement (WebDAVTextElement):
"""
WebDAV date-time element. (RFC 2518, section 23.2)
@@ -654,16 +699,19 @@
return clazz(PCDATAElement(date))
+
def __init__(self, *children, **attributes):
super(WebDAVDateTimeElement, self).__init__(*children, **attributes)
self.datetime() # Raise ValueError if the format is wrong
+
def __eq__(self, other):
if isinstance(other, self.__class__):
return self.datetime() == other.datetime()
else:
return NotImplemented
+
def datetime(self):
s = str(self)
if not s:
@@ -672,6 +720,7 @@
return parse_date(s)
+
class DateTimeHeaderElement (WebDAVDateTimeElement):
"""
WebDAV date-time element for elements that substitute for HTTP
@@ -707,6 +756,7 @@
return clazz(PCDATAElement(date))
+
def datetime(self):
s = str(self)
if not s:
@@ -715,6 +765,7 @@
return parseDateTime(s)
+
##
# Utilities
##
@@ -727,13 +778,21 @@
super(FixedOffset, self).__init__()
self._offset = datetime.timedelta(minutes=offset)
- self._name = name
+ self._name = name
- def utcoffset(self, dt): return self._offset
- def tzname (self, dt): return self._name
- def dst (self, dt): return datetime.timedelta(0)
+ def utcoffset(self, dt):
+ return self._offset
+
+ def tzname(self, dt):
+ return self._name
+
+
+ def dst(self, dt):
+ return datetime.timedelta(0)
+
+
_regex_ISO8601Date = re.compile(
"^" +
"(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})T" +
@@ -760,19 +819,21 @@
if offset_sign is None:
offset = FixedOffset(0)
else:
- offset_hour = int(match.group("offset_hour" ))
+ offset_hour = int(match.group("offset_hour"))
offset_minute = int(match.group("offset_minute"))
delta = (offset_hour * 60) + offset_minute
- if offset_sign == "+": offset = FixedOffset(0 - delta)
- elif offset_sign == "-": offset = FixedOffset(0 + delta)
+ if offset_sign == "+":
+ offset = FixedOffset(0 - delta)
+ elif offset_sign == "-":
+ offset = FixedOffset(0 + delta)
return datetime.datetime(
- int(match.group("year" )),
- int(match.group("month" )),
- int(match.group("day" )),
- int(match.group("hour" )),
+ int(match.group("year")),
+ int(match.group("month")),
+ int(match.group("day")),
+ int(match.group("hour")),
int(match.group("minute")),
int(match.group("second")),
subsecond,
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/element.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/element.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/element.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -7,10 +7,10 @@
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -65,19 +65,20 @@
assert elementClass.name, "Element has no name: %s" % (elementClass,)
qname = elementClass.namespace, elementClass.name
-
+
if qname in _elements_by_qname:
raise AssertionError(
"Attempting to register element %s multiple times: (%r, %r)"
% (elementClass.sname(), _elements_by_qname[qname], elementClass)
)
-
+
if not (qname in _elements_by_qname and issubclass(elementClass, _elements_by_qname[qname])):
_elements_by_qname[qname] = elementClass
return elementClass
+
def registerElementClass(elementClass):
"""
Add an XML element class to this module's namespace.
@@ -97,8 +98,23 @@
return elementClass
+
def lookupElement(qname):
"""
Return the element class for the element with the given qname.
"""
return _elements_by_qname[qname]
+
+# Shhh unused imports
+WebDAVDocument
+dav_namespace
+twisted_dav_namespace
+twisted_private_namespace
+WebDAVElement
+PCDATAElement
+WebDAVOneShotElement
+WebDAVUnknownElement
+WebDAVEmptyElement
+WebDAVTextElement
+WebDAVDateTimeElement
+DateTimeHeaderElement
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/parser.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/parser.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/parser.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -7,10 +7,10 @@
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -33,3 +33,6 @@
]
from txdav.xml.parser_etree import WebDAVDocument
+
+# Shh unused import
+WebDAVDocument
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/parser_base.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/parser_base.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/parser_base.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -7,10 +7,10 @@
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -37,6 +37,7 @@
def fromStream(cls, source):
raise NotImplementedError()
+
@classmethod
def fromString(cls, source):
source = StringIO(source)
@@ -45,6 +46,7 @@
finally:
source.close()
+
def __init__(self, root_element):
"""
root_element must be a WebDAVElement instance.
@@ -56,18 +58,22 @@
self.root_element = root_element
+
def __str__(self):
return self.toxml()
+
def __eq__(self, other):
if isinstance(other, AbstractWebDAVDocument):
return self.root_element == other.root_element
else:
return NotImplemented
+
def writeXML(self, output):
raise NotImplementedError()
+
def toxml(self):
output = StringIO()
self.writeXML(output)
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/parser_etree.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/parser_etree.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/parser_etree.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -7,10 +7,10 @@
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -28,7 +28,7 @@
"WebDAVDocument",
]
-from xml.etree.ElementTree import TreeBuilder, XMLParser,\
+from xml.etree.ElementTree import TreeBuilder, XMLParser, \
_namespace_map
from txdav.xml.base import WebDAVUnknownElement, PCDATAElement
from txdav.xml.base import _elements_by_qname
@@ -39,15 +39,19 @@
except ImportError:
from xml.parsers.expat import ExpatError as XMLParseError
+
+
def QNameSplit(qname):
return tuple(qname[1:].split("}", 1)) if "}" in qname else ("", qname,)
+
+
class WebDAVContentHandler (TreeBuilder):
def __init__(self):
TreeBuilder.__init__(self)
self._characterBuffer = None
-
+
self.startDocument()
@@ -56,7 +60,6 @@
Doctype declaration is ignored.
"""
-
def startDocument(self):
self.stack = [{
"name" : None,
@@ -71,6 +74,7 @@
# multiple times in a document.
self.unknownElementClasses = {}
+
def close(self):
top = self.stack[-1]
@@ -83,12 +87,14 @@
del(self.unknownElementClasses)
return self.dom
+
def data(self, data):
# Stash character data away in a list that we will "".join() when done
if self._characterBuffer is None:
self._characterBuffer = []
self._characterBuffer.append(data)
+
def start(self, tag, attrs):
name = QNameSplit(tag)
@@ -117,7 +123,7 @@
def element_class(*args, **kwargs):
element = WebDAVUnknownElement(*args, **kwargs)
element.namespace = tag_namespace
- element.name = tag_name
+ element.name = tag_name
return element
self.unknownElementClasses[name] = element_class
@@ -128,6 +134,7 @@
"children" : [],
})
+
def end(self, tag):
name = QNameSplit(tag)
@@ -149,10 +156,11 @@
self.stack[-1]["children"].append(element)
+
class WebDAVDocument(AbstractWebDAVDocument):
@classmethod
def fromStream(cls, source):
- parser = XMLParser(target=WebDAVContentHandler())
+ parser = XMLParser(target=WebDAVContentHandler())
try:
while 1:
data = source.read(65536)
@@ -162,6 +170,7 @@
except XMLParseError, e:
raise ValueError(e)
return parser.close()
-
+
+
def writeXML(self, output):
self.root_element.writeXML(output)
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/parser_sax.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/parser_sax.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/parser_sax.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -7,10 +7,10 @@
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -34,16 +34,21 @@
class WebDAVContentHandler (xml.sax.handler.ContentHandler):
- def setDocumentLocator(self, locator): self.locator = locator
+
+ def setDocumentLocator(self, locator):
+ self.locator = locator
+
locator = None
def __init__(self):
xml.sax.handler.ContentHandler.__init__(self)
self._characterBuffer = None
+
def location(self):
return "line %d, column %d" % (self.locator.getLineNumber(), self.locator.getColumnNumber())
+
def startDocument(self):
self.stack = [{
"name" : None,
@@ -58,6 +63,7 @@
# multiple times in a document.
self.unknownElementClasses = {}
+
def endDocument(self):
top = self.stack[-1]
@@ -69,6 +75,7 @@
self.dom = WebDAVDocument(top["children"][0])
del(self.unknownElementClasses)
+
def startElementNS(self, name, qname, attributes):
if self._characterBuffer is not None:
pcdata = PCDATAElement("".join(self._characterBuffer))
@@ -91,7 +98,7 @@
def element_class(*args, **kwargs):
element = WebDAVUnknownElement(*args, **kwargs)
element.namespace = tag_namespace
- element.name = tag_name
+ element.name = tag_name
return element
self.unknownElementClasses[name] = element_class
@@ -102,6 +109,7 @@
"children" : [],
})
+
def endElementNS(self, name, qname):
if self._characterBuffer is not None:
pcdata = PCDATAElement("".join(self._characterBuffer))
@@ -124,33 +132,41 @@
self.stack[-1]["children"].append(element)
+
def characters(self, content):
# Stash character data away in a list that we will "".join() when done
if self._characterBuffer is None:
self._characterBuffer = []
self._characterBuffer.append(content)
+
def ignorableWhitespace(self, whitespace):
self.characters(self, whitespace)
+
def startElement(self, name, attributes):
raise AssertionError("startElement() should not be called by namespace-aware parser")
+
def endElement(self, name):
raise AssertionError("endElement() should not be called by namespace-aware parser")
+
def processingInstruction(self, target, data):
raise AssertionError("processing instructions are not allowed")
+
def skippedEntity(self, name):
raise AssertionError("skipped entities are not allowed")
+
class WebDAVDocument(AbstractWebDAVDocument):
+
@classmethod
def fromStream(cls, source):
handler = WebDAVContentHandler()
- parser = xml.sax.make_parser()
+ parser = xml.sax.make_parser()
parser.setContentHandler(handler)
parser.setFeature(xml.sax.handler.feature_namespaces, True)
@@ -163,7 +179,8 @@
#handler.dom.root_element.validate()
return handler.dom
-
+
+
def writeXML(self, output):
document = xml.dom.minidom.Document()
self.root_element.addToDOM(document, None)
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc2518.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc2518.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc2518.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -7,10 +7,10 @@
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -56,14 +56,15 @@
allowed_children = {
(dav_namespace, "lockscope"): (1, 1),
- (dav_namespace, "locktype" ): (1, 1),
- (dav_namespace, "depth" ): (1, 1),
- (dav_namespace, "owner" ): (0, 1),
- (dav_namespace, "timeout" ): (0, 1),
+ (dav_namespace, "locktype"): (1, 1),
+ (dav_namespace, "depth"): (1, 1),
+ (dav_namespace, "owner"): (0, 1),
+ (dav_namespace, "timeout"): (0, 1),
(dav_namespace, "locktoken"): (0, 1),
}
+
@registerElement
@registerElementClass
class Depth (WebDAVTextElement):
@@ -80,6 +81,7 @@
raise ValueError("Invalid depth: %s" % (depth,))
+
@registerElement
@registerElementClass
class LockToken (WebDAVElement):
@@ -88,9 +90,10 @@
"""
name = "locktoken"
- allowed_children = { (dav_namespace, "href"): (1, None) }
+ allowed_children = {(dav_namespace, "href"): (1, None)}
+
@registerElement
@registerElementClass
class Timeout (WebDAVTextElement):
@@ -100,6 +103,7 @@
name = "timeout"
+
@registerElement
@registerElementClass
class Collection (WebDAVEmptyElement):
@@ -109,6 +113,7 @@
name = "collection"
+
@registerElement
@registerElementClass
class HRef (WebDAVTextElement):
@@ -118,6 +123,7 @@
name = "href"
+
@registerElement
@registerElementClass
class Link (WebDAVElement):
@@ -133,6 +139,7 @@
}
+
@registerElement
@registerElementClass
class LinkDestination (WebDAVTextElement):
@@ -142,6 +149,7 @@
name = "dst"
+
@registerElement
@registerElementClass
class LinkSource (WebDAVTextElement):
@@ -151,6 +159,7 @@
name = "src"
+
@registerElement
@registerElementClass
class LockEntry (WebDAVElement):
@@ -162,10 +171,11 @@
allowed_children = {
(dav_namespace, "lockscope"): (1, 1),
- (dav_namespace, "locktype" ): (1, 1),
+ (dav_namespace, "locktype"): (1, 1),
}
+
@registerElement
@registerElementClass
class LockInfo (WebDAVElement):
@@ -177,11 +187,12 @@
allowed_children = {
(dav_namespace, "lockscope"): (1, 1),
- (dav_namespace, "locktype" ): (1, 1),
- (dav_namespace, "owner" ): (0, 1),
+ (dav_namespace, "locktype"): (1, 1),
+ (dav_namespace, "owner"): (0, 1),
}
+
@registerElement
@registerElementClass
class LockScope (WebDAVOneShotElement):
@@ -193,10 +204,11 @@
allowed_children = {
(dav_namespace, "exclusive"): (0, 1),
- (dav_namespace, "shared" ): (0, 1),
+ (dav_namespace, "shared"): (0, 1),
}
+
@registerElement
@registerElementClass
class Exclusive (WebDAVEmptyElement):
@@ -227,9 +239,10 @@
"""
name = "locktype"
- allowed_children = { (dav_namespace, "write"): (0, 1) }
+ allowed_children = {(dav_namespace, "write"): (0, 1)}
+
@registerElement
@registerElementClass
class Write (WebDAVEmptyElement):
@@ -244,6 +257,7 @@
LockType.write = LockType(Write())
+
@registerElement
@registerElementClass
class MultiStatus (WebDAVElement):
@@ -253,11 +267,12 @@
name = "multistatus"
allowed_children = {
- (dav_namespace, "response" ): (0, None),
+ (dav_namespace, "response"): (0, None),
(dav_namespace, "responsedescription"): (0, 1),
}
+
@registerElement
@registerElementClass
class Response (WebDAVElement):
@@ -268,46 +283,52 @@
name = "response"
allowed_children = {
- (dav_namespace, "href" ): (1, None),
- (dav_namespace, "status" ): (1, 1),
- (dav_namespace, "propstat" ): (1, None),
- (dav_namespace, "error" ): (0, 1), # 2518bis
+ (dav_namespace, "href"): (1, None),
+ (dav_namespace, "status"): (1, 1),
+ (dav_namespace, "propstat"): (1, None),
+ (dav_namespace, "error"): (0, 1), # 2518bis
(dav_namespace, "responsedescription"): (0, 1),
}
- def __new__(clazz, *children):
- if clazz is not Response: return WebDAVElement.__new__(clazz)
+ def __new__(cls, *children):
+ if cls is not Response:
+ return WebDAVElement.__new__(cls)
+
resource_count = 0
- status_count = 0
+ status_count = 0
propstat_count = 0
for child in children:
- if isinstance(child, HRef ): resource_count += 1
- elif isinstance(child, Status ): status_count += 1
- elif isinstance(child, PropertyStatus): propstat_count += 1
+ if isinstance(child, HRef):
+ resource_count += 1
+ elif isinstance(child, Status):
+ status_count += 1
+ elif isinstance(child, PropertyStatus):
+ propstat_count += 1
if resource_count < 1:
raise ValueError("%s element must have at least one %s."
- % (clazz.sname(), HRef.sname()))
+ % (cls.sname(), HRef.sname()))
if status_count is 0:
if propstat_count is 0:
raise ValueError("%s element must have one of %s or %s"
- % (clazz.sname(), Status.sname(), PropertyStatus.sname()))
+ % (cls.sname(), Status.sname(), PropertyStatus.sname()))
if resource_count > 1:
raise ValueError("%s element with %s may only have one %s"
- % (clazz.sname(), PropertyStatus.sname(), HRef.sname()))
+ % (cls.sname(), PropertyStatus.sname(), HRef.sname()))
return PropertyStatusResponse.__new__(PropertyStatusResponse, *children)
if status_count > 1:
- raise ValueError("%s element may only have one %s" % (clazz.sname(), Status.sname()))
+ raise ValueError("%s element may only have one %s" % (cls.sname(), Status.sname()))
return StatusResponse.__new__(StatusResponse, *children)
+
@registerElementClass
class StatusResponse (Response):
"""
@@ -316,13 +337,14 @@
unregistered = True
allowed_children = {
- (dav_namespace, "href" ): (1, None),
- (dav_namespace, "status" ): (1, 1),
- (dav_namespace, "error" ): (0, 1), # 2518bis
+ (dav_namespace, "href"): (1, None),
+ (dav_namespace, "status"): (1, 1),
+ (dav_namespace, "error"): (0, 1), # 2518bis
(dav_namespace, "responsedescription"): (0, 1),
}
+
@registerElementClass
class PropertyStatusResponse (Response):
"""
@@ -331,13 +353,14 @@
unregistered = True
allowed_children = {
- (dav_namespace, "href" ): (1, 1),
- (dav_namespace, "propstat" ): (1, None),
- (dav_namespace, "error" ): (0, 1), # 2518bis
+ (dav_namespace, "href"): (1, 1),
+ (dav_namespace, "propstat"): (1, None),
+ (dav_namespace, "error"): (0, 1), # 2518bis
(dav_namespace, "responsedescription"): (0, 1),
}
+
@registerElement
@registerElementClass
class PropertyStatus (WebDAVElement):
@@ -348,13 +371,14 @@
name = "propstat"
allowed_children = {
- (dav_namespace, "prop" ): (1, 1),
- (dav_namespace, "status" ): (1, 1),
- (dav_namespace, "error" ): (0, 1), # 2518bis
+ (dav_namespace, "prop"): (1, 1),
+ (dav_namespace, "status"): (1, 1),
+ (dav_namespace, "error"): (0, 1), # 2518bis
(dav_namespace, "responsedescription"): (0, 1),
}
+
@registerElement
@registerElementClass
class Status (WebDAVTextElement):
@@ -363,7 +387,7 @@
"""
name = "status"
- def fromResponseCode(clazz, code):
+ def fromResponseCode(cls, code):
"""
code must be an integer response code in
twext.web2.responsecode.RESPONSES.keys()
@@ -371,10 +395,11 @@
if code not in responsecode.RESPONSES:
raise ValueError("Invalid response code: %r" % (code,))
- return clazz(PCDATAElement("HTTP/1.1 %d %s" % (code, responsecode.RESPONSES[code])))
+ return cls(PCDATAElement("HTTP/1.1 %d %s" % (code, responsecode.RESPONSES[code])))
fromResponseCode = classmethod(fromResponseCode)
+
def __init__(self, *children, **attributes):
super(Status, self).__init__(*children, **attributes)
@@ -389,6 +414,7 @@
self.code = code
+
@registerElement
@registerElementClass
class ResponseDescription (WebDAVTextElement):
@@ -399,6 +425,7 @@
name = "responsedescription"
+
@registerElement
@registerElementClass
class Owner (WebDAVElement):
@@ -414,9 +441,10 @@
hidden = True
protected = True # may be protected, per RFC 3744, section 5.1
- allowed_children = { WebDAVElement: (0, None) }
+ allowed_children = {WebDAVElement: (0, None)}
+
@registerElement
@registerElementClass
class PropertyContainer (WebDAVElement):
@@ -425,9 +453,10 @@
"""
name = "prop"
- allowed_children = { WebDAVElement: (0, None) }
+ allowed_children = {WebDAVElement: (0, None)}
+
@registerElement
@registerElementClass
class PropertyBehavior (WebDAVElement):
@@ -438,10 +467,11 @@
name = "propertybehavior"
allowed_children = {
- (dav_namespace, "omit" ): (0, 1),
+ (dav_namespace, "omit"): (0, 1),
(dav_namespace, "keepalive"): (0, 1),
}
+
def __init__(self, *children, **attributes):
super(PropertyBehavior, self).__init__(*children, **attributes)
@@ -454,6 +484,7 @@
self.behavior = children[0]
+
@registerElement
@registerElementClass
class KeepAlive (WebDAVElement):
@@ -468,6 +499,7 @@
PCDATAElement: (0, 1),
}
+
def validate(self):
super(KeepAlive, self).validate()
@@ -487,6 +519,7 @@
raise ValueError("Invalid keepalive value: %r", (str(self),))
+
@registerElement
@registerElementClass
class Omit (WebDAVEmptyElement):
@@ -497,6 +530,7 @@
name = "omit"
+
@registerElement
@registerElementClass
class PropertyUpdate (WebDAVElement):
@@ -508,10 +542,11 @@
allowed_children = {
(dav_namespace, "remove"): (0, None),
- (dav_namespace, "set" ): (0, None),
+ (dav_namespace, "set"): (0, None),
}
+
@registerElement
@registerElementClass
class Remove (WebDAVElement):
@@ -521,9 +556,10 @@
"""
name = "remove"
- allowed_children = { (dav_namespace, "prop"): (1, 1) }
+ allowed_children = {(dav_namespace, "prop"): (1, 1)}
+
@registerElement
@registerElementClass
class Set (WebDAVElement):
@@ -533,9 +569,10 @@
"""
name = "set"
- allowed_children = { (dav_namespace, "prop"): (1, 1) }
+ allowed_children = {(dav_namespace, "prop"): (1, 1)}
+
@registerElement
@registerElementClass
class PropertyFind (WebDAVElement):
@@ -546,11 +583,12 @@
name = "propfind"
allowed_children = {
- (dav_namespace, "allprop" ): (0, 1),
+ (dav_namespace, "allprop"): (0, 1),
(dav_namespace, "propname"): (0, 1),
- (dav_namespace, "prop" ): (0, 1),
+ (dav_namespace, "prop"): (0, 1),
}
+
def validate(self):
super(PropertyFind, self).validate()
@@ -561,6 +599,7 @@
)
+
@registerElement
@registerElementClass
class AllProperties (WebDAVEmptyElement):
@@ -571,6 +610,7 @@
name = "allprop"
+
@registerElement
@registerElementClass
class PropertyName (WebDAVEmptyElement):
@@ -581,6 +621,7 @@
name = "propname"
+
##
# Section 13
##
@@ -597,6 +638,7 @@
protected = True
+
@registerElement
@registerElementClass
class DisplayName (WebDAVTextElement):
@@ -607,6 +649,7 @@
name = "displayname"
+
@registerElement
@registerElementClass
class GETContentLanguage (WebDAVTextElement):
@@ -617,6 +660,7 @@
name = "getcontentlanguage"
+
@registerElement
@registerElementClass
class GETContentLength (WebDAVTextElement):
@@ -628,6 +672,7 @@
protected = True
+
@registerElement
@registerElementClass
class GETContentType (WebDAVTextElement):
@@ -641,6 +686,7 @@
return MimeType.fromString(str(self))
+
@registerElement
@registerElementClass
class GETETag (WebDAVTextElement):
@@ -652,6 +698,7 @@
protected = True
+
@registerElement
@registerElementClass
class GETLastModified (DateTimeHeaderElement):
@@ -663,6 +710,7 @@
protected = True
+
@registerElement
@registerElementClass
class LockDiscovery (WebDAVElement):
@@ -672,9 +720,10 @@
name = "lockdiscovery"
protected = True
- allowed_children = { (dav_namespace, "activelock"): (0, None) }
+ allowed_children = {(dav_namespace, "activelock"): (0, None)}
+
@registerElement
@registerElementClass
class ResourceType (WebDAVElement):
@@ -684,10 +733,10 @@
name = "resourcetype"
protected = True
- allowed_children = { WebDAVElement: (0, None) }
+ allowed_children = {WebDAVElement: (0, None)}
ResourceType.collection = ResourceType(Collection())
-ResourceType.empty = ResourceType()
+ResourceType.empty = ResourceType()
@registerElement
@@ -700,9 +749,10 @@
"""
name = "source"
- allowed_children = { (dav_namespace, "link"): (0, None) }
+ allowed_children = {(dav_namespace, "link"): (0, None)}
+
@registerElement
@registerElementClass
class SupportedLock (WebDAVElement):
@@ -713,9 +763,10 @@
name = "supportedlock"
protected = True
- allowed_children = { (dav_namespace, "lockentry"): (0, None) }
+ allowed_children = {(dav_namespace, "lockentry"): (0, None)}
+
# FIXME: Add preconditions codes defined in RFC4918
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc3253.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc3253.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc3253.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -7,10 +7,10 @@
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -49,9 +49,10 @@
# FIXME: Move when we update to RFC 2518bis
name = "error"
- allowed_children = { WebDAVElement: (0, None) }
+ allowed_children = {WebDAVElement: (0, None)}
+
##
# Section 3
##
@@ -68,6 +69,7 @@
hidden = True
+
@registerElement
@registerElementClass
class CreatorDisplayName (WebDAVTextElement):
@@ -79,6 +81,7 @@
hidden = True
+
@registerElement
@registerElementClass
class SupportedMethod (WebDAVElement):
@@ -92,10 +95,11 @@
name = "supported-method"
hidden = True
- allowed_children = { WebDAVElement: (0, None) }
- allowed_attributes = { "name": True }
+ allowed_children = {WebDAVElement: (0, None)}
+ allowed_attributes = {"name": True}
+
@registerElement
@registerElementClass
class SupportedMethodSet (WebDAVElement):
@@ -107,9 +111,10 @@
protected = True
hidden = True
- allowed_children = { (dav_namespace, "supported-method"): (0, None) }
+ allowed_children = {(dav_namespace, "supported-method"): (0, None)}
+
@registerElement
@registerElementClass
class SupportedLiveProperty (WebDAVElement):
@@ -124,9 +129,10 @@
name = "supported-live-property"
# FIXME: Where is the name element defined?
- allowed_children = { (dav_namespace, "name"): (1, 1) }
+ allowed_children = {(dav_namespace, "name"): (1, 1)}
+
@registerElement
@registerElementClass
class SupportedLivePropertySet (WebDAVElement):
@@ -138,9 +144,10 @@
hidden = True
protected = True
- allowed_children = { (dav_namespace, "supported-live-property"): (0, None) }
+ allowed_children = {(dav_namespace, "supported-live-property"): (0, None)}
+
@registerElement
@registerElementClass
class Report (WebDAVElement):
@@ -150,9 +157,10 @@
# FIXME: Section 3.1.5 is pretty low on information. Where else do we look?
name = "report"
- allowed_children = { WebDAVElement: (0, None) }
+ allowed_children = {WebDAVElement: (0, None)}
+
@registerElement
@registerElementClass
class SupportedReport (WebDAVElement):
@@ -185,9 +193,10 @@
# Absent any better guidance, we'll allow no children for this element for
# the time being.
#
- allowed_children = { (dav_namespace, "report"): (0, 1) }
+ allowed_children = {(dav_namespace, "report"): (0, 1)}
+
@registerElement
@registerElementClass
class SupportedReportSet (WebDAVElement):
@@ -199,9 +208,10 @@
hidden = True
protected = True
- allowed_children = { (dav_namespace, "supported-report"): (0, None) }
+ allowed_children = {(dav_namespace, "supported-report"): (0, None)}
+
@registerElement
@registerElementClass
class ExpandProperty (WebDAVElement):
@@ -212,9 +222,10 @@
"""
name = "expand-property"
- allowed_children = { (dav_namespace, "property"): (0, None) }
+ allowed_children = {(dav_namespace, "property"): (0, None)}
+
@registerElement
@registerElementClass
class Property (WebDAVElement):
@@ -227,7 +238,7 @@
"""
name = "property"
- allowed_children = { (dav_namespace, "property"): (0, None) }
+ allowed_children = {(dav_namespace, "property"): (0, None)}
allowed_attributes = {
"name" : True,
"namespace" : False,
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc3744.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc3744.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc3744.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -7,10 +7,10 @@
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -55,6 +55,7 @@
# rfc2518.py.
+
@registerElement
@registerElementClass
class WriteProperties (WebDAVEmptyElement):
@@ -65,6 +66,7 @@
name = "write-properties"
+
@registerElement
@registerElementClass
class WriteContent (WebDAVEmptyElement):
@@ -75,6 +77,7 @@
name = "write-content"
+
@registerElement
@registerElementClass
class Unlock (WebDAVEmptyElement):
@@ -85,6 +88,7 @@
name = "unlock"
+
@registerElement
@registerElementClass
class ReadACL (WebDAVEmptyElement):
@@ -95,6 +99,7 @@
name = "read-acl"
+
@registerElement
@registerElementClass
class ReadCurrentUserPrivilegeSet (WebDAVEmptyElement):
@@ -106,6 +111,7 @@
name = "read-current-user-privilege-set"
+
@registerElement
@registerElementClass
class WriteACL (WebDAVEmptyElement):
@@ -116,6 +122,7 @@
name = "write-acl"
+
@registerElement
@registerElementClass
class Bind (WebDAVEmptyElement):
@@ -126,6 +133,7 @@
name = "bind"
+
@registerElement
@registerElementClass
class Unbind (WebDAVEmptyElement):
@@ -136,6 +144,7 @@
name = "unbind"
+
@registerElement
@registerElementClass
class All (WebDAVEmptyElement):
@@ -147,6 +156,7 @@
name = "all"
+
##
# Section 4 (Principal Properties)
##
@@ -161,12 +171,12 @@
name = "principal"
allowed_children = {
- (dav_namespace, "href" ): (0, 1),
- (dav_namespace, "all" ): (0, 1),
- (dav_namespace, "authenticated" ): (0, 1),
+ (dav_namespace, "href"): (0, 1),
+ (dav_namespace, "all"): (0, 1),
+ (dav_namespace, "authenticated"): (0, 1),
(dav_namespace, "unauthenticated"): (0, 1),
- (dav_namespace, "property" ): (0, 1),
- (dav_namespace, "self" ): (0, 1),
+ (dav_namespace, "property"): (0, 1),
+ (dav_namespace, "self"): (0, 1),
}
def validate(self):
@@ -181,6 +191,7 @@
)
+
@registerElement
@registerElementClass
class AlternateURISet (WebDAVElement):
@@ -192,9 +203,10 @@
hidden = True
protected = True
- allowed_children = { (dav_namespace, "href"): (0, None) }
+ allowed_children = {(dav_namespace, "href"): (0, None)}
+
@registerElement
@registerElementClass
class PrincipalURL (WebDAVElement):
@@ -206,9 +218,10 @@
hidden = True
protected = True
- allowed_children = { (dav_namespace, "href"): (0, 1) }
+ allowed_children = {(dav_namespace, "href"): (0, 1)}
+
@registerElement
@registerElementClass
class GroupMemberSet (WebDAVElement):
@@ -220,9 +233,10 @@
name = "group-member-set"
hidden = True
- allowed_children = { (dav_namespace, "href"): (0, None) }
+ allowed_children = {(dav_namespace, "href"): (0, None)}
+
@registerElement
@registerElementClass
class GroupMembership (WebDAVElement):
@@ -234,7 +248,7 @@
hidden = True
protected = True
- allowed_children = { (dav_namespace, "href"): (0, None) }
+ allowed_children = {(dav_namespace, "href"): (0, None)}
##
@@ -245,6 +259,7 @@
# rfc2518.py.
+
@registerElement
@registerElementClass
class Group (WebDAVElement):
@@ -256,9 +271,10 @@
hidden = True
protected = True # may be protected, per RFC 3744, section 5.2
- allowed_children = { (dav_namespace, "href"): (0, 1) }
+ allowed_children = {(dav_namespace, "href"): (0, 1)}
+
@registerElement
@registerElementClass
class SupportedPrivilegeSet (WebDAVElement):
@@ -270,9 +286,10 @@
hidden = True
protected = True
- allowed_children = { (dav_namespace, "supported-privilege"): (0, None) }
+ allowed_children = {(dav_namespace, "supported-privilege"): (0, None)}
+
@registerElement
@registerElementClass
class SupportedPrivilege (WebDAVElement):
@@ -282,13 +299,14 @@
name = "supported-privilege"
allowed_children = {
- (dav_namespace, "privilege" ): (1, 1),
- (dav_namespace, "abstract" ): (0, 1),
- (dav_namespace, "description" ): (1, 1),
+ (dav_namespace, "privilege"): (1, 1),
+ (dav_namespace, "abstract"): (0, 1),
+ (dav_namespace, "description"): (1, 1),
(dav_namespace, "supported-privilege"): (0, None),
}
+
@registerElement
@registerElementClass
class Privilege (WebDAVElement):
@@ -297,7 +315,7 @@
"""
name = "privilege"
- allowed_children = { WebDAVElement: (0, None) }
+ allowed_children = {WebDAVElement: (0, None)}
def isAggregateOf(self, subprivilege, supportedPrivileges):
"""
@@ -339,6 +357,7 @@
else:
return False
+
def expandAggregate(self, supportedPrivileges):
"""
Expand this privilege into the set of privileges aggregated under it
@@ -384,6 +403,7 @@
return aggregates
+
@registerElement
@registerElementClass
class Abstract (WebDAVElement):
@@ -393,6 +413,7 @@
name = "abstract"
+
@registerElement
@registerElementClass
class Description (WebDAVTextElement):
@@ -401,9 +422,10 @@
3744, sections 5.3 and 9.5)
"""
name = "description"
- allowed_attributes = { "xml:lang": True }
+ allowed_attributes = {"xml:lang": True}
+
@registerElement
@registerElementClass
class CurrentUserPrivilegeSet (WebDAVElement):
@@ -416,12 +438,13 @@
hidden = True
protected = True
- allowed_children = { (dav_namespace, "privilege"): (0, None) }
+ allowed_children = {(dav_namespace, "privilege"): (0, None)}
# For DAV:privilege element (RFC 3744, section 5.4) see Privilege class above.
+
@registerElement
@registerElementClass
class ACL (WebDAVElement):
@@ -434,9 +457,10 @@
hidden = True
protected = True
- allowed_children = { (dav_namespace, "ace"): (0, None) }
+ allowed_children = {(dav_namespace, "ace"): (0, None)}
+
@registerElement
@registerElementClass
class ACE (WebDAVElement):
@@ -448,9 +472,9 @@
allowed_children = {
(dav_namespace, "principal"): (0, 1),
- (dav_namespace, "invert" ): (0, 1),
- (dav_namespace, "grant" ): (0, 1),
- (dav_namespace, "deny" ): (0, 1),
+ (dav_namespace, "invert"): (0, 1),
+ (dav_namespace, "grant"): (0, 1),
+ (dav_namespace, "deny"): (0, 1),
(dav_namespace, "protected"): (0, 1),
(dav_namespace, "inherited"): (0, 1),
}
@@ -458,12 +482,12 @@
def __init__(self, *children, **attributes):
super(ACE, self).__init__(*children, **attributes)
- self.principal = None
- self.invert = None
- self.allow = None
+ self.principal = None
+ self.invert = None
+ self.allow = None
self.privileges = None
- self.inherited = None
- self.protected = False
+ self.inherited = None
+ self.protected = False
my_children = []
@@ -481,24 +505,24 @@
% (self.sname(), self.children)
)
if name == "invert":
- self.invert = True
+ self.invert = True
self.principal = child.children[0]
else:
- self.invert = False
+ self.invert = False
self.principal = child
-
+
elif name in ("grant", "deny"):
if self.allow is not None:
raise ValueError(
"Only one of DAV:grant or DAV:deny allowed in %s, got: %s"
% (self.sname(), self.children)
)
- self.allow = (name == "grant")
+ self.allow = (name == "grant")
self.privileges = child.children
-
+
elif name == "inherited":
self.inherited = str(child.children[0])
-
+
elif name == "protected":
self.protected = True
@@ -528,6 +552,7 @@
# For DAV:all element (RFC 3744, section 5.5.1) see All class above.
+
@registerElement
@registerElementClass
class Authenticated (WebDAVEmptyElement):
@@ -537,6 +562,7 @@
name = "authenticated"
+
@registerElement
@registerElementClass
class Unauthenticated (WebDAVEmptyElement):
@@ -550,6 +576,7 @@
# class above.
+
@registerElement
@registerElementClass
class Self (WebDAVEmptyElement):
@@ -560,6 +587,7 @@
name = "self"
+
@registerElement
@registerElementClass
class Invert (WebDAVElement):
@@ -569,9 +597,10 @@
"""
name = "invert"
- allowed_children = { (dav_namespace, "principal"): (1, 1) }
+ allowed_children = {(dav_namespace, "principal"): (1, 1)}
+
@registerElement
@registerElementClass
class Grant (WebDAVElement):
@@ -580,9 +609,10 @@
"""
name = "grant"
- allowed_children = { (dav_namespace, "privilege"): (1, None) }
+ allowed_children = {(dav_namespace, "privilege"): (1, None)}
+
@registerElement
@registerElementClass
class Deny (WebDAVElement):
@@ -591,13 +621,14 @@
"""
name = "deny"
- allowed_children = { (dav_namespace, "privilege"): (1, None) }
+ allowed_children = {(dav_namespace, "privilege"): (1, None)}
# For DAV:privilege element (RFC 3744, section 5.5.2) see Privilege
# class above.
+
@registerElement
@registerElementClass
class Protected (WebDAVEmptyElement):
@@ -607,6 +638,7 @@
name = "protected"
+
@registerElement
@registerElementClass
class Inherited (WebDAVElement):
@@ -616,9 +648,10 @@
"""
name = "inherited"
- allowed_children = { (dav_namespace, "href"): (1, 1) }
+ allowed_children = {(dav_namespace, "href"): (1, 1)}
+
@registerElement
@registerElementClass
class ACLRestrictions (WebDAVElement):
@@ -631,13 +664,14 @@
protected = True
allowed_children = {
- (dav_namespace, "grant-only" ): (0, 1),
- (dav_namespace, "no-invert" ): (0, 1),
- (dav_namespace, "deny-before-grant" ): (0, 1),
+ (dav_namespace, "grant-only"): (0, 1),
+ (dav_namespace, "no-invert"): (0, 1),
+ (dav_namespace, "deny-before-grant"): (0, 1),
(dav_namespace, "required-principal"): (0, 1),
}
+
@registerElement
@registerElementClass
class GrantOnly (WebDAVEmptyElement):
@@ -648,6 +682,7 @@
name = "grant-only"
+
@registerElement
@registerElementClass
class NoInvert (WebDAVEmptyElement):
@@ -658,6 +693,7 @@
name = "no-invert"
+
@registerElement
@registerElementClass
class DenyBeforeGrant (WebDAVEmptyElement):
@@ -668,6 +704,7 @@
name = "deny-before-grant"
+
@registerElement
@registerElementClass
class RequiredPrincipal (WebDAVElement):
@@ -678,12 +715,12 @@
name = "required-principal"
allowed_children = {
- (dav_namespace, "all" ): (0, 1),
- (dav_namespace, "authenticated" ): (0, 1),
+ (dav_namespace, "all"): (0, 1),
+ (dav_namespace, "authenticated"): (0, 1),
(dav_namespace, "unauthenticated"): (0, 1),
- (dav_namespace, "self" ): (0, 1),
- (dav_namespace, "href" ): (0, None),
- (dav_namespace, "property" ): (0, None),
+ (dav_namespace, "self"): (0, 1),
+ (dav_namespace, "href"): (0, None),
+ (dav_namespace, "property"): (0, None),
}
def validate(self):
@@ -702,6 +739,7 @@
)
+
@registerElement
@registerElementClass
class InheritedACLSet (WebDAVElement):
@@ -713,9 +751,10 @@
hidden = True
protected = True
- allowed_children = { (dav_namespace, "href"): (0, None) }
+ allowed_children = {(dav_namespace, "href"): (0, None)}
+
@registerElement
@registerElementClass
class PrincipalCollectionSet (WebDAVElement):
@@ -728,9 +767,10 @@
hidden = True
protected = True
- allowed_children = { (dav_namespace, "href"): (0, None) }
+ allowed_children = {(dav_namespace, "href"): (0, None)}
+
##
# Section 7 (Access Control and existing methods)
##
@@ -743,9 +783,10 @@
"""
name = "need-privileges"
- allowed_children = { (dav_namespace, "resource"): (0, None) }
+ allowed_children = {(dav_namespace, "resource"): (0, None)}
+
@registerElement
@registerElementClass
class Resource (WebDAVElement):
@@ -756,11 +797,12 @@
name = "resource"
allowed_children = {
- (dav_namespace, "href" ): (1, 1),
+ (dav_namespace, "href"): (1, 1),
(dav_namespace, "privilege"): (1, 1),
}
+
##
# Section 9 (Access Control Reports)
##
@@ -776,13 +818,13 @@
"""
name = "acl-principal-prop-set"
- allowed_children = { WebDAVElement: (0, None) }
+ allowed_children = {WebDAVElement: (0, None)}
def validate(self):
super(ACLPrincipalPropSet, self).validate()
prop = False
-
+
for child in self.children:
if child.qname() == (dav_namespace, "prop"):
if prop:
@@ -793,6 +835,7 @@
prop = True
+
@registerElement
@registerElementClass
class PrincipalMatch (WebDAVElement):
@@ -805,8 +848,8 @@
allowed_children = {
(dav_namespace, "principal-property"): (0, 1),
- (dav_namespace, "self" ): (0, 1),
- (dav_namespace, "prop" ): (0, 1),
+ (dav_namespace, "self"): (0, 1),
+ (dav_namespace, "prop"): (0, 1),
}
def validate(self):
@@ -836,6 +879,7 @@
)
+
@registerElement
@registerElementClass
class PrincipalProperty (WebDAVElement):
@@ -844,12 +888,13 @@
"""
name = "principal-property"
- allowed_children = { WebDAVElement: (0, None) }
+ allowed_children = {WebDAVElement: (0, None)}
# For DAV:self element (RFC 3744, section 9.3) see Self class above.
+
@registerElement
@registerElementClass
class PrincipalPropertySearch (WebDAVElement):
@@ -861,13 +906,14 @@
name = "principal-property-search"
allowed_children = {
- (dav_namespace, "property-search" ): (0, None), # This is required but this element must be empty in supported-report-set
- (dav_namespace, "prop" ): (0, 1),
+ (dav_namespace, "property-search"): (0, None), # This is required but this element must be empty in supported-report-set
+ (dav_namespace, "prop"): (0, 1),
(dav_namespace, "apply-to-principal-collection-set"): (0, 1),
}
- allowed_attributes = { "test": False }
+ allowed_attributes = {"test": False}
+
@registerElement
@registerElementClass
class PropertySearch (WebDAVElement):
@@ -878,11 +924,12 @@
name = "property-search"
allowed_children = {
- (dav_namespace, "prop" ): (1, 1),
+ (dav_namespace, "prop"): (1, 1),
(dav_namespace, "match"): (1, 1),
}
+
@registerElement
@registerElementClass
class Match (WebDAVTextElement):
@@ -892,6 +939,7 @@
name = "match"
+
@registerElement
@registerElementClass
class PrincipalSearchPropertySet (WebDAVElement):
@@ -901,9 +949,10 @@
"""
name = "principal-search-property-set"
- allowed_children = { (dav_namespace, "principal-search-property"): (0, None) }
+ allowed_children = {(dav_namespace, "principal-search-property"): (0, None)}
+
@registerElement
@registerElementClass
class PrincipalSearchProperty (WebDAVElement):
@@ -914,11 +963,12 @@
name = "principal-search-property"
allowed_children = {
- (dav_namespace, "prop" ): (1, 1),
+ (dav_namespace, "prop"): (1, 1),
(dav_namespace, "description"): (1, 1),
}
+
@registerElement
@registerElementClass
class NumberOfMatchesWithinLimits (WebDAVEmptyElement):
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc4331.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc4331.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc4331.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -7,10 +7,10 @@
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -51,6 +51,7 @@
protected = True
+
@registerElement
@registerElementClass
class QuotaUsedBytes (WebDAVTextElement):
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc5397.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc5397.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc5397.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -7,10 +7,10 @@
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc5842.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc5842.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc5842.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -7,10 +7,10 @@
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -45,9 +45,10 @@
hidden = True
protected = True
- allowed_children = { (dav_namespace, "href"): (0, 1) }
+ allowed_children = {(dav_namespace, "href"): (0, 1)}
+
@registerElement
@registerElementClass
class ParentSet (WebDAVElement):
@@ -58,9 +59,10 @@
hidden = True
protected = True
- allowed_children = { (dav_namespace, "parent"): (0, 1) }
+ allowed_children = {(dav_namespace, "parent"): (0, 1)}
+
@registerElement
@registerElementClass
class Parent (WebDAVElement):
@@ -73,6 +75,7 @@
}
+
@registerElement
@registerElementClass
class Segment (WebDAVTextElement):
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc5995.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc5995.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/rfc5995.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -7,10 +7,10 @@
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -48,9 +48,10 @@
hidden = True
protected = True
- allowed_children = { (dav_namespace, "href"): (0, 1) }
+ allowed_children = {(dav_namespace, "href"): (0, 1)}
+
@registerElement
@registerElementClass
class AllowClientDefinedURI (WebDAVElement):
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/test/test_base.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/test/test_base.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/test/test_base.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -37,7 +37,7 @@
"""
def test_decodeXMLName(self):
# Empty name
- self.assertRaises(ValueError, decodeXMLName, "")
+ self.assertRaises(ValueError, decodeXMLName, "")
self.assertRaises(ValueError, decodeXMLName, "{}")
self.assertRaises(ValueError, decodeXMLName, "{x}")
@@ -47,18 +47,19 @@
self.assertRaises(ValueError, decodeXMLName, "{x")
self.assertRaises(ValueError, decodeXMLName, "}")
self.assertRaises(ValueError, decodeXMLName, "x}")
- self.assertRaises(ValueError, decodeXMLName, "}x")
+ self.assertRaises(ValueError, decodeXMLName, "}x")
self.assertRaises(ValueError, decodeXMLName, "{{}")
self.assertRaises(ValueError, decodeXMLName, "{{}}")
self.assertRaises(ValueError, decodeXMLName, "x{}")
# Empty namespace is OK
- self.assertEquals(decodeXMLName( "x"), (None, "x"))
+ self.assertEquals(decodeXMLName("x"), (None, "x"))
self.assertEquals(decodeXMLName("{}x"), (None, "x"))
# Normal case
self.assertEquals(decodeXMLName("{namespace}name"), ("namespace", "name"))
+
def test_encodeXMLName(self):
# No namespace
self.assertEquals(encodeXMLName(None, "name"), "name")
@@ -68,6 +69,7 @@
self.assertEquals(encodeXMLName("namespace", "name"), "{namespace}name")
+
class WebDAVElementTestsMixin:
"""
Mixin for L{TestCase}s which test a L{WebDAVElement} subclass.
@@ -92,6 +94,7 @@
WebDAVDocument.fromString(document.toxml()))
+
class WebDAVUnknownElementTests(WebDAVElementTestsMixin, TestCase):
"""
Tests for L{WebDAVUnknownElement}.
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/test/test_xml.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/test/test_xml.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/test/test_xml.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -54,6 +54,7 @@
)
+
class CurrentUserPrincipalTests(WebDAVElementTestsMixin, TestCase):
"""
Tests for L{CurrentUserPrincipal}.
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/test/test_xml_rfc3744.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/test/test_xml_rfc3744.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/test/test_xml_rfc3744.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -7,10 +7,10 @@
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/xmlext.py
===================================================================
--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/xmlext.py 2013-10-03 22:51:14 UTC (rev 11787)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/xml/xmlext.py 2013-10-04 16:40:38 UTC (rev 11788)
@@ -3,6 +3,7 @@
# File Name: __init__.py
#
#
+from types import UnicodeType
"""
WWW: http://4suite.com/4DOM e-mail: support at 4suite.com
@@ -13,14 +14,20 @@
"""Some Helper functions: 4DOM/PyXML-specific Extensions to the DOM,
and DOM-related utilities."""
-__all__ = [ "Print", "PrettyPrint" ]
+__all__ = ["Print", "PrettyPrint"]
-import sys,string
+import string
+import sys
import re
from xml.dom import Node
-from xml.dom import XML_NAMESPACE, XMLNS_NAMESPACE, DOMException
+from xml.dom import XML_NAMESPACE, XMLNS_NAMESPACE
+HTML_4_TRANSITIONAL_INLINE = ['TT', 'I', 'B', 'U', 'S', 'STRIKE', 'BIG', 'SMALL', 'EM', 'STRONG', 'DFN', 'CODE', 'SAMP', 'KBD', 'VAR', 'CITE', 'ABBR', 'ACRONYM', 'A', 'IMG', 'APPLET', 'OBJECT', 'FONT', 'BASEFONT', 'SCRIPT', 'MAP', 'Q', 'SUB', 'SUP', 'SPAN', 'BDO', 'IFRAME', 'INPUT', 'SELECT', 'TEXTAREA', 'LABEL', 'BUTTON']
+HTML_FORBIDDEN_END = ['AREA', 'BASE', 'BASEFONT', 'BR', 'COL', 'FRAME', 'HR', 'IMG', 'INPUT', 'ISINDEX', 'LINK', 'META', 'PARAM']
+XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml"
+
+
def Print(root, stream=sys.stdout, encoding='UTF-8'):
if not hasattr(root, "nodeType"):
return
@@ -29,6 +36,8 @@
PrintWalker(visitor, root).run()
return
+
+
def PrettyPrint(root, stream=sys.stdout, encoding='UTF-8', indent=' ',
preserveElements=None):
if not hasattr(root, "nodeType"):
@@ -45,6 +54,8 @@
stream.write('\n')
return
+
+
def GetAllNs(node):
#The xml namespace is implicit
nss = {'xml': XML_NAMESPACE}
@@ -68,6 +79,8 @@
nss = parent_nss
return nss
+
+
def SeekNss(node, nss=None):
'''traverses the tree to seek an approximate set of defined namespaces'''
nss = nss or {}
@@ -86,6 +99,8 @@
SeekNss(child, nss)
return nss
+
+
class PrintVisitor:
def __init__(self, stream, encoding, indent='', plainElements=None,
nsHints=None, isXhtml=0, force8bit=0):
@@ -105,6 +120,7 @@
self.force8bit = force8bit
return
+
def _write(self, text):
if self.force8bit:
obj = strobj_to_utf8str(text, self.encoding)
@@ -113,17 +129,18 @@
self.stream.write(obj)
return
+
def _tryIndent(self):
if not self._inText and self._indent:
- self._write('\n' + self._indent*self._depth)
+ self._write('\n' + self._indent * self._depth)
return
+
def visit(self, node):
if self._html is None:
# Set HTMLDocument flag here for speed
self._html = hasattr(node.ownerDocument, 'getElementsByName')
- nodeType = node.nodeType
if node.nodeType == Node.ELEMENT_NODE:
return self.visitElement(node)
@@ -163,16 +180,20 @@
# It has a node type, but we don't know how to handle it
raise Exception("Unknown node type: %s" % repr(node))
+
def visitNodeList(self, node, exclude=None):
for curr in node:
- curr is not exclude and self.visit(curr)
+ if curr is not exclude:
+ self.visit(curr)
return
+
def visitNamedNodeMap(self, node):
for item in node.values():
self.visit(item)
return
+
def visitAttr(self, node):
if node.namespaceURI == XMLNS_NAMESPACE:
# Skip namespace declarations
@@ -185,6 +206,7 @@
self.stream.write("=%s%s%s" % (delimiter, text, delimiter))
return
+
def visitProlog(self):
self._write("<?xml version='1.0' encoding='%s'?>" % (
self.encoding or 'utf-8'
@@ -192,16 +214,19 @@
self._inText = 0
return
+
def visitDocument(self, node):
not self._html and self.visitProlog()
node.doctype and self.visitDocumentType(node.doctype)
self.visitNodeList(node.childNodes, exclude=node.doctype)
return
+
def visitDocumentFragment(self, node):
self.visitNodeList(node.childNodes)
return
+
def visitElement(self, node):
self._namespaces.append(self._namespaces[-1].copy())
inline = node.tagName in self._plainElements
@@ -219,12 +244,12 @@
self._nsHints = {}
del nss['xml']
for prefix in nss.keys():
- if not self._namespaces[-1].has_key(prefix) or self._namespaces[-1][prefix] != nss[prefix]:
+ if prefix not in self._namespaces[-1] or self._namespaces[-1][prefix] != nss[prefix]:
nsuri, delimiter = TranslateCdataAttr(nss[prefix])
if prefix:
- xmlns = " xmlns:%s=%s%s%s" % (prefix, delimiter,nsuri,delimiter)
+ xmlns = " xmlns:%s=%s%s%s" % (prefix, delimiter, nsuri, delimiter)
else:
- xmlns = " xmlns=%s%s%s" % (delimiter,nsuri,delimiter)
+ xmlns = " xmlns=%s%s%s" % (delimiter, nsuri, delimiter)
namespaces = namespaces + xmlns
self._namespaces[-1][prefix] = nss[prefix]
@@ -249,6 +274,7 @@
self._inText = 0
return
+
def visitText(self, node):
text = node.data
if self._indent:
@@ -262,8 +288,10 @@
self._inText = 1
return
+
def visitDocumentType(self, doctype):
- if not doctype.systemId and not doctype.publicId: return
+ if not doctype.systemId and not doctype.publicId:
+ return
self._tryIndent()
self._write('<!DOCTYPE %s' % doctype.name)
if doctype.systemId and '"' in doctype.systemId:
@@ -294,6 +322,7 @@
self._inText = 0
return
+
def visitEntity(self, node):
"""Visited from a NamedNodeMap in DocumentType"""
self._tryIndent()
@@ -304,6 +333,7 @@
self._write('>')
return
+
def visitNotation(self, node):
"""Visited from a NamedNodeMap in DocumentType"""
self._tryIndent()
@@ -313,40 +343,48 @@
self._write('>')
return
+
def visitCDATASection(self, node):
self._tryIndent()
self._write('<![CDATA[%s]]>' % (node.data))
self._inText = 0
return
+
def visitComment(self, node):
self._tryIndent()
self._write('<!--%s-->' % (node.data))
self._inText = 0
return
+
def visitEntityReference(self, node):
self._write('&%s;' % node.nodeName)
self._inText = 1
return
+
def visitProcessingInstruction(self, node):
self._tryIndent()
self._write('<?%s %s?>' % (node.target, node.data))
self._inText = 0
return
+
+
class PrintWalker:
def __init__(self, visitor, startNode):
self.visitor = visitor
self.start_node = startNode
return
+
def step(self):
"""There is really no step to printing. It prints the whole thing"""
self.visitor.visit(self.start_node)
return
+
def run(self):
return self.step()
@@ -354,7 +392,7 @@
SURROGATE_BLOCK = '[\xF0-\xF7][\x80-\xBF][\x80-\xBF][\x80-\xBF]'
ILLEGAL_HIGH_CHARS = '\xEF\xBF[\xBE\xBF]'
#Note: Prolly fuzzy on this, but it looks as if characters from the surrogate block are allowed if in scalar form, which is encoded in UTF8 the same was as in surrogate block form
-XML_ILLEGAL_CHAR_PATTERN = re.compile('%s|%s'%(ILLEGAL_LOW_CHARS, ILLEGAL_HIGH_CHARS))
+XML_ILLEGAL_CHAR_PATTERN = re.compile('%s|%s' % (ILLEGAL_LOW_CHARS, ILLEGAL_HIGH_CHARS))
g_utf8TwoBytePattern = re.compile('([\xC0-\xC3])([\x80-\xBF])')
g_cdataCharPattern = re.compile('[&<]|]]>')
@@ -371,15 +409,20 @@
if type(text) is not unicode:
text = unicode(text, "utf-8")
return encoder(text)[0] # result,size
+
+
+
def strobj_to_utf8str(text, encoding):
if string.upper(encoding) not in ["UTF-8", "ISO-8859-1", "LATIN-1"]:
- raise ValueError("Invalid encoding: %s"%encoding)
+ raise ValueError("Invalid encoding: %s" % encoding)
encoder = codecs.lookup(encoding)[0] # encode,decode,reader,writer
if type(text) is not unicode:
text = unicode(text, "utf-8")
#FIXME
return str(encoder(text)[0])
+
+
def TranslateCdataAttr(characters):
'''Handles normalization and some intelligence about quoting'''
if not characters:
@@ -397,12 +440,14 @@
new_chars = re.sub('\n', ' ', new_chars)
return new_chars, delimiter
+
+
#Note: Unicode object only for now
def TranslateCdata(characters, encoding='UTF-8', prev_chars='', markupSafe=0,
charsetHandler=utf8_to_code):
"""
charsetHandler is a function that takes a string or unicode object as the
- first argument, representing the string to be procesed, and an encoding
+ first argument, representing the string to be processed, and an encoding
specifier as the second argument. It must return a string or unicode
object
"""
@@ -428,3 +473,312 @@
new_string)[0]
new_string = charsetHandler(new_string, encoding)
return new_string
+
+
+
+def TranslateHtmlCdata(characters, encoding='UTF-8', prev_chars=''):
+ #Translate numerical char entity references with HTML entity equivalents
+ new_string, _ignore_num_subst = re.subn(
+ g_cdataCharPattern,
+ lambda m, d=g_charToEntity: d[m.group()],
+ characters
+ )
+ if prev_chars[-2:] == ']]' and new_string[0] == '>':
+ new_string = '>' + new_string[1:]
+ new_string = UseHtmlCharEntities(new_string)
+ try:
+ new_string = utf8_to_code(new_string, encoding)
+ except:
+ #FIXME: This is a work-around, contributed by Mike Brown, that
+ #Deals with escaping output, until we have XML/HTML aware codecs
+ tmp_new_string = ""
+ for c in new_string:
+ try:
+ new_c = utf8_to_code(c, encoding)
+ except:
+ new_c = '&#%i;' % ord(c)
+ tmp_new_string = tmp_new_string + new_c
+ new_string = tmp_new_string
+ #new_string, num_subst = re.subn(g_xmlIllegalCharPattern, lambda m: '&#%i;'%ord(m.group()), new_string)
+ #Note: use decimal char entity rep because some browsers are broken
+ return new_string
+
+
+HTML_CHARACTER_ENTITIES = {
+ # Sect 24.2 -- ISO 8859-1
+ 160: 'nbsp',
+ 161: 'iexcl',
+ 162: 'cent',
+ 163: 'pound',
+ 164: 'curren',
+ 165: 'yen',
+ 166: 'brvbar',
+ 167: 'sect',
+ 168: 'uml',
+ 169: 'copy',
+ 170: 'ordf',
+ 171: 'laquo',
+ 172: 'not',
+ 173: 'shy',
+ 174: 'reg',
+ 175: 'macr',
+ 176: 'deg',
+ 177: 'plusmn',
+ 178: 'sup2',
+ 179: 'sup3',
+ 180: 'acute',
+ 181: 'micro',
+ 182: 'para',
+ 183: 'middot',
+ 184: 'cedil',
+ 185: 'sup1',
+ 186: 'ordm',
+ 187: 'raquo',
+ 188: 'frac14',
+ 189: 'frac12',
+ 190: 'frac34',
+ 191: 'iquest',
+ 192: 'Agrave',
+ 193: 'Aacute',
+ 194: 'Acirc',
+ 195: 'Atilde',
+ 196: 'Auml',
+ 197: 'Aring',
+ 198: 'AElig',
+ 199: 'Ccedil',
+ 200: 'Egrave',
+ 201: 'Eacute',
+ 202: 'Ecirc',
+ 203: 'Euml',
+ 204: 'Igrave',
+ 205: 'Iacute',
+ 206: 'Icirc',
+ 207: 'Iuml',
+ 208: 'ETH',
+ 209: 'Ntilde',
+ 210: 'Ograve',
+ 211: 'Oacute',
+ 212: 'Ocirc',
+ 213: 'Otilde',
+ 214: 'Ouml',
+ 215: 'times',
+ 216: 'Oslash',
+ 217: 'Ugrave',
+ 218: 'Uacute',
+ 219: 'Ucirc',
+ 220: 'Uuml',
+ 221: 'Yacute',
+ 222: 'THORN',
+ 223: 'szlig',
+ 224: 'agrave',
+ 225: 'aacute',
+ 226: 'acirc',
+ 227: 'atilde',
+ 228: 'auml',
+ 229: 'aring',
+ 230: 'aelig',
+ 231: 'ccedil',
+ 232: 'egrave',
+ 233: 'eacute',
+ 234: 'ecirc',
+ 235: 'euml',
+ 236: 'igrave',
+ 237: 'iacute',
+ 238: 'icirc',
+ 239: 'iuml',
+ 240: 'eth',
+ 241: 'ntilde',
+ 242: 'ograve',
+ 243: 'oacute',
+ 244: 'ocirc',
+ 245: 'otilde',
+ 246: 'ouml',
+ 247: 'divide',
+ 248: 'oslash',
+ 249: 'ugrave',
+ 250: 'uacute',
+ 251: 'ucirc',
+ 252: 'uuml',
+ 253: 'yacute',
+ 254: 'thorn',
+ 255: 'yuml',
+
+ # Sect 24.3 -- Symbols, Mathematical Symbols, and Greek Letters
+ # Latin Extended-B
+ 402: 'fnof',
+ # Greek
+ 913: 'Alpha',
+ 914: 'Beta',
+ 915: 'Gamma',
+ 916: 'Delta',
+ 917: 'Epsilon',
+ 918: 'Zeta',
+ 919: 'Eta',
+ 920: 'Theta',
+ 921: 'Iota',
+ 922: 'Kappa',
+ 923: 'Lambda',
+ 924: 'Mu',
+ 925: 'Nu',
+ 926: 'Xi',
+ 927: 'Omicron',
+ 928: 'Pi',
+ 929: 'Rho',
+ 931: 'Sigma',
+ 932: 'Tau',
+ 933: 'Upsilon',
+ 934: 'Phi',
+ 935: 'Chi',
+ 936: 'Psi',
+ 937: 'Omega',
+ 945: 'alpha',
+ 946: 'beta',
+ 947: 'gamma',
+ 948: 'delta',
+ 949: 'epsilon',
+ 950: 'zeta',
+ 951: 'eta',
+ 952: 'theta',
+ 953: 'iota',
+ 954: 'kappa',
+ 955: 'lambda',
+ 956: 'mu',
+ 957: 'nu',
+ 958: 'xi',
+ 959: 'omicron',
+ 960: 'pi',
+ 961: 'rho',
+ 962: 'sigmaf',
+ 963: 'sigma',
+ 964: 'tau',
+ 965: 'upsilon',
+ 966: 'phi',
+ 967: 'chi',
+ 968: 'psi',
+ 969: 'omega',
+ 977: 'thetasym',
+ 978: 'upsih',
+ 982: 'piv',
+ # General Punctuation
+ 8226: 'bull', # bullet
+ 8230: 'hellip', # horizontal ellipsis
+ 8242: 'prime', # prime (minutes/feet)
+ 8243: 'Prime', # double prime (seconds/inches)
+ 8254: 'oline', # overline (spacing overscore)
+ 8250: 'frasl', # fractional slash
+ # Letterlike Symbols
+ 8472: 'weierp', # script capital P (power set/Weierstrass p)
+ 8465: 'image', # blackletter capital I (imaginary part)
+ 8476: 'real', # blackletter capital R (real part)
+ 8482: 'trade', # trademark
+ 8501: 'alefsym', # alef symbol (first transfinite cardinal)
+ # Arrows
+ 8592: 'larr', # leftwards arrow
+ 8593: 'uarr', # upwards arrow
+ 8594: 'rarr', # rightwards arrow
+ 8595: 'darr', # downwards arrow
+ 8596: 'harr', # left right arrow
+ 8629: 'crarr', # downwards arrow with corner leftwards (carriage return)
+ 8656: 'lArr', # leftwards double arrow
+ 8657: 'uArr', # upwards double arrow
+ 8658: 'rArr', # rightwards double arrow
+ 8659: 'dArr', # downwards double arrow
+ 8660: 'hArr', # left right double arrow
+ # Mathematical Operators
+ 8704: 'forall', # for all
+ 8706: 'part', # partial differential
+ 8707: 'exist', # there exists
+ 8709: 'empty', # empty set, null set, diameter
+ 8711: 'nabla', # nabla, backward difference
+ 8712: 'isin', # element of
+ 8713: 'notin', # not an element of
+ 8715: 'ni', # contains as member
+ 8719: 'prod', # n-ary product, product sign
+ 8721: 'sum', # n-ary sumation
+ 8722: 'minus', # minus sign
+ 8727: 'lowast', # asterisk operator
+ 8730: 'radic', # square root, radical sign
+ 8733: 'prop', # proportional to
+ 8734: 'infin', # infinity
+ 8736: 'ang', # angle
+ 8743: 'and', # logical and, wedge
+ 8744: 'or', # logical or, vee
+ 8745: 'cap', # intersection, cap
+ 8746: 'cup', # union, cup
+ 8747: 'int', # integral
+ 8756: 'there4', # therefore
+ 8764: 'sim', # tilde operator, varies with, similar to
+ 8773: 'cong', # approximately equal to
+ 8776: 'asymp', # almost equal to, asymptotic to
+ 8800: 'ne', # not equal to
+ 8801: 'equiv', # identical to
+ 8804: 'le', # less-than or equal to
+ 8805: 'ge', # greater-than or equal to
+ 8834: 'sub', # subset of
+ 8835: 'sup', # superset of
+ 8836: 'nsub', # not subset of
+ 8838: 'sube', # subset of or equal to
+ 8839: 'supe', # superset of or equal to
+ 8853: 'oplus', # circled plus, direct sum
+ 8855: 'otimes', # circled times, vector product
+ 8869: 'perp', # up tack, orthogonal to, perpendicular
+ 8901: 'sdot', # dot operator
+ 8968: 'lceil', # left ceiling, apl upstile
+ 8969: 'rceil', # right ceiling
+ 8970: 'lfloor', # left floor, apl downstile
+ 8971: 'rfloor', # right floor
+ 9001: 'lang', # left-pointing angle bracket, bra
+ 9002: 'rang', # right-pointing angle bracket, ket
+ 9674: 'loz', # lozenge
+ # Miscellaneous Symbols
+ 9824: 'spades',
+ 9827: 'clubs',
+ 9829: 'hearts',
+ 9830: 'diams',
+
+ # Sect 24.4 -- Markup Significant and Internationalization
+ # Latin Extended-A
+ 338: 'OElig', # capital ligature OE
+ 339: 'oelig', # small ligature oe
+ 352: 'Scaron', # capital S with caron
+ 353: 'scaron', # small s with caron
+ 376: 'Yuml', # capital Y with diaeresis
+ # Spacing Modifier Letters
+ 710: 'circ', # circumflexx accent
+ 732: 'tidle', # small tilde
+ # General Punctuation
+ 8194: 'ensp', # en space
+ 8195: 'emsp', # em space
+ 8201: 'thinsp', # thin space
+ 8204: 'zwnj', # zero-width non-joiner
+ 8205: 'zwj', # zero-width joiner
+ 8206: 'lrm', # left-to-right mark
+ 8207: 'rlm', # right-to-left mark
+ 8211: 'ndash', # en dash
+ 8212: 'mdash', # em dash
+ 8216: 'lsquo', # left single quotation mark
+ 8217: 'rsquo', # right single quotation mark
+ 8218: 'sbquo', # single low-9 quotation mark
+ 8220: 'ldquo', # left double quotation mark
+ 8221: 'rdquo', # right double quotation mark
+ 8222: 'bdquo', # double low-9 quotation mark
+ 8224: 'dagger', # dagger
+ 8225: 'Dagger', # double dagger
+ 8240: 'permil', # per mille sign
+ 8249: 'lsaquo', # single left-pointing angle quotation mark
+ 8250: 'rsaquo', # single right-pointing angle quotation mark
+ 8364: 'euro', # euro sign
+}
+
+g_htmlUniCharEntityPattern = re.compile('[\xa0-\xff]')
+
+def ConvertChar(m):
+ return '&' + HTML_CHARACTER_ENTITIES[ord(m.group())] + ';'
+
+
+
+def UseHtmlCharEntities(text):
+ if type(text) is not UnicodeType:
+ text = unicode(text, "utf-8")
+ new_text, _ignore_num_subst = re.subn(g_htmlUniCharEntityPattern, ConvertChar, text)
+ return new_text
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20131004/947ce92e/attachment-0001.html>
More information about the calendarserver-changes
mailing list