Skip to content
Snippets Groups Projects
Commit 885cdd00 authored by Amir MOHAMMADI's avatar Amir MOHAMMADI
Browse files

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

parent 8c178351
No related branches found
No related tags found
1 merge request!29create_directories_safe: use the new exist_ok flag in os.makedirs.
Pipeline #38382 passed
......@@ -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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment