From aa3a5774beaa7ad6a752169c66e97ddb4bdc8983 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 9 Aug 2009 16:32:19 +0200 Subject: [PATCH] Added a simple utility function for simulating mkdir -p. --- t/moe/util.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 t/moe/util.py 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 -- 2.39.2