3 Shell utilities. Additional to shutil.py (standard library module).
10 mkhier_error = "m_shutil.mkhier_error"
12 def mkhier(path): # Python implementation of UNIX' mkdir -p /path/to/dir
13 if os.path.isdir(path):
14 return # It's Ok to have the directory already created
16 if os.path.exists(path):
17 raise mkhier_error, "`%s' is file" % path
19 list_dirs = string.split(path, os.sep)
21 for i in range(0, len(list_dirs)):
22 new_path = string.join(list_dirs[0:i+1], os.sep)
23 if (new_path <> '') and (not os.path.exists(new_path)):
24 #print "Making", new_path
34 mkhier("I.AM/creating/TEST/dir")
36 if __name__ == "__main__":