Mercurial > cpython-lru_cache-weakref
annotate Demo/scripts/makedir.py @ 5817:48b94de85bf3 legacy-trunk
Extensive changes by AMK.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 17 Jul 1997 16:29:42 +0000 |
| parents | 73758db2f464 |
| children | 03530ea2148c |
| 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(): | |
| 11 for p in sys.argv[1:]: | |
| 12 makedirs(p) | |
| 13 | |
| 14 def makedirs(p): | |
| 15 if not os.path.isdir(p): | |
| 16 head, tail = os.path.split(p) | |
| 17 makedirs(head) | |
| 18 os.mkdir(p, 0777) | |
| 19 | |
| 20 main() |
