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 import getopt
21 import os
22 import readline
23 import shlex
24
26
30
32
33 opts, args = getopt.getopt(shlex.split(options), '')
34
35 for name, _ignore_value in opts:
36
37 print "Unknown option: %s" % (name,)
38 print self.usage(name)
39 raise WrongOptions
40
41 paths = []
42 if len(args) == 0:
43 print "Wrong number of arguments: %d" % (len(args),)
44 print self.usage(name)
45 raise WrongOptions
46
47 while True:
48 result = raw_input("Really delete %d resource(s) [y/n]: " % (len(args),))
49 if readline.get_current_history_length():
50 readline.remove_history_item(readline.get_current_history_length() - 1)
51 if not result:
52 continue
53 if result[0] == "n":
54 return True
55 elif result[0] == "y":
56 break
57
58 for arg in args:
59 path = arg
60 if not path.startswith("/"):
61 path = os.path.join(self.shell.wd, path)
62 paths.append(path)
63
64 resource = URL(url=path)
65 self.shell.account.session.deleteResource(resource)
66
67 return True
68
71
73 return """Usage: %s PATH *[PATH]
74 PATH is a relative or absolute path.
75
76 """ % (name,)
77
79 return "Deletes one or more resources."
80