Skip to content

Commit

Permalink
Add exist_ok to os.makedirs (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
kahst committed May 10, 2022
1 parent 2ea1949 commit d4edfdd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def analyzeFile(item):

# Make directory if it doesn't exist
if len(os.path.dirname(cfg.OUTPUT_PATH)) > 0 and not os.path.exists(os.path.dirname(cfg.OUTPUT_PATH)):
os.makedirs(os.path.dirname(cfg.OUTPUT_PATH))
os.makedirs(os.path.dirname(cfg.OUTPUT_PATH), exist_ok=True)

if os.path.isdir(cfg.OUTPUT_PATH):
rpath = fpath.replace(cfg.INPUT_PATH, '')
Expand Down
2 changes: 1 addition & 1 deletion segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def extractSegments(item):
# Make output path
outpath = os.path.join(cfg.OUTPUT_PATH, seg['species'])
if not os.path.exists(outpath):
os.makedirs(outpath)
os.makedirs(outpath, exist_ok=True)

# Save segment
seg_name = '{:.3f}_{}_{}.wav'.format(seg['confidence'], seg_cnt, seg['audio'].split(os.sep)[-1].rsplit('.', 1)[0])
Expand Down

0 comments on commit d4edfdd

Please sign in to comment.