3 Shell utilities. Additional to shutil.py (standard library module).
7 from __future__ import print_function
11 mkhier_error = "m_shutil.mkhier_error"
13 def mkhier(path): # Python implementation of UNIX' mkdir -p /path/to/dir
14 if os.path.isdir(path):
15 return # It's Ok to have the directory already created
17 if os.path.exists(path):
18 raise mkhier_error("`%s' is file" % path)
20 list_dirs = path.split(os.sep)
22 for i in range(0, len(list_dirs)):
23 new_path = os.sep.join(list_dirs[0:i+1])
24 if (new_path != '') and (not os.path.exists(new_path)):
25 #print("Making", new_path)
35 mkhier("I.AM/creating/TEST/dir")
37 if __name__ == "__main__":