import vobject
import string
import re
+import logging
from . import config
def __init__(self, path):
"""Initialize the collection with ``cal`` and ``user`` parameters."""
+ self.log = logging.getLogger(__name__)
folder = os.path.expanduser(config.get("storage", "folder"))
self.encoding = "utf-8"
def write_file(self, item):
fd, path = tempfile.mkstemp(suffix=".ics", prefix="cal", dir=self.path)
+ self.log.debug('Trying to write to %s', path)
file = os.fdopen(fd, 'w')
file.write(item.text.encode('utf-8'))
file.close()
+ self.log.debug('Wrote %s to %s', file, path)
return path
def create_file(self, item):
except OSError, ex:
print "Error writing file: %s" % ex
except Exception, ex:
+ print "Caught Exception:\n%s" % (ex,)
print "Failed to create %s: %s" % (path, ex)
def destroy_file(self, item):
try:
new_item = Item(text, name, None)
- except Exception:
- print "Cannot create new item"
+ except Exception, e:
+ print "Cannot create new item: %s" % e
return False
if new_item.name not in (item.name for item in self.my_items):
print "New item %s" % new_item.name
import dateutil.tz
import datetime
import email.utils
+import logging
import urllib
from . import client, config, webdav
+__package__ = 'calypso.xmlutils'
NAMESPACES = {
"C": "urn:ietf:params:xml:ns:caldav",
"D": "DAV:",
"CS": "http://calendarserver.org/ns/"}
+log = logging.getLogger(__name__)
def _tag(short_name, local):
"""Get XML Clark notation {uri(``short_name``)}``local``."""
def name_from_path(path):
"""Return Calypso item name from ``path``."""
path_parts = path.strip("/").split("/")
- return urllib.unquote(path_parts[-1]) if len(path_parts) > 2 else None
+ name = urllib.unquote(path_parts[-1]) if len(path_parts) > 2 else None
+ log.debug('Path %s results in name: %s', path, name)
+ return name
def delete(path, collection):
"""Read and answer DELETE requests.
collection.replace(name, webdav_request)
else:
# PUT is adding a new item
+ log.debug('Putting a new item, because name %s is not known', name)
collection.append(name, webdav_request)