1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 from caldavclientlibrary.browser.command import Command
18 from caldavclientlibrary.browser.command import WrongOptions
19 from caldavclientlibrary.protocol.url import URL
20 from caldavclientlibrary.browser import utils
21 import os
22 import getopt
23 import shlex
24
26
30
32
33 names = False
34 all = False
35 xmllist = False
36 path = None
37
38 opts, args = getopt.getopt(shlex.split(options), 'aln')
39
40 for name, _ignore_value in opts:
41
42 if name == "-a":
43 all = True
44 elif name == "-l":
45 xmllist = True
46 elif name == "-n":
47 names = True
48 else:
49 print "Unknown option: %s" % (name,)
50 print self.usage(name)
51 raise WrongOptions
52
53 if len(args) > 1:
54 print "Wrong number of arguments: %d" % (len(args),)
55 print self.usage(name)
56 raise WrongOptions
57 elif args:
58 path = args[0]
59 if not path.startswith("/"):
60 path = os.path.join(self.shell.wd, path)
61 else:
62 path = self.shell.wd
63 if not path.endswith("/"):
64 path += "/"
65 resource = URL(url=path)
66
67 if names:
68 results = self.shell.account.session.getPropertyNames(resource)
69 print " Properties: %s" % (utils.printList(results),)
70 else:
71 if all:
72 props = None
73 else:
74 props = self.shell.account.session.getPropertyNames(resource)
75 results, bad = self.shell.account.session.getProperties(resource, props, xmllist)
76 print "OK Properties:"
77 utils.printProperties(results)
78 if bad:
79 print "Failed Properties:"
80 utils.printProperties(bad)
81
82 return True
83
86
88 return """Usage: %s [OPTIONS] [PATH]
89 PATH is a relative or absolute path.
90
91 Options:
92 -n list property names only
93 -a list all properties via allprop
94 -l list actual property XML values
95 if neither -n nor -a are set then property names are first listed, and then values of those looked up.
96 only one of -n and -a can be set.
97 """ % (name,)
98
100 return "List the properties of a directory or file."
101