Revision 76e5f8b5 lib/utils.py
b/lib/utils.py | ||
---|---|---|
365 | 365 |
# as efficient. |
366 | 366 |
if mkdir and err.errno == errno.ENOENT: |
367 | 367 |
# Create directory and try again |
368 |
dirname = os.path.dirname(new) |
|
369 |
try: |
|
370 |
os.makedirs(dirname, mode=mkdir_mode) |
|
371 |
except OSError, err: |
|
372 |
# Ignore EEXIST. This is only handled in os.makedirs as included in |
|
373 |
# Python 2.5 and above. |
|
374 |
if err.errno != errno.EEXIST or not os.path.exists(dirname): |
|
375 |
raise |
|
368 |
Makedirs(os.path.dirname(new)) |
|
376 | 369 |
|
377 | 370 |
return os.rename(old, new) |
378 | 371 |
|
379 | 372 |
raise |
380 | 373 |
|
381 | 374 |
|
375 |
def Makedirs(path, mode=0750): |
|
376 |
"""Super-mkdir; create a leaf directory and all intermediate ones. |
|
377 |
|
|
378 |
This is a wrapper around C{os.makedirs} adding error handling not implemented |
|
379 |
before Python 2.5. |
|
380 |
|
|
381 |
""" |
|
382 |
try: |
|
383 |
os.makedirs(path, mode) |
|
384 |
except OSError, err: |
|
385 |
# Ignore EEXIST. This is only handled in os.makedirs as included in |
|
386 |
# Python 2.5 and above. |
|
387 |
if err.errno != errno.EEXIST or not os.path.exists(path): |
|
388 |
raise |
|
389 |
|
|
390 |
|
|
382 | 391 |
def ResetTempfileModule(): |
383 | 392 |
"""Resets the random name generator of the tempfile module. |
384 | 393 |
|
Also available in: Unified diff