2from typing
import Any, Dict, List
9 def __init__(self, configuration_file_name: str):
10 """Configuration handler object, essentially a wrapper around a conffwk.Configuration object
13 configuration_file_name -- name of the configuration .database.xml file to open
25 '''Opens configuration object safely '''
26 if not os.path.isfile(configuration_file_name):
27 raise Exception(f
"Cannot find file: {configuration_file_name}")
31 except Exception
as e:
37 """Adds all loaded dals to self._loaded_dals
47 """For a given configuration object, return all related objects
50 conf_object -- Any DAL object
53 List of related objects
60 for rel, rel_info
in relations.items():
61 rel_val = getattr(conf_object, rel)
63 if not isinstance(rel_val, list):
66 relations_list.append({rel: [v
for v
in rel_val
if v
is not None],
'rel_info': rel_info})
71 """Get all configuration objects of a given class
74 conf_class -- Coniguration class to get objects of
77 List of configuration objects of the given class
82 """Gets all classes + objects of that class in the configuration
85 dictionary of class : dal objects
91 """Get all related to classes to a given input class
94 class_id -- Name of class
97 List of all related classses
102 inherited_classes = [class_
for class_
in self.
_configuration.classes()\
104 return inherited_classes
109 """Access the underlying configuration object
113 @configuration.setter
115 """dummy method in case I try to do something silly
117 raise NotImplementedError(f
"Configuration object is not mutable, please create new object")
121 """List of loaded in dals
126 """Get a particular configuration object
129 class_id -- Class name
130 uid -- Unique object ID
133 DAL object satisfying the input
138 """Commit changes to the database
141 update_message -- Add message to the update
147 """Lists the total number of loaded objects
153 """Add new configuration object
156 class_id -- Class name
157 uid -- Unique object ID
165 """Destroy a configuration object
168 class_id -- class name
169 uid -- unique object ID
177 """Modify TODO: EDIT THIS
179 :param class_id: _description_
180 :type class_id: _type_
181 :param uid: _description_
183 :param relationship_name: _description_
184 :type relationship_name: str
185 :param updated_value: _description_
186 :type updated_value: _type_
187 :param append: _description_, defaults to False
188 :type append: bool, optional
195 for relations
in rel_list:
197 if list(relations.keys())[0] != relationship_name:
202 raise Exception(updated_value)
206 if append
and relations[
'rel_info'][
'multivalue']:
207 rel = list(relations.items)[0]
208 rel.append(updated_value)
210 elif relations[
'rel_info'][
'multivalue']:
211 rel = [updated_value]
216 setattr(selected_dal, relationship_name, rel)
222 raise RuntimeError(f
"Cannot find relationship with name {relationship_name}")
Dict[str, Any] get_all_conf_classes(self)
destroy_conf_obj(self, str class_id, str uid)
add_new_conf_obj(self, str class_id, str uid)
conffwk.Configuration configuration(self)
get_conf_objects_class(self, str conf_class)
conffwk.Configuration __open_configuration(self, str configuration_file_name)
List[Any] get_relationships_for_conf_object(self, conf_object)
__init__(self, str configuration_file_name)
conffwk.Configuration _configuration
List[str] get_related_classes(self, str class_id)
get_obj(self, str class_id, str uid)
None __cache_all_conf_objects(self)
commit(self, str update_message)
List[str] get_inherited_classes(self, str class_id)
modify_relationship(self, class_id, uid, str relationship_name, updated_value, bool append=False)