From 33134b3ea37d478093adca34fcbdc36ef7e1ddf2 Mon Sep 17 00:00:00 2001 From: Michael Boniface <m.j.boniface@soton.ac.uk> Date: Thu, 13 Feb 2025 18:25:18 +0000 Subject: [PATCH] changed directory checks for this script to focus on maps directory and not full build directory that's required for the other procesign scripts --- trud.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/trud.py b/trud.py index 95a30e6..87dfbf4 100644 --- a/trud.py +++ b/trud.py @@ -215,23 +215,26 @@ def create_build_directories(build_dir='build'): """Create build directories.""" build_path = Path(build_dir) + if not build_path.exists(): + build_path.mkdir(parents=True, exist_ok=True) + # Check if build directory exists - create_build_dirs = False - if build_path.exists() and build_path.is_dir(): - user_input = input(f"The build directory {build_path} already exists. Do you want to delete and recreate all data? (y/n): ").strip().lower() + maps_path = build_path / 'maps' + create_map_dirs = False + if maps_path.exists(): + user_input = input(f"The map directory {maps_path} already exists. Do you want to download and process trud data again? (y/n): ").strip().lower() if user_input == "y": # delete all build files - shutil.rmtree(build_path) - create_build_dirs = True + shutil.rmtree(maps_path) + create_map_dirs = True + elif user_input == "n": + print("Exiting TRUD processing") + sys.exit(0) else: - create_build_dirs = True - - if create_build_dirs: - # create build directory - build_path.mkdir(parents=True, exist_ok=True) + create_map_dirs = True + if create_map_dirs: # create maps directories - maps_path = build_path / 'maps' maps_path.mkdir(parents=True, exist_ok=True) maps_download_path = maps_path / 'downloads' maps_download_path.mkdir(parents=True, exist_ok=True) -- GitLab