From 1031b64eed26855c6ca44cfd1e819abf3c8df975 Mon Sep 17 00:00:00 2001 From: aeoranday Date: Wed, 14 Feb 2024 18:22:32 +0100 Subject: [PATCH] --overwrite bug fix on mkdir logic. --- apps/ta_dump.py | 4 +++- apps/tp_dump.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/ta_dump.py b/apps/ta_dump.py index 8d857ce..8388dba 100644 --- a/apps/ta_dump.py +++ b/apps/ta_dump.py @@ -399,7 +399,9 @@ def main(): plot_iter += 1 plot_dir = f"{data.run_id}-{data.file_index}_figures_{plot_iter:04}" print(f"Saving outputs to ./{plot_dir}/") - if not overwrite: # Can only create new dirs. + # If overwriting and it does exist, don't need to make it. + # So take the inverse to mkdir. + if not (overwrite and os.path.isdir(plot_dir)): os.mkdir(plot_dir) os.chdir(plot_dir) diff --git a/apps/tp_dump.py b/apps/tp_dump.py index 01e67a8..ed6aa92 100644 --- a/apps/tp_dump.py +++ b/apps/tp_dump.py @@ -381,7 +381,9 @@ def main(): plot_iter += 1 plot_dir = f"{data.run_id}-{data.file_index}_figures_{plot_iter:04}" print(f"Saving outputs to ./{plot_dir}/") - if not overwrite: # Can only create new dirs. + # If overwriting and it does exist, don't need to make it. + # So take the inverse to mkdir. + if not (overwrite and os.path.isdir(plot_dir)): os.mkdir(plot_dir) os.chdir(plot_dir)