From 6fa9740cd61e6f86b72fa49198a13ce7ca3c1b6b Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Tue, 27 Aug 2024 12:08:56 -0400 Subject: [PATCH] Use pathlib to determine parent directory This assists with calling the script to generate a file in the current directory rather than another directory. No appreciable effects were observed on output files. Signed-off-by: Alex Nelson --- python/CASE2GeoJSON.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/CASE2GeoJSON.py b/python/CASE2GeoJSON.py index 56654b7..96a43a2 100644 --- a/python/CASE2GeoJSON.py +++ b/python/CASE2GeoJSON.py @@ -1,6 +1,7 @@ import json import sys from os.path import exists, isdir, isfile +from pathlib import Path from typing import List from geotypes import GeoRecord @@ -22,7 +23,7 @@ sys.exit(1) # Ensure the output directory exists -output_directory: str = output_filename[: output_filename.rfind("/")] +output_directory: str = str(Path(output_filename).parent.absolute()) if not exists(output_directory) and not isdir(output_directory): print(f"Directory not found: {output_directory}") sys.exit(1)