From 63aefc1c46ea0e747f52e88923e438266cdf80d3 Mon Sep 17 00:00:00 2001 From: Cas Cremers Date: Fri, 21 Jan 2011 17:38:14 +0100 Subject: [PATCH] BUGFIX: makedirs wasn't working as expected, reverting to builtin. --- gui/Scyther/Misc.py | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/gui/Scyther/Misc.py b/gui/Scyther/Misc.py index 494e17e..340e33c 100644 --- a/gui/Scyther/Misc.py +++ b/gui/Scyther/Misc.py @@ -64,7 +64,7 @@ def sorted(li): return result -# ensurePath: does what os.makedirs should do. +# ensurePath: wraps os.makedirs def ensurePath(pt): """ Make sure the path exists: if not, create the directories one by one @@ -75,27 +75,9 @@ def ensurePath(pt): It ensures this by doing the procedure for "dog", then "dog/cat", etc... """ - ptn = os.path.normpath(pt) - - # First we see what needs to exist overall - todo = [ptn] - tail = "x" - while len(tail) > 0: - (head,tail) = os.path.split(ptn) - if len(head) > 0: - todo.append(head) - ptn = head - else: - break - - # Reverse list: path prefixes first - todo.reverse() - - # Create bottom-up - for pt in todo: - if not os.path.isdir(pt): - # Note that os.path.exists(pt) may still hold. In this case the next command will cause an error. - os.mkdir(pt) + if not os.path.isdir(pt): + # Note that os.path.exists(pt) may still hold. In this case the next command will cause an error. + os.makedirs(pt) # path