Commit e1a161ed authored by Guillaume Ayoub's avatar Guillaume Ayoub

Rename calendar into ical to avoid name collisions.

parent 9a07ec71
......@@ -45,7 +45,7 @@ except ImportError:
import BaseHTTPServer as server
# pylint: enable-msg=F0401
from radicale import acl, calendar, config, xmlutils
from radicale import acl, config, ical, xmlutils
def _check(request, function):
......@@ -105,12 +105,12 @@ class CalendarHTTPHandler(server.BaseHTTPRequestHandler):
def _calendar(self):
"""The ``calendar.Calendar`` object corresponding to the given path."""
"""The ``ical.Calendar`` object corresponding to the given path."""
# ``normpath`` should clean malformed and malicious request paths
attributes = os.path.normpath(self.path.strip("/")).split("/")
if len(attributes) >= 2:
path = "%s/%s" % (attributes[0], attributes[1])
return calendar.Calendar(path)
return ical.Calendar(path)
def _decode(self, text):
"""Try to decode text according to various parameters."""
......@@ -42,6 +42,15 @@ def open(path, mode="r"):
# pylint: enable-msg=W0622
def serialize(headers=(), timezones=(), events=(), todos=()):
for part in (headers, timezones, todos, events):
if part:
items.append("\n".join(item.text for item in part))
return "\n".join(items)
class Header(object):
"""Internal header class."""
def __init__(self, text):
......@@ -179,14 +188,8 @@ class Calendar(object):
# Create folder if absent
if not os.path.exists(os.path.dirname(self.path)):
text = "\n".join((
"\n".join([header.text for header in headers]),
"\n".join([timezone.text for timezone in timezones]),
"\n".join([todo.text for todo in todos]),
"\n".join([event.text for event in events]),
text = serialize(headers, timezones, events, todos)
return open(self.path, "w").write(text)
......@@ -175,10 +175,7 @@ def report(xml_request, calendar, url):
# is that really what is needed?
# Read rfc4791-9.[6|10] for info
for hreference in hreferences:
headers = ical.headers(calendar.text)
timezones = ical.timezones(calendar.text)
objects = + ical.todos(calendar.text)
objects = + calendar.todos
if not objects:
# TODO: Read rfc4791-9.[6|10] to find a right answer
......@@ -216,8 +213,12 @@ def report(xml_request, calendar, url):
if _tag("C", "calendar-data") in props:
element = ET.Element(_tag("C", "calendar-data"))
# TODO: Maybe assume that events and todos are not the same
element.text = ical.write_calendar(headers, timezones, [obj])
if isinstance(obj, ical.Event):
element.text = ical.serialize(
calendar.headers, calendar.timezones, events=[obj])
elif isinstance(obj, ical.Todo):
element.text = ical.serialize(
calendar.headers, calendar.timezones, todos=[obj])
status = ET.Element(_tag("D", "status"))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment