Mercurial > cpython-lru_cache-weakref
annotate Demo/scripts/makedir.py @ 54294:dba767bc3155 legacy-trunk
remove mention of old ctypes version
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 23 May 2009 20:59:09 +0000 |
| parents | 487280cf71b9 |
| children | 7d16b42fcdbd |
| rev | line source |
|---|---|
|
4573
73758db2f464
/usr/local/bin/python -> /usr/bin/env python
Guido van Rossum <guido@python.org>
parents:
1269
diff
changeset
|
1 #! /usr/bin/env python |
| 875 | 2 |
| 3 # Like mkdir, but also make intermediate directories if necessary. | |
| 4 # It is not an error if the given directory already exists (as long | |
| 5 # as it is a directory). | |
| 6 # Errors are not treated specially -- you just get a Python exception. | |
| 7 | |
| 8 import sys, os | |
| 9 | |
| 10 def main(): | |
|
32735
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
10949
diff
changeset
|
11 for p in sys.argv[1:]: |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
10949
diff
changeset
|
12 makedirs(p) |
| 875 | 13 |
| 14 def makedirs(p): | |
|
32735
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
10949
diff
changeset
|
15 if p and not os.path.isdir(p): |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
10949
diff
changeset
|
16 head, tail = os.path.split(p) |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
10949
diff
changeset
|
17 makedirs(head) |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
10949
diff
changeset
|
18 os.mkdir(p, 0777) |
| 875 | 19 |
|
33456
487280cf71b9
Add 'if __name__ == "__main__":' to files already as a usable as a module.
Johannes Gijsbers <jlg@dds.nl>
parents:
32735
diff
changeset
|
20 if __name__ == "__main__": |
|
487280cf71b9
Add 'if __name__ == "__main__":' to files already as a usable as a module.
Johannes Gijsbers <jlg@dds.nl>
parents:
32735
diff
changeset
|
21 main() |
