PageRenderTime 17ms CodeModel.GetById 9ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/Demo/scripts/makedir.py

http://unladen-swallow.googlecode.com/
Python | 21 lines | 11 code | 5 blank | 5 comment | 6 complexity | 62b6859e2e5410b5e20541f7b7da075d MD5 | raw file
 1#! /usr/bin/env python
 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
 8import sys, os
 9
10def main():
11    for p in sys.argv[1:]:
12        makedirs(p)
13
14def makedirs(p):
15    if p and not os.path.isdir(p):
16        head, tail = os.path.split(p)
17        makedirs(head)
18        os.mkdir(p, 0777)
19
20if __name__ == "__main__":
21    main()