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 import os
20 import getopt
21 import shlex
22
24
28
30 opts, args = getopt.getopt(shlex.split(options), '')
31 if len(opts) or len(args) != 1:
32 print self.usage(name)
33 raise WrongOptions()
34
35 newpath = args[0]
36 oldpath = self.shell.wd
37 result = True
38
39 if newpath == "..":
40 result = self.shell.setWD(os.path.dirname(oldpath))
41 elif newpath == ".":
42 pass
43 elif newpath.startswith("/"):
44 result = self.shell.setWD(newpath)
45 else:
46 result = self.shell.setWD(os.path.normpath(os.path.join(oldpath, newpath)))
47
48 if not result:
49 print "%s: %s No such directory" % (name, options,)
50
51 return result
52
55
57 return """Usage: %s PATH
58 PATH is a relative or absolute path.
59 """ % (name,)
60
62 return "Change working directory."
63