[CalendarServer-changes] [15068] CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/ls. py

source_changes at macosforge.org source_changes at macosforge.org
Wed Aug 26 10:25:45 PDT 2015


Revision: 15068
          http://trac.calendarserver.org//changeset/15068
Author:   sagen at apple.com
Date:     2015-08-26 10:25:45 -0700 (Wed, 26 Aug 2015)
Log Message:
-----------
Adds 'ls -D' which prints details about events -- so far just the SUMMARY

Modified Paths:
--------------
    CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/ls.py

Modified: CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/ls.py
===================================================================
--- CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/ls.py	2015-08-21 19:47:02 UTC (rev 15067)
+++ CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/ls.py	2015-08-26 17:25:45 UTC (rev 15068)
@@ -19,6 +19,8 @@
 from caldavclientlibrary.protocol.caldav.definitions import csxml, caldavxml
 from caldavclientlibrary.protocol.webdav.definitions import davxml
 from caldavclientlibrary.protocol.url import URL
+from pycalendar.icalendar.calendar import Calendar
+
 import os
 import getopt
 import shlex
@@ -42,8 +44,9 @@
         etag = False
         supported_components = False
         synctoken = False
+        details = False
 
-        opts, args = getopt.getopt(shlex.split(options), 'acdeilrs')
+        opts, args = getopt.getopt(shlex.split(options), 'acdDeilrs')
 
         for name, _ignore_value in opts:
 
@@ -55,6 +58,8 @@
             elif name == "-d":
                 displayname = True
                 longlist = True
+            elif name == "-D":
+                details = True
             elif name == "-e":
                 etag = True
                 longlist = True
@@ -106,6 +111,19 @@
         items.sort()
         lines = []
         for rurl in items:
+
+            summaries = []
+            if details:
+                data = self.shell.account.session.readData(URL(url=rurl))
+                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>"]
+
             rurl = urllib.unquote(rurl)
             if rurl == path:
                 continue
@@ -136,6 +154,8 @@
                     line.append("sync:'%s'" % (props.get(davxml.synctoken, '-'),))
             else:
                 line.append(rurl[len(path):])
+            if details:
+                line.append("summary: {}".format("|".join(summaries)))
             lines.append(line)
 
         if lines:
@@ -168,6 +188,7 @@
 -l   long listing
 -r   long listing + DAV:resourcetype
 -s   long listing + DAV:sync-token
+-D   details including SUMMARY
 """ % (name,)
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150826/fb2864a9/attachment.html>


More information about the calendarserver-changes mailing list