]> mj.ucw.cz Git - eval.git/commitdiff
Added a simple utility function for simulating mkdir -p.
authorMartin Mares <mj@ucw.cz>
Sun, 9 Aug 2009 14:32:19 +0000 (16:32 +0200)
committerMartin Mares <mj@ucw.cz>
Sun, 9 Aug 2009 14:32:19 +0000 (16:32 +0200)
t/moe/util.py [new file with mode: 0644]

diff --git a/t/moe/util.py b/t/moe/util.py
new file mode 100644 (file)
index 0000000..801d2c7
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+
+import os
+import os.path
+
+def mkdir_tree(name):
+    try:
+       os.mkdir(name)  
+    except OSError, e:
+       if e.errno == os.errno.ENOENT:
+           head, tail = os.path.split(name)
+           mkdir_tree(head)
+           os.mkdir(name)
+       elif e.errno == os.errno.EEXIST:
+           pass
+       else:
+           raise e