Commit cd1486ff authored by Greg Ward's avatar Greg Ward

More tweaks to 'mkpath()':

  - deal with empty tail from os.path.split() (eg. from trailing slash,
    or backslash, or whatever)
  - check PATH_CREATED hash inside loop as well
parent 3868eb97
...@@ -43,6 +43,8 @@ def mkpath (name, mode=0777, verbose=0, dry_run=0): ...@@ -43,6 +43,8 @@ def mkpath (name, mode=0777, verbose=0, dry_run=0):
return return
(head, tail) = os.path.split (name) (head, tail) = os.path.split (name)
if not tail: # in case 'name' has trailing slash
(head, tail) = os.path.split (head)
tails = [tail] # stack of lone dirs to create tails = [tail] # stack of lone dirs to create
while head and tail and not os.path.isdir (head): while head and tail and not os.path.isdir (head):
...@@ -59,6 +61,9 @@ def mkpath (name, mode=0777, verbose=0, dry_run=0): ...@@ -59,6 +61,9 @@ def mkpath (name, mode=0777, verbose=0, dry_run=0):
for d in tails: for d in tails:
#print "head = %s, d = %s: " % (head, d), #print "head = %s, d = %s: " % (head, d),
head = os.path.join (head, d) head = os.path.join (head, d)
if PATH_CREATED.get (head):
continue
if verbose: if verbose:
print "creating", head print "creating", head
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment