Commit 885cdd00 authored by Amir MOHAMMADI's avatar Amir MOHAMMADI

create_directories_safe: use the new exist_ok flag in os.makedirs.

parent 8c178351
Pipeline #38382 passed with stage
in 5 minutes and 21 seconds
......@@ -97,17 +97,10 @@ def create_directories_safe(directory, dryrun=False):
``dryrun`` : bool
Only ``print`` the command to console, but do not execute it.
"""
try:
if dryrun:
print("[dry-run] mkdir -p '%s'" % directory)
else:
if directory and not os.path.exists(directory):
os.makedirs(directory)
except OSError as exc: # Python >2.5
import errno
if exc.errno != errno.EEXIST:
raise
if dryrun:
print("[dry-run] mkdir -p '%s'" % directory)
else:
os.makedirs(directory, exist_ok=True)
def load(inputs):
......
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