From: Martin Mares Date: Sun, 9 Aug 2009 14:32:19 +0000 (+0200) Subject: Added a simple utility function for simulating mkdir -p. X-Git-Tag: python-dummy-working~89 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=aa3a5774beaa7ad6a752169c66e97ddb4bdc8983;p=moe.git Added a simple utility function for simulating mkdir -p. --- diff --git a/t/moe/util.py b/t/moe/util.py new file mode 100644 index 0000000..801d2c7 --- /dev/null +++ b/t/moe/util.py @@ -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