[CalendarServer-changes] [15442] CalDAVTester/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Jan 22 13:22:35 PST 2016
Revision: 15442
http://trac.calendarserver.org//changeset/15442
Author: cdaboo at apple.com
Date: 2016-01-22 13:22:35 -0800 (Fri, 22 Jan 2016)
Log Message:
-----------
Make pycalendar imports optional. Clean-up.
Modified Paths:
--------------
CalDAVTester/trunk/.project
CalDAVTester/trunk/src/caldavtest.py
CalDAVTester/trunk/src/request.py
CalDAVTester/trunk/verifiers/addressDataMatch.py
CalDAVTester/trunk/verifiers/calendarDataMatch.py
CalDAVTester/trunk/verifiers/freeBusy.py
CalDAVTester/trunk/verifiers/postFreeBusy.py
CalDAVTester/trunk/verifiers/xmlElementMatch.py
Modified: CalDAVTester/trunk/.project
===================================================================
--- CalDAVTester/trunk/.project 2016-01-22 18:27:32 UTC (rev 15441)
+++ CalDAVTester/trunk/.project 2016-01-22 21:22:35 UTC (rev 15442)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>caldavtester</name>
+ <name>CalDAVTester</name>
<comment></comment>
<projects>
<project>pycalendar</project>
@@ -15,15 +15,4 @@
<natures>
<nature>org.python.pydev.pythonNature</nature>
</natures>
- <filteredResources>
- <filter>
- <id>1395855144585</id>
- <name></name>
- <type>10</type>
- <matcher>
- <id>org.eclipse.ui.ide.multiFilter</id>
- <arguments>1.0-projectRelativePath-matches-true-false-.develop</arguments>
- </matcher>
- </filter>
- </filteredResources>
</projectDescription>
Modified: CalDAVTester/trunk/src/caldavtest.py
===================================================================
--- CalDAVTester/trunk/src/caldavtest.py 2016-01-22 18:27:32 UTC (rev 15441)
+++ CalDAVTester/trunk/src/caldavtest.py 2016-01-22 21:22:35 UTC (rev 15442)
@@ -19,7 +19,11 @@
"""
from cStringIO import StringIO
-from pycalendar.icalendar.calendar import Calendar
+try:
+ # Treat pycalendar as optional
+ from pycalendar.icalendar.calendar import Calendar
+except ImportError:
+ pass
from src.httpshandler import SmartHTTPConnection
from src.jsonPointer import JSONMatcher
from src.manager import manager
@@ -751,7 +755,7 @@
if stats:
stats.endTimer()
- if doverify and (respdata != None):
+ if doverify and (respdata is not None):
result, txt = self.verifyrequest(req, uri, response, respdata)
resulttxt += txt
elif forceverify:
@@ -784,7 +788,7 @@
tree = ElementTree(file=StringIO(respdata))
ctr = len(tree.findall("{DAV:}response")) - 1
- if ctr == None or ctr == -1:
+ if ctr is None or ctr == -1:
result = False
resulttxt += "\nCould not count resources in response\n"
else:
@@ -804,7 +808,7 @@
for propname, variable in req.grabproperty:
# grab the property here
propvalue = self.extractProperty(propname, respdata)
- if propvalue == None:
+ if propvalue is None:
result = False
resulttxt += "\nProperty %s was not extracted from multistatus response\n" % (propname,)
else:
@@ -820,7 +824,7 @@
parent = self.manager.server_info.extrasubs(parent)
# grab the property here
elementvalues = self.extractElements(elementpath, parent, respdata)
- if elementvalues == None:
+ if elementvalues is None:
result = False
resulttxt += "\nElement %s was not extracted from response\n" % (elementpath,)
elif len(variables) != len(elementvalues):
@@ -834,7 +838,7 @@
for pointer, variables in req.grabjson:
# grab the JSON value here
pointervalues = self.extractPointer(pointer, respdata)
- if pointervalues == None:
+ if pointervalues is None:
result = False
resulttxt += "\Pointer %s was not extracted from response\n" % (pointer,)
elif len(variables) != len(pointervalues):
@@ -850,7 +854,7 @@
propname = self.manager.server_info.subs(propname)
propname = self.manager.server_info.extrasubs(propname)
propvalue = self.extractCalProperty(propname, respdata)
- if propvalue == None:
+ if propvalue is None:
result = False
resulttxt += "\nCalendar property %s was not extracted from response\n" % (propname,)
else:
@@ -862,7 +866,7 @@
paramname = self.manager.server_info.subs(paramname)
paramname = self.manager.server_info.extrasubs(paramname)
paramvalue = self.extractCalParameter(paramname, respdata)
- if paramvalue == None:
+ if paramvalue is None:
result = False
resulttxt += "\nCalendar Parameter %s was not extracted from response\n" % (paramname,)
else:
Modified: CalDAVTester/trunk/src/request.py
===================================================================
--- CalDAVTester/trunk/src/request.py 2016-01-22 18:27:32 UTC (rev 15441)
+++ CalDAVTester/trunk/src/request.py 2016-01-22 21:22:35 UTC (rev 15442)
@@ -206,7 +206,7 @@
hdrs[key] = si.extrasubs(value)
# Content type
- if self.data != None:
+ if self.data is not None:
hdrs["Content-Type"] = self.data.content_type
# Auth
@@ -308,7 +308,7 @@
def getFilePath(self):
- if self.data != None:
+ if self.data is not None:
return os.path.join(self.manager.data_dir, self.data.filepath) if self.manager.data_dir else self.data.filepath
else:
return ""
@@ -316,7 +316,7 @@
def getData(self):
data = ""
- if self.data != None:
+ if self.data is not None:
if len(self.data.value) != 0:
data = self.data.value
elif self.data.filepath:
Modified: CalDAVTester/trunk/verifiers/addressDataMatch.py
===================================================================
--- CalDAVTester/trunk/verifiers/addressDataMatch.py 2016-01-22 18:27:32 UTC (rev 15441)
+++ CalDAVTester/trunk/verifiers/addressDataMatch.py 2016-01-22 21:22:35 UTC (rev 15442)
@@ -15,7 +15,11 @@
##
from difflib import unified_diff
-from pycalendar.vcard.card import Card
+try:
+ # pycalendar is optional
+ from pycalendar.vcard.card import Card
+except ImportError:
+ pass
import os
"""
Modified: CalDAVTester/trunk/verifiers/calendarDataMatch.py
===================================================================
--- CalDAVTester/trunk/verifiers/calendarDataMatch.py 2016-01-22 18:27:32 UTC (rev 15441)
+++ CalDAVTester/trunk/verifiers/calendarDataMatch.py 2016-01-22 21:22:35 UTC (rev 15442)
@@ -15,9 +15,13 @@
##
from difflib import unified_diff
-from pycalendar.icalendar.calendar import Calendar
-from pycalendar.icalendar.componentrecur import ComponentRecur
-from pycalendar.parameter import Parameter
+try:
+ # pycalendar is optional
+ from pycalendar.icalendar.calendar import Calendar
+ from pycalendar.icalendar.componentrecur import ComponentRecur
+ from pycalendar.parameter import Parameter
+except ImportError:
+ pass
import os
"""
Modified: CalDAVTester/trunk/verifiers/freeBusy.py
===================================================================
--- CalDAVTester/trunk/verifiers/freeBusy.py 2016-01-22 18:27:32 UTC (rev 15441)
+++ CalDAVTester/trunk/verifiers/freeBusy.py 2016-01-22 21:22:35 UTC (rev 15442)
@@ -18,9 +18,15 @@
Verifier that checks the response of a free-busy-query.
"""
-from pycalendar.icalendar.calendar import Calendar
-from pycalendar.exceptions import InvalidData
+try:
+ # pycalendar is optional
+ from pycalendar.icalendar.calendar import Calendar
+ from pycalendar.exceptions import InvalidData
+except ImportError:
+ pass
+
+
class Verifier(object):
def verify(self, manager, uri, response, respdata, args): #@UnusedVariable
@@ -104,5 +110,7 @@
return False, " HTTP response data is not a calendar"
except ValueError, txt:
return False, " HTTP response data is invalid: %s" % (txt,)
+ except Exception, e:
+ return False, " Response data is not calendar data: %s" % (e,)
return True, ""
Modified: CalDAVTester/trunk/verifiers/postFreeBusy.py
===================================================================
--- CalDAVTester/trunk/verifiers/postFreeBusy.py 2016-01-22 18:27:32 UTC (rev 15441)
+++ CalDAVTester/trunk/verifiers/postFreeBusy.py 2016-01-22 21:22:35 UTC (rev 15442)
@@ -18,8 +18,12 @@
Verifier that checks the response of a free-busy-query.
"""
-from pycalendar.icalendar.calendar import Calendar
-from pycalendar.exceptions import InvalidData
+try:
+ # pycalendar is optional
+ from pycalendar.icalendar.calendar import Calendar
+ from pycalendar.exceptions import InvalidData
+except ImportError:
+ pass
from xml.etree.cElementTree import ElementTree
from xml.parsers.expat import ExpatError
import StringIO
@@ -124,6 +128,8 @@
return False, " HTTP response data is not a calendar"
except ValueError, txt:
return False, " HTTP response data is invalid: %s" % (txt,)
+ except Exception, e:
+ return False, " Response data is not calendar data: %s" % (e,)
if len(users):
return False, " Could not find attendee/calendar data in XML response\n"
Modified: CalDAVTester/trunk/verifiers/xmlElementMatch.py
===================================================================
--- CalDAVTester/trunk/verifiers/xmlElementMatch.py 2016-01-22 18:27:32 UTC (rev 15441)
+++ CalDAVTester/trunk/verifiers/xmlElementMatch.py 2016-01-22 21:22:35 UTC (rev 15442)
@@ -19,7 +19,11 @@
Verifier that checks the response body for an exact match to data in a file.
"""
-from pycalendar.icalendar.calendar import Calendar
+try:
+ # pycalendar is optional
+ from pycalendar.icalendar.calendar import Calendar
+except ImportError:
+ pass
from xml.etree.cElementTree import ElementTree
import json
import re
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20160122/283c758b/attachment-0001.html>
More information about the calendarserver-changes
mailing list