diff --git a/trud.py b/trud.py index 95a30e6e5c9dbfebfa9a04f557ba4efb17c625ff..87dfbf44f96b5fc2ede4084d3c33f356d8a220b1 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)