From a95d6e7f8a17ef13c09d1dafa78951933e3ea924 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Thu, 8 Apr 2021 21:40:50 +0200 Subject: [PATCH] Improved configuration to handle absolute paths in add_json_file --- src/cpl/configuration/configuration.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/cpl/configuration/configuration.py b/src/cpl/configuration/configuration.py index e006f0a5..907ad041 100644 --- a/src/cpl/configuration/configuration.py +++ b/src/cpl/configuration/configuration.py @@ -285,14 +285,17 @@ class Configuration(ConfigurationABC): exit() def add_json_file(self, name: str, optional: bool = None, output: bool = True, path: str = None): - path_root = self._application_environment.working_directory - if path is not None: - path_root = path - - if str(path_root).endswith('/') and not name.startswith('/'): - file_path = f'{path_root}{name}' + if os.path.isabs(name): + file_path = name else: - file_path = f'{path_root}/{name}' + path_root = self._application_environment.working_directory + if path is not None: + path_root = path + + if str(path_root).endswith('/') and not name.startswith('/'): + file_path = f'{path_root}{name}' + else: + file_path = f'{path_root}/{name}' if not os.path.isfile(file_path): if optional is not True: