aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/argaze/DataFeatures.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/argaze/DataFeatures.py b/src/argaze/DataFeatures.py
index fe7a5ac..8ffc9d7 100644
--- a/src/argaze/DataFeatures.py
+++ b/src/argaze/DataFeatures.py
@@ -55,7 +55,7 @@ def set_working_directory(working_directory: str):
WORKING_DIRECTORY[0] = working_directory
-def get_class(class_path: str) -> object:
+def get_class(class_path: str) -> type:
"""Get class object from 'path.to.class' string.
Parameters:
@@ -109,7 +109,7 @@ def properties(cls) -> list:
return properties
-def from_json(configuration_filepath: str, patch_filepath: str = None) -> any:
+def from_json(filepath: str) -> any:
"""
Load object instance from .json file.
@@ -118,21 +118,24 @@ def from_json(configuration_filepath: str, patch_filepath: str = None) -> any:
Parameters:
configuration_filepath: path to json configuration file
- patch_filepath: path to json patch file to modify any configuration entries
"""
logging.debug('DataFeatures.from_json')
# Edit working directory once
if get_working_directory() is None:
- set_working_directory(os.path.dirname(os.path.abspath(configuration_filepath)))
+ set_working_directory(os.path.dirname(os.path.abspath(filepath)))
logging.debug('\t> set global working directory as %s', get_working_directory())
- # Load configuration from JSON file
- with open(configuration_filepath) as configuration_file:
+ # Open JSON file
+ with open(filepath) as configuration_file:
- object_data = json.load(configuration_file)
+ # Load unique object
+ object_class, object_data = json.load(configuration_file).popitem()
+
+ '''
+ # patch_filepath: path to json patch file to modify any configuration entries
# Apply patch to configuration if required
if patch_filepath is not None:
@@ -162,14 +165,11 @@ def from_json(configuration_filepath: str, patch_filepath: str = None) -> any:
return d
objects_data = update(object_data, patch_data)
-
- # Load unique object
- object_class, object_data = object_data.popitem()
+ '''
# Instanciate class
logging.debug('\t+ create %s object', object_class)
- # noinspection PyCallingNonCallable
return get_class(object_class)(**object_data)