From 458120dd40db6b4df55a4e96b650e16798ef06a0 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Tue, 3 May 2011 11:25:13 +0000 Subject: add hg and python --- sys/src/cmd/python/Demo/scripts/makedir.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 sys/src/cmd/python/Demo/scripts/makedir.py (limited to 'sys/src/cmd/python/Demo/scripts/makedir.py') diff --git a/sys/src/cmd/python/Demo/scripts/makedir.py b/sys/src/cmd/python/Demo/scripts/makedir.py new file mode 100755 index 000000000..f70facd08 --- /dev/null +++ b/sys/src/cmd/python/Demo/scripts/makedir.py @@ -0,0 +1,21 @@ +#! /usr/bin/env python + +# Like mkdir, but also make intermediate directories if necessary. +# It is not an error if the given directory already exists (as long +# as it is a directory). +# Errors are not treated specially -- you just get a Python exception. + +import sys, os + +def main(): + for p in sys.argv[1:]: + makedirs(p) + +def makedirs(p): + if p and not os.path.isdir(p): + head, tail = os.path.split(p) + makedirs(head) + os.mkdir(p, 0777) + +if __name__ == "__main__": + main() -- cgit v1.2.3