A simple function to change the directory. Including handling spaces, quotes etc.
(l1)
| 58 | return newline |
| 59 | |
| 60 | def chdir(l1): |
| 61 | """A simple function to change the directory. |
| 62 | Including handling spaces, quotes etc.""" |
| 63 | l2 = l1 |
| 64 | if l1[0] == '\"' == l1[-1]: l2 = l1[1:-1] |
| 65 | if os.path.isdir(l2): |
| 66 | os.chdir(l2) |
| 67 | elif os.path.isdir(l2.strip()): |
| 68 | os.chdir(l2.strip()) |
| 69 | else: |
| 70 | print 'The system can\'t see directory ' + l1 |
| 71 | |
| 72 | |
| 73 |
no test coverage detected