aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2024-04-10 20:04:28 +0200
committerThéo de la Hogue2024-04-10 20:04:28 +0200
commitbe59d476d3ff5810da583efe2ac4c62b4294f663 (patch)
tree46c6eed1e628090f2f37ecf2539cf0bcd21ce3a5
parentad922eb19e45c5669ea9536a3a2a88d79da496c9 (diff)
downloadargaze-be59d476d3ff5810da583efe2ac4c62b4294f663.zip
argaze-be59d476d3ff5810da583efe2ac4c62b4294f663.tar.gz
argaze-be59d476d3ff5810da583efe2ac4c62b4294f663.tar.bz2
argaze-be59d476d3ff5810da583efe2ac4c62b4294f663.tar.xz
Catching case where working directory is not set.
-rw-r--r--src/argaze/DataFeatures.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/argaze/DataFeatures.py b/src/argaze/DataFeatures.py
index af18c3b..68afbca 100644
--- a/src/argaze/DataFeatures.py
+++ b/src/argaze/DataFeatures.py
@@ -39,8 +39,14 @@ WORKING_DIRECTORY = [None]
def get_working_directory() -> str:
"""Get global working directory."""
- return WORKING_DIRECTORY[0]
+ if WORKING_DIRECTORY[0] is not None:
+
+ return WORKING_DIRECTORY[0]
+
+ else:
+
+ raise RuntimeError('No working directory')
def set_working_directory(working_directory: str):
"""Set global working directory."""
@@ -123,7 +129,8 @@ def from_json(filepath: str) -> any:
logging.debug('DataFeatures.from_json')
# Edit working directory once
- if get_working_directory() is None:
+ if WORKING_DIRECTORY[0] is None:
+
set_working_directory(os.path.dirname(os.path.abspath(filepath)))
logging.debug('\t> set global working directory as %s', get_working_directory())