diff options
-rw-r--r-- | src/argaze/DataFeatures.py | 11 |
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()) |