Skip to content

Commit

Permalink
Merge remote-tracking branch 'nlessmann/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianIsensee committed Nov 18, 2020
2 parents c73f07d + 9649545 commit d4dcedc
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions batchgenerators/utilities/file_and_folder_operations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import pathlib
import pickle
import json

Expand Down Expand Up @@ -33,16 +34,7 @@ def subfiles(folder, join=True, prefix=None, suffix=None, sort=True):


def maybe_mkdir_p(directory):
directory = os.path.abspath(directory)
splits = directory.split("/")[1:]
for i in range(0, len(splits)):
if not os.path.isdir(os.path.join("/", *splits[:i+1])):
try:
os.mkdir(os.path.join("/", *splits[:i+1]))
except FileExistsError:
# this can sometimes happen when two jobs try to create the same directory at the same time,
# especially on network drives.
print("WARNING: Folder %s already existed and does not need to be created" % directory)
pathlib.Path(directory).mkdir(parents=True, exist_ok=True)


def load_pickle(file, mode='rb'):
Expand Down

0 comments on commit d4dcedc

Please sign in to comment.