[CalendarServer-changes] [11620] PyCalendar/branches/json-2/src/pycalendar

source_changes at macosforge.org source_changes at macosforge.org
Tue Aug 20 09:43:53 PDT 2013


Revision: 11620
          http://trac.calendarserver.org//changeset/11620
Author:   cdaboo at apple.com
Date:     2013-08-20 09:43:53 -0700 (Tue, 20 Aug 2013)
Log Message:
-----------
Initial VPOLL support.

Modified Paths:
--------------
    PyCalendar/branches/json-2/src/pycalendar/__init__.py
    PyCalendar/branches/json-2/src/pycalendar/icalendar/definitions.py
    PyCalendar/branches/json-2/src/pycalendar/icalendar/itipdefinitions.py

Added Paths:
-----------
    PyCalendar/branches/json-2/src/pycalendar/icalendar/tests/test_vpoll.py
    PyCalendar/branches/json-2/src/pycalendar/icalendar/vpoll.py

Modified: PyCalendar/branches/json-2/src/pycalendar/__init__.py
===================================================================
--- PyCalendar/branches/json-2/src/pycalendar/__init__.py	2013-08-20 03:11:03 UTC (rev 11619)
+++ PyCalendar/branches/json-2/src/pycalendar/__init__.py	2013-08-20 16:43:53 UTC (rev 11620)
@@ -43,11 +43,9 @@
 import icalendar.vevent
 import icalendar.vfreebusy
 import icalendar.vjournal
+import icalendar.vpoll
 import icalendar.vtimezone
 import icalendar.vtimezonedaylight
 import icalendar.vtimezonestandard
 import icalendar.vtodo
 import icalendar.vunknown
-
-# Import these to force static initialisation
-#import property

Modified: PyCalendar/branches/json-2/src/pycalendar/icalendar/definitions.py
===================================================================
--- PyCalendar/branches/json-2/src/pycalendar/icalendar/definitions.py	2013-08-20 03:11:03 UTC (rev 11619)
+++ PyCalendar/branches/json-2/src/pycalendar/icalendar/definitions.py	2013-08-20 16:43:53 UTC (rev 11620)
@@ -320,6 +320,7 @@
 #     Section 3.2
 cICalProperty_BUSYTYPE = "BUSYTYPE"
 
+
 #     Extensions: draft-daboo-valarm-extensions-03
 
 #     Section 5
@@ -332,6 +333,26 @@
 eAction_VAlarm_None = 6
 cICalProperty_ACTION_NONE = "NONE"
 
+
+#    Extensions: draft-york-vpoll-00.txt
+
+#    Section 4.1
+cICalParamater_PUBLIC_COMMENT = "PUBLIC-COMMENT"
+cICalParamater_RESPONSE = "RESPONSE"
+cICalParamater_STAY_INFORMED = "STAY-INFORMED"
+
+#    Section 4.2
+cICalProperty_ACCEPT_RESPONSE = "ACCEPT-RESPONSE"
+cICalProperty_POLL_ITEM_ID = "POLL-ITEM-ID"
+cICalProperty_POLL_MODE = "POLL-MODE"
+cICalProperty_POLL_MODE_BASIC = "BASIC"
+cICalProperty_POLL_PROPERTIES = "POLL-PROPERTIES"
+cICalProperty_VOTER = "VOTER"
+
+#    Section 4.3
+cICalComponent_VPOLL = "VPOLL"
+
+
 #     Mulberry extensions
 cICalProperty_ACTION_X_SPEAKTEXT = "X-MULBERRY-SPEAK-TEXT"
 cICalProperty_ALARM_X_LASTTRIGGER = "X-MULBERRY-LAST-TRIGGER"

Modified: PyCalendar/branches/json-2/src/pycalendar/icalendar/itipdefinitions.py
===================================================================
--- PyCalendar/branches/json-2/src/pycalendar/icalendar/itipdefinitions.py	2013-08-20 03:11:03 UTC (rev 11619)
+++ PyCalendar/branches/json-2/src/pycalendar/icalendar/itipdefinitions.py	2013-08-20 16:43:53 UTC (rev 11620)
@@ -40,3 +40,10 @@
 cICalMIMEComponent_VJOURNAL = "vjournal"
 cICalMIMEComponent_VFREEBUSY = "vfreebusy"
 cICalMIMEComponent_VAVAILABILITY = "vavailability"
+
+# VPOLL extensions draft-york-vpoll-00.txt
+
+#    Section 6.1
+cICalMethod_POLLSTATUS = "POLLSTATUS"
+cICalMIMEMethod_POLLSTATUS = "pollstatus"
+cICalMIMEComponent_VPOLL = "vpoll"

Added: PyCalendar/branches/json-2/src/pycalendar/icalendar/tests/test_vpoll.py
===================================================================
--- PyCalendar/branches/json-2/src/pycalendar/icalendar/tests/test_vpoll.py	                        (rev 0)
+++ PyCalendar/branches/json-2/src/pycalendar/icalendar/tests/test_vpoll.py	2013-08-20 16:43:53 UTC (rev 11620)
@@ -0,0 +1,98 @@
+##
+#    Copyright (c) 2007-2012 Cyrus Daboo. All rights reserved.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+##
+
+from pycalendar.icalendar.calendar import Calendar
+import cStringIO as StringIO
+import difflib
+import unittest
+
+class TestCalendar(unittest.TestCase):
+
+    data = (
+"""BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+PRODID:-//mulberrymail.com//Mulberry v4.0//EN
+BEGIN:VPOLL
+UID:A979D282-2CDB-484F-BD63-3972094DFFC0
+DTSTAMP:20020101T000000Z
+ORGANIZER:mailto:user01 at example.com
+POLL-MODE:BASIC
+POLL-PROPERTIES:DTSTART,DTEND
+VOTER;CN=User 02:mailto:user02 at example.com
+VOTER;CN=User 03:mailto:user03 at example.com
+BEGIN:VEVENT
+UID:C3184A66-1ED0-11D9-A5E0-000A958A3252
+DTSTART;VALUE=DATE:20130101
+DTEND;VALUE=DATE:20130102
+DTSTAMP:20020101T000000Z
+POLL-ITEM-ID:1
+SUMMARY:Party option #1
+END:VEVENT
+BEGIN:VEVENT
+UID:C3184A66-1ED0-11D9-A5E0-000A958A3252
+DTSTART;VALUE=DATE:20130201
+DTEND;VALUE=DATE:20130202
+DTSTAMP:20020101T000000Z
+POLL-ITEM-ID:2
+SUMMARY:Party option #2
+END:VEVENT
+END:VPOLL
+END:VCALENDAR
+""",
+
+"""BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+METHOD:REPLY
+PRODID:-//mulberrymail.com//Mulberry v4.0//EN
+BEGIN:VPOLL
+UID:A979D282-2CDB-484F-BD63-3972094DFFC0
+DTSTAMP:20020101T000000Z
+ORGANIZER:mailto:user01 at example.com
+POLL-ITEM-ID;PUBLIC-COMMENT=Not ideal;RESPONSE=50:1
+POLL-ITEM-ID;PUBLIC-COMMENT=Perfect;RESPONSE=100:2
+POLL-MODE:BASIC
+POLL-PROPERTIES:DTSTART,DTEND
+VOTER;CN=User 02:mailto:user02 at example.com
+END:VPOLL
+END:VCALENDAR
+""",
+
+)
+
+
+    def testRoundtrip(self):
+
+
+        def _doRoundtrip(caldata, resultdata=None):
+            test1 = resultdata if resultdata is not None else caldata
+
+            cal = Calendar()
+            cal.parse(StringIO.StringIO(caldata))
+
+            s = StringIO.StringIO()
+            cal.generate(s)
+            test2 = s.getvalue()
+
+            self.assertEqual(
+                test1,
+                test2,
+                "\n".join(difflib.unified_diff(str(test1).splitlines(), test2.splitlines()))
+            )
+
+        for item in self.data:
+            _doRoundtrip(item.replace("\n", "\r\n"))

Added: PyCalendar/branches/json-2/src/pycalendar/icalendar/vpoll.py
===================================================================
--- PyCalendar/branches/json-2/src/pycalendar/icalendar/vpoll.py	                        (rev 0)
+++ PyCalendar/branches/json-2/src/pycalendar/icalendar/vpoll.py	2013-08-20 16:43:53 UTC (rev 11620)
@@ -0,0 +1,67 @@
+##
+#    Copyright (c) 2007-2012 Cyrus Daboo. All rights reserved.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+##
+
+from pycalendar.icalendar import definitions
+from pycalendar.icalendar import itipdefinitions
+from pycalendar.icalendar.component import Component
+from pycalendar.icalendar.validation import ICALENDAR_VALUE_CHECKS
+
+class VPoll(Component):
+
+    propertyCardinality_1 = (
+        definitions.cICalProperty_DTSTAMP,
+        definitions.cICalProperty_UID,
+        definitions.cICalProperty_ORGANIZER,
+    )
+
+    propertyCardinality_0_1 = (
+        definitions.cICalProperty_ACCEPT_RESPONSE,
+        definitions.cICalProperty_CLASS,
+        definitions.cICalProperty_CREATED,
+        definitions.cICalProperty_COMPLETED,
+        definitions.cICalProperty_DESCRIPTION,
+        definitions.cICalProperty_DTSTART,
+        definitions.cICalProperty_DTEND,
+        definitions.cICalProperty_DURATION,
+        definitions.cICalProperty_LAST_MODIFIED,
+        definitions.cICalProperty_POLL_MODE,
+        definitions.cICalProperty_POLL_PROPERTIES,
+        definitions.cICalProperty_PRIORITY,
+        definitions.cICalProperty_SEQUENCE,
+        definitions.cICalProperty_STATUS,
+        definitions.cICalProperty_SUMMARY,
+        definitions.cICalProperty_URL,
+    )
+
+    propertyValueChecks = ICALENDAR_VALUE_CHECKS
+
+    def getType(self):
+        return definitions.cICalComponent_VPOLL
+
+
+    def getMimeComponentName(self):
+        return itipdefinitions.cICalMIMEComponent_VPOLL
+
+
+    def sortedPropertyKeyOrder(self):
+        return (
+            definitions.cICalProperty_UID,
+            definitions.cICalProperty_DTSTART,
+            definitions.cICalProperty_DURATION,
+            definitions.cICalProperty_DTEND,
+        )
+
+Component.registerComponent(definitions.cICalComponent_VPOLL, VPoll)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130820/6d818e53/attachment.html>


More information about the calendarserver-changes mailing list