[CalendarServer-changes] [7277] CalDAVClientLibrary/trunk/src
source_changes at macosforge.org
source_changes at macosforge.org
Wed Mar 30 13:19:25 PDT 2011
Revision: 7277
http://trac.macosforge.org/projects/calendarserver/changeset/7277
Author: cdaboo at apple.com
Date: 2011-03-30 13:19:25 -0700 (Wed, 30 Mar 2011)
Log Message:
-----------
Allow option to include various tags/tokens in the ls output.
Modified Paths:
--------------
CalDAVClientLibrary/trunk/src/browser/commands/ls.py
CalDAVClientLibrary/trunk/src/protocol/caldav/definitions/csxml.py
CalDAVClientLibrary/trunk/src/protocol/webdav/definitions/davxml.py
Modified: CalDAVClientLibrary/trunk/src/browser/commands/ls.py
===================================================================
--- CalDAVClientLibrary/trunk/src/browser/commands/ls.py 2011-03-30 20:08:33 UTC (rev 7276)
+++ CalDAVClientLibrary/trunk/src/browser/commands/ls.py 2011-03-30 20:19:25 UTC (rev 7277)
@@ -16,6 +16,7 @@
from browser.command import Command
from browser.command import WrongOptions
+from protocol.caldav.definitions import csxml
from protocol.webdav.definitions import davxml
from protocol.url import URL
import os
@@ -33,18 +34,30 @@
longlist = False
path = None
displayname = False
+ ctag = False
+ etag = False
+ synctoken = False
- opts, args = getopt.getopt(shlex.split(options), 'adl')
+ opts, args = getopt.getopt(shlex.split(options), 'acdels')
for name, _ignore_value in opts:
if name == "-a":
pass
+ elif name == "-c":
+ ctag = True
+ longlist = True
elif name == "-d":
displayname = True
longlist = True
+ elif name == "-e":
+ etag = True
+ longlist = True
elif name == "-l":
longlist = True
+ elif name == "-s":
+ synctoken = True
+ longlist = True
else:
print "Unknown option: %s" % (name,)
print self.usage(name)
@@ -66,26 +79,57 @@
props = (davxml.resourcetype,)
if longlist:
- props += (davxml.displayname, davxml.getcontentlength, davxml.getlastmodified,)
+ props += (davxml.getcontentlength, davxml.getlastmodified,)
+ if ctag:
+ props += (csxml.getctag,)
+ if etag:
+ props += (davxml.getetag,)
+ if synctoken:
+ props += (davxml.synctoken,)
results = self.shell.account.session.getPropertiesOnHierarchy(resource, props)
items = results.keys()
items.sort()
+ lines = []
for rurl in items:
if rurl == path:
continue
+ line = []
if longlist:
props = results[rurl]
size = props.get(davxml.getcontentlength, "-")
if not size:
size = "0"
+ line.append("%s" % (size,))
modtime = props.get(davxml.getlastmodified, "-")
+ line.append(modtime)
+ line.append(rurl[len(path):])
if displayname:
- print "% 8s %s %s '%s'" % (size, modtime, rurl[len(path):], props.get(davxml.displayname, ''))
- else:
- print "% 8s %s %s" % (size, modtime, rurl[len(path):])
+ line.append("name:'%s'" % (props.get(davxml.displayname, '-'),))
+ if ctag:
+ line.append("ctag:'%s'" % (props.get(csxml.getctag, '-'),))
+ if etag:
+ line.append("etag:'%s'" % (props.get(davxml.getetag, '-'),))
+ if synctoken:
+ line.append("sync:'%s'" % (props.get(davxml.synctoken, '-'),))
else:
- print rurl[len(path):]
+ line.append(rurl[len(path):])
+ lines.append(line)
+
+ if lines:
+ # Get column widths
+ widths = [0] * len(lines[0])
+ for line in lines:
+ for ctr, col in enumerate(line):
+ widths[ctr] = max(widths[ctr], len(col))
+ # Write out each one
+ for line in lines:
+ for ctr, col in enumerate(line):
+ if ctr in (0, 1):
+ print col.rjust(widths[ctr] + 2),
+ else:
+ print col.ljust(widths[ctr] + 2),
+ print
return True
def complete(self, text):
@@ -96,8 +140,11 @@
PATH is a relative or absolute path.
Options:
+-c long listing + CS:getctag
-d long listing + DAV:displayname
+-e long listing + DAV:getetag
-l long listing
+-s long listing + DAV:sync-token
""" % (name,)
def helpDescription(self):
Modified: CalDAVClientLibrary/trunk/src/protocol/caldav/definitions/csxml.py
===================================================================
--- CalDAVClientLibrary/trunk/src/protocol/caldav/definitions/csxml.py 2011-03-30 20:08:33 UTC (rev 7276)
+++ CalDAVClientLibrary/trunk/src/protocol/caldav/definitions/csxml.py 2011-03-30 20:19:25 UTC (rev 7277)
@@ -20,6 +20,7 @@
calendar_proxy_read_for = QName(CSNamespace, "calendar-proxy-read-for")
calendar_proxy_write_for = QName(CSNamespace, "calendar-proxy-write-for")
+getctag = QName(CSNamespace, "getctag")
notification = QName(CSNamespace, "notification")
notification_URL = QName(CSNamespace, "notification-URL")
Modified: CalDAVClientLibrary/trunk/src/protocol/webdav/definitions/davxml.py
===================================================================
--- CalDAVClientLibrary/trunk/src/protocol/webdav/definitions/davxml.py 2011-03-30 20:08:33 UTC (rev 7276)
+++ CalDAVClientLibrary/trunk/src/protocol/webdav/definitions/davxml.py 2011-03-30 20:19:25 UTC (rev 7277)
@@ -36,6 +36,7 @@
getlastmodified = QName(DAVNamespace, "getlastmodified")
resourcetype = QName(DAVNamespace, "resourcetype")
collection = QName(DAVNamespace, "collection")
+synctoken = QName(DAVNamespace, "sync-token")
lockinfo = QName(DAVNamespace, "lockinfo")
lockscope = QName(DAVNamespace, "lockscope")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110330/fc7fe451/attachment.html>
More information about the calendarserver-changes
mailing list