[CalendarServer-changes] [7463] CalendarServer/branches/users/glyph/new-export
source_changes at macosforge.org
source_changes at macosforge.org
Mon May 16 07:43:45 PDT 2011
Revision: 7463
http://trac.macosforge.org/projects/calendarserver/changeset/7463
Author: glyph at apple.com
Date: 2011-05-16 07:43:45 -0700 (Mon, 16 May 2011)
Log Message:
-----------
export.emptyComponent -> Component.newCalendar
Modified Paths:
--------------
CalendarServer/branches/users/glyph/new-export/calendarserver/tools/export.py
CalendarServer/branches/users/glyph/new-export/calendarserver/tools/test/test_export.py
CalendarServer/branches/users/glyph/new-export/twistedcaldav/ical.py
CalendarServer/branches/users/glyph/new-export/twistedcaldav/test/test_icalendar.py
Modified: CalendarServer/branches/users/glyph/new-export/calendarserver/tools/export.py
===================================================================
--- CalendarServer/branches/users/glyph/new-export/calendarserver/tools/export.py 2011-05-16 14:43:31 UTC (rev 7462)
+++ CalendarServer/branches/users/glyph/new-export/calendarserver/tools/export.py 2011-05-16 14:43:45 UTC (rev 7463)
@@ -46,8 +46,8 @@
#from twisted.internet.defer import returnValue
from twistedcaldav.config import ConfigurationError
-from twistedcaldav.ical import Component, Property
-from twistedcaldav.ical import iCalendarProductID
+from twistedcaldav.ical import Component
+
from twistedcaldav.resource import isCalendarCollectionResource,\
CalendarHomeResource
from twistedcaldav.directory.directory import DirectoryService
@@ -85,19 +85,15 @@
-def emptyComponent():
+class ExportOptions(Options):
"""
- Create and return an empty C{VCALENDAR} component.
+ Command-line options for 'calendarserver_export'
+
+ @ivar exporters: a list of L{HomeExporter} objects which can identify the
+ calendars to export, given a directory service. This list is built by
+ parsing --record and --collection options.
"""
- c = Component("VCALENDAR")
- c.addProperty(Property("VERSION", "2.0"))
- c.addProperty(Property("PRODID", iCalendarProductID))
- return c
-
-
-class ExportOptions(Options):
-
def __init__(self):
super(ExportOptions, self).__init__()
self.exporters = []
@@ -149,7 +145,7 @@
the file will not be closed.)
@rtype: L{Deferred} that fires with C{None}
"""
- comp = emptyComponent()
+ comp = Component.newCalendar()
for calendar in calendars:
calendar = yield calendar
for obj in (yield calendar.calendarObjects()):
@@ -258,7 +254,7 @@
collections.add(child)
try:
- calendar = emptyComponent()
+ calendar = Component.newCalendar()
uids = set()
tzids = set()
Modified: CalendarServer/branches/users/glyph/new-export/calendarserver/tools/test/test_export.py
===================================================================
--- CalendarServer/branches/users/glyph/new-export/calendarserver/tools/test/test_export.py 2011-05-16 14:43:31 UTC (rev 7462)
+++ CalendarServer/branches/users/glyph/new-export/calendarserver/tools/test/test_export.py 2011-05-16 14:43:45 UTC (rev 7463)
@@ -36,7 +36,7 @@
from txdav.common.datastore.test.util import buildStore
from txdav.common.datastore.test.util import populateCalendarsFrom
-from calendarserver.tools.export import usage, exportToFile, emptyComponent
+from calendarserver.tools.export import usage, exportToFile
def holiday(uid):
return (
@@ -157,7 +157,7 @@
self.assertEquals(value, None)
# but it should write a valid component to the file.
self.assertEquals(Component.fromString(io.getvalue()),
- emptyComponent())
+ Component.newCalendar())
def txn(self):
@@ -187,7 +187,7 @@
}, self.store
)
- expected = emptyComponent()
+ expected = Component.newCalendar()
[theComponent] = Component.fromString(valentines).subcomponents()
expected.addComponent(theComponent)
@@ -218,7 +218,7 @@
}, self.store
)
- expected = emptyComponent()
+ expected = Component.newCalendar()
a = Component.fromString(valentines)
b = Component.fromString(newYears)
for comp in a, b:
Modified: CalendarServer/branches/users/glyph/new-export/twistedcaldav/ical.py
===================================================================
--- CalendarServer/branches/users/glyph/new-export/twistedcaldav/ical.py 2011-05-16 14:43:31 UTC (rev 7462)
+++ CalendarServer/branches/users/glyph/new-export/twistedcaldav/ical.py 2011-05-16 14:43:45 UTC (rev 7463)
@@ -1,3 +1,4 @@
+# -*- test-case-name: twistedcaldav.test.test_icalendar -*-
##
# Copyright (c) 2005-2010 Apple Inc. All rights reserved.
#
@@ -362,6 +363,18 @@
def parse(data): return clazz.fromString(data)
return allDataFromStream(IStream(stream), parse)
+
+ @classmethod
+ def newCalendar(cls):
+ """
+ Create and return an empty C{VCALENDAR} component.
+ """
+ self = cls("VCALENDAR")
+ self.addProperty(Property("VERSION", "2.0"))
+ self.addProperty(Property("PRODID", iCalendarProductID))
+ return self
+
+
def __init__(self, name, **kwargs):
"""
Use this constructor to initialize an empty L{Component}.
Modified: CalendarServer/branches/users/glyph/new-export/twistedcaldav/test/test_icalendar.py
===================================================================
--- CalendarServer/branches/users/glyph/new-export/twistedcaldav/test/test_icalendar.py 2011-05-16 14:43:31 UTC (rev 7462)
+++ CalendarServer/branches/users/glyph/new-export/twistedcaldav/test/test_icalendar.py 2011-05-16 14:43:45 UTC (rev 7463)
@@ -26,6 +26,7 @@
from pycalendar.datetime import PyCalendarDateTime
from pycalendar.timezone import PyCalendarTimezone
+from twistedcaldav.ical import iCalendarProductID
from pycalendar.duration import PyCalendarDuration
class iCalendar (twistedcaldav.test.util.TestCase):
@@ -50,6 +51,20 @@
else:
SkipTest("test unimplemented")
+
+ def test_newCalendar(self):
+ """
+ L{Component.newCalendar} creates a new VCALENDAR L{Component} with
+ appropriate version and product identifiers, and no subcomponents.
+ """
+ calendar = Component.newCalendar()
+ version = calendar.getProperty("VERSION")
+ prodid = calendar.getProperty("PRODID")
+ self.assertEqual(version.value(), "2.0")
+ self.assertEqual(prodid.value(), iCalendarProductID)
+ self.assertEqual(list(calendar.subcomponents()), [])
+
+
def test_component_equality(self):
# for filename in (
# os.path.join(self.data_dir, "Holidays", "C318A4BA-1ED0-11D9-A5E0-000A958A3252.ics"),
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110516/f99d8b81/attachment-0001.html>
More information about the calendarserver-changes
mailing list