[CalendarServer-changes] [15070] CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/ query.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Aug 26 18:58:53 PDT 2015
Revision: 15070
http://trac.calendarserver.org//changeset/15070
Author: sagen at apple.com
Date: 2015-08-26 18:58:53 -0700 (Wed, 26 Aug 2015)
Log Message:
-----------
Adds 'query -D' which prints details about events -- so far just the SUMMARY
Modified Paths:
--------------
CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/query.py
Modified: CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/query.py
===================================================================
--- CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/query.py 2015-08-26 18:01:05 UTC (rev 15069)
+++ CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/query.py 2015-08-27 01:58:53 UTC (rev 15070)
@@ -23,6 +23,7 @@
import shlex
import time
from caldavclientlibrary.protocol.caldav.definitions import caldavxml
+from pycalendar.icalendar.calendar import Calendar
class Cmd(Command):
@@ -39,8 +40,9 @@
end = None
expand = False
data = False
+ details = False
- opts, args = getopt.getopt(shlex.split(options), 'ts:e:xd')
+ opts, args = getopt.getopt(shlex.split(options), 'ts:e:xdD')
for name, value in opts:
@@ -54,6 +56,8 @@
expand = True
elif name == "-d":
data = True
+ elif name == "-D":
+ details = True
else:
print "Unknown option: %s" % (name,)
print self.usage(cmdname)
@@ -85,7 +89,20 @@
props += (caldavxml.calendar_data,)
results = self.shell.account.session.queryCollection(resource, timerange, start, end, expand, props=props)
for href in results:
- print href
+ if details:
+ summaries = []
+ data = self.shell.account.session.readData(href)
+ try:
+ cobject = Calendar.parseData(data[0])
+ for comp in cobject.getComponents():
+ for summary in [p.getValue().getValue() for p in comp.getProperties("SUMMARY")]:
+ if summary not in summaries:
+ summaries.append(summary)
+ except:
+ summaries = ["<Could not parse>"]
+ print href, "summary: {}".format("|".join(summaries))
+ else:
+ print href
return True
@@ -100,6 +117,7 @@
-e end time [DEFAULT tomorrow]
-x expand components
-d return data
+-D print details including SUMMARY
""" % (name,)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150826/7f245e3d/attachment.html>
More information about the calendarserver-changes
mailing list