PySimultan 0.4.22__py3-none-any.whl → 0.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. PySimultan2/__about__.py +1 -1
  2. PySimultan2/__init__.py +1 -0
  3. PySimultan2/data_model.py +185 -80
  4. PySimultan2/default_types.py +127 -21
  5. PySimultan2/files.py +55 -5
  6. PySimultan2/object_mapper.py +58 -7
  7. PySimultan2/resources/ComponentBuilder.dll +0 -0
  8. PySimultan2/resources/ComponentBuilder.runtimeconfig.json +2 -1
  9. PySimultan2/resources/ComponentBuilder.xml +47 -1
  10. PySimultan2/resources/SIMULTAN.AutoUpdate.Client.dll +0 -0
  11. PySimultan2/resources/SIMULTAN.AutoUpdate.DataTransferLibrary.dll +0 -0
  12. PySimultan2/resources/SIMULTAN.Lang.dll +0 -0
  13. PySimultan2/resources/SIMULTAN.Lang.xml +94 -7
  14. PySimultan2/resources/SIMULTAN.Plugins.dll +0 -0
  15. PySimultan2/resources/SIMULTAN.UI.dll +0 -0
  16. PySimultan2/resources/SIMULTAN.UI.xml +136 -43
  17. PySimultan2/resources/SIMULTAN.dll +0 -0
  18. PySimultan2/resources/SIMULTAN.xml +364 -97
  19. PySimultan2/resources/System.Collections.Immutable.dll +0 -0
  20. PySimultan2/resources/System.Reflection.Metadata.dll +0 -0
  21. PySimultan2/resources/System.Reflection.MetadataLoadContext.dll +0 -0
  22. PySimultan2/resources/componentmanager.user +0 -0
  23. PySimultan2/simultan_object.py +64 -15
  24. PySimultan2/taxonomy_maps.py +20 -12
  25. PySimultan2/type_setter_lookup.py +46 -33
  26. PySimultan2/utils.py +49 -14
  27. {pysimultan-0.4.22.dist-info → pysimultan-0.5.0.dist-info}/METADATA +2 -3
  28. {pysimultan-0.4.22.dist-info → pysimultan-0.5.0.dist-info}/RECORD +30 -32
  29. {pysimultan-0.4.22.dist-info → pysimultan-0.5.0.dist-info}/WHEEL +1 -1
  30. PySimultan2/resources/GeometryViewer.dll +0 -0
  31. PySimultan2/resources/GeometryViewer.dll.config +0 -42
  32. PySimultan2/resources/GeometryViewer.xml +0 -6425
  33. PySimultan2/resources/SitePlanner.dll +0 -0
  34. PySimultan2/resources/SitePlanner.dll.config +0 -11
  35. PySimultan2/resources/SitePlanner.xml +0 -2736
  36. {pysimultan-0.4.22.dist-info → pysimultan-0.5.0.dist-info}/licenses/LICENSE.txt +0 -0
@@ -3,8 +3,10 @@ import json
3
3
 
4
4
  from copy import copy
5
5
  from weakref import WeakSet
6
+ from functools import lru_cache
6
7
  from . import utils
7
8
  from numpy import ndarray
9
+ from pandas import DataFrame
8
10
  import colorlog
9
11
  from typing import Union, Optional, Any
10
12
 
@@ -80,6 +82,7 @@ class MetaMock(type):
80
82
  init_dict['object_mapper'] = cls._object_mapper
81
83
  init_dict['data_model'] = data_model
82
84
  init_dict['wrapped_obj'] = wrapped_obj
85
+
83
86
  obj.__init__(*args, **init_dict)
84
87
 
85
88
  # for key, value in kwargs.items():
@@ -110,7 +113,14 @@ class SimultanObject(object, metaclass=MetaMock):
110
113
 
111
114
  @classproperty
112
115
  def _cls_instances_dict(cls) -> dict[SimId, 'SimultanObject']:
113
- return dict(zip([x.id for x in cls._cls_instances], [x for x in cls._cls_instances]))
116
+ if cls._cls_instances_dict_cache is None:
117
+ cls._cls_instances_dict_cache = dict(zip([x.id for x in cls._cls_instances], [x for x in cls._cls_instances]))
118
+
119
+ elif len(cls._cls_instances) == 0:
120
+ return {}
121
+ elif len(cls._cls_instances) != len(cls._cls_instances_dict_cache):
122
+ cls._cls_instances_dict_cache = dict(zip([x.id for x in cls._cls_instances], [x for x in cls._cls_instances]))
123
+ return cls._cls_instances_dict_cache
114
124
 
115
125
  @classproperty
116
126
  def cls_instances(cls) -> list['SimultanObject']:
@@ -150,7 +160,11 @@ class SimultanObject(object, metaclass=MetaMock):
150
160
  self._wrapped_obj: Union[SimComponent, None] = kwargs.get('wrapped_obj', None)
151
161
  self.__obj_init__: bool = kwargs.get('__obj_init__', False)
152
162
  self._data_model: Union[DataModel, None] = kwargs.get('data_model', config.get_default_data_model())
153
- self._object_mapper: Union[PythonMapper, None] = kwargs.get('object_mapper', config.get_default_mapper())
163
+
164
+ object_mapper = kwargs.get('object_mapper', None)
165
+ if object_mapper is None:
166
+ object_mapper = config.get_default_mapper()
167
+ self._object_mapper: Union[PythonMapper, None] = object_mapper
154
168
  self.name: str = kwargs.get('name', '')
155
169
 
156
170
  self.__property_cache__ = {}
@@ -192,15 +206,6 @@ class SimultanObject(object, metaclass=MetaMock):
192
206
  if self._wrapped_obj is not None:
193
207
  return [x.Target.Key for x in self._wrapped_obj.Slots]
194
208
 
195
- @property
196
- def json_ref(self):
197
- return {"_ref": {
198
- "$ref": self.__class__.__name__,
199
- "$id": {
200
- "$oid": self.id_str
201
- }
202
- }}
203
-
204
209
  @property
205
210
  def name(self) -> str:
206
211
  if self._wrapped_obj is not None:
@@ -275,7 +280,7 @@ class SimultanObject(object, metaclass=MetaMock):
275
280
 
276
281
  def add_subcomponent(self, subcomponent: Union['SimultanObject', SimComponent],
277
282
  slot: SimTaxonomyEntryReference = None,
278
- slot_extension: str = None):
283
+ slot_extension: str = None) -> 'SimultanObject':
279
284
 
280
285
  if isinstance(subcomponent, SimComponent):
281
286
  comp_to_add = subcomponent
@@ -292,6 +297,8 @@ class SimultanObject(object, metaclass=MetaMock):
292
297
  slot_extension,
293
298
  slot)
294
299
 
300
+ return comp_to_add
301
+
295
302
  def remove_subcomponent(self, subcomponent: Union['SimultanObject', SimComponent]):
296
303
  if isinstance(subcomponent, SimComponent):
297
304
  utils.remove_sub_component(self._wrapped_obj, subcomponent)
@@ -387,18 +394,20 @@ class SimultanObject(object, metaclass=MetaMock):
387
394
  setattr(comp_prop, prop, value)
388
395
  return comp_prop
389
396
 
390
- def copy(self):
397
+ def copy(self,
398
+ name: str = None):
391
399
  """
392
400
  Create a copy of the object including all properties. The properties are copied by reference.
393
401
  :return:
394
402
  """
395
- new_copy = self.__class__(data_model=self._data_model,
403
+ new_copy = self.__class__(name=name if name is not None else f'Copy of {self.name}',
404
+ data_model=self._data_model,
396
405
  object_mapper=self._object_mapper)
397
406
 
398
407
  for content in self._taxonomy_map.content:
399
408
  setattr(new_copy, content.property_name, getattr(self, content.property_name))
400
409
 
401
- new_copy.name = f'Copy of {self.name}'
410
+ # new_copy.name = name if name is not None else f'Copy of {self.name}'
402
411
 
403
412
  if self.associated_geometry:
404
413
  for geo in self.associated_geometry:
@@ -406,6 +415,46 @@ class SimultanObject(object, metaclass=MetaMock):
406
415
 
407
416
  return new_copy
408
417
 
418
+ def remove_from_datamodel(self):
419
+ self._data_model.remove_component(self)
420
+ self.__class__.cls_instances.remove(self)
421
+
422
+ def to_json(self) -> dict:
423
+
424
+ from .default_types import ComponentList, ComponentDictionary
425
+
426
+ obj_dict = {
427
+ str(self.id): {'name': self.name},
428
+ 'taxonomies': self.taxonomy_keys,
429
+ }
430
+
431
+ for content in self._taxonomy_map.content:
432
+ val = getattr(self, content.property_name)
433
+
434
+ if hasattr(val, 'json_ref'):
435
+ obj_dict[content.text_or_key] = val.json_ref()
436
+ elif isinstance(val, (list, ComponentList)):
437
+ obj_dict[content.text_or_key] = [v.json_ref() if hasattr(v, 'json_ref') else v for v in val]
438
+ elif isinstance(val, (dict, ComponentDictionary)):
439
+ obj_dict[content.text_or_key] = {k: v.json_ref() if hasattr(v, 'json_ref') else v for k, v in val.items()}
440
+ elif isinstance(val, ndarray):
441
+ obj_dict[content.text_or_key] = val.tolist()
442
+ elif isinstance(val, DataFrame):
443
+ obj_dict[content.text_or_key] = val.to_dict()
444
+ else:
445
+ obj_dict[content.text_or_key] = val
446
+
447
+ return obj_dict
448
+
449
+ def json_ref(self):
450
+ return {"$ref": {
451
+ "$type": 'Component',
452
+ "$taxonomies": self.taxonomy_keys,
453
+ "$id": {'local_id': self.id.LocalId,
454
+ 'global_id': str(self.id.GlobalId)
455
+ }
456
+ }
457
+ }
409
458
 
410
459
  # def to_json(self):
411
460
  #
@@ -4,6 +4,7 @@ from ruamel.yaml import YAML, yaml_object, add_representer
4
4
  from . import yaml
5
5
 
6
6
  from typing import TYPE_CHECKING, Optional, Union, Literal
7
+
7
8
  if TYPE_CHECKING:
8
9
  from .data_model import DataModel
9
10
 
@@ -15,7 +16,9 @@ class Content(object):
15
16
 
16
17
  yaml_tag = u'!Content'
17
18
 
18
- def __init__(self, *args, **kwargs):
19
+ def __init__(self,
20
+ *args,
21
+ **kwargs):
19
22
  """
20
23
  Define a content/parameter/property of a taxonomy entry in the taxonomy map.
21
24
 
@@ -27,8 +30,7 @@ class Content(object):
27
30
  * *type* (``str``) -- type of the content/parameter/property
28
31
  * *unit* (``str``) -- unit of the content/parameter/property
29
32
  * *documentation* (``str``) -- documentation of the content/parameter/property
30
- * *component_policy* (``str``) -- component add policy of the content/parameter/property, '
31
- reference' or 'subcomponent'
33
+ * *component_policy* (``str``) -- component add policy of the content/parameter/property, 'reference' or 'subcomponent'
32
34
  """
33
35
 
34
36
  self.name: str = kwargs.get('name', kwargs.get('text_or_key'))
@@ -89,11 +91,14 @@ class TaxonomyMap(object):
89
91
  self._content_dict = {}
90
92
  self._parameter_taxonomy_entry_dict = {}
91
93
 
92
- self.taxonomy_name = kwargs.get('taxonomy_name', kwargs.get('taxonomy_key', None))
93
- self.taxonomy_key = kwargs.get('taxonomy_key', None)
94
+ self.taxonomy_name = kwargs.get('taxonomy_name', kwargs.get('taxonomy_key'))
95
+ self.taxonomy_key = kwargs.get('taxonomy_key')
94
96
 
95
- self.taxonomy_entry_name = kwargs.get('taxonomy_entry_name', kwargs.get('taxonomy_entry_key', None))
96
- self.taxonomy_entry_key = kwargs.get('taxonomy_entry_key', None)
97
+ if self.taxonomy_key == kwargs.get('taxonomy_entry_key'):
98
+ raise ValueError('taxonomy_key and taxonomy_entry_key must be different')
99
+
100
+ self.taxonomy_entry_name = kwargs.get('taxonomy_entry_name', kwargs.get('taxonomy_entry_key'))
101
+ self.taxonomy_entry_key = kwargs.get('taxonomy_entry_key')
97
102
 
98
103
  self.content = kwargs.get('content', [])
99
104
  self.documentation = kwargs.get('documentation', '')
@@ -128,8 +133,7 @@ class TaxonomyMap(object):
128
133
  @property
129
134
  def parameter_taxonomy_entry_dict(self):
130
135
  if not self._parameter_taxonomy_entry_dict:
131
- for content in self._content:
132
- self._parameter_taxonomy_entry_dict[content.property_name] = content.text_or_key
136
+ self._parameter_taxonomy_entry_dict = {content.property_name: content.text_or_key for content in self._content}
133
137
  return self._parameter_taxonomy_entry_dict
134
138
 
135
139
  def write(self, filename=None):
@@ -152,11 +156,13 @@ class TaxonomyMap(object):
152
156
  content._taxonomy_map = self
153
157
  self._content_dict = {}
154
158
 
155
- def get_or_create_simultan_taxonomy_entry(self, data_model: 'DataModel', create=True):
159
+ def get_or_create_simultan_taxonomy_entry(self,
160
+ data_model: 'DataModel',
161
+ create=True):
156
162
 
157
163
  if self._taxonomy_entries.get(data_model, None) is None:
158
164
 
159
- taxonomy_entries = data_model.get_taxonomy_entries()
165
+ taxonomy_entries = data_model.get_taxonomy_entries(taxonomy=self.taxonomy_key)
160
166
  if self.taxonomy_entry_key in taxonomy_entries.keys():
161
167
  self._taxonomy_entries[data_model] = taxonomy_entries[self.taxonomy_entry_key]
162
168
  elif create:
@@ -167,7 +173,9 @@ class TaxonomyMap(object):
167
173
  create=create))
168
174
  return self._taxonomy_entries[data_model]
169
175
 
170
- def get_or_create_simultan_taxonomy(self, data_model: 'DataModel', create=True):
176
+ def get_or_create_simultan_taxonomy(self,
177
+ data_model: 'DataModel',
178
+ create=True):
171
179
  if self._taxonomies.get(data_model, None) is None:
172
180
  self._taxonomies[data_model] = data_model.get_or_create_taxonomy(
173
181
  taxonomy_name=self.taxonomy_name,
@@ -1,11 +1,16 @@
1
+ from typing import Any
1
2
  import numpy as np
2
3
  import pandas as pd
4
+ import inspect
5
+ import enum
3
6
 
4
- from .utils import (SimComponent, SimultanObject, SimDoubleParameter, SimIntegerParameter, SimStringParameter,
7
+ from .utils import (SimComponent, SimDoubleParameter, SimIntegerParameter, SimStringParameter,
5
8
  SimBoolParameter, SimEnumParameter, SimMultiValueField3D, SimMultiValueBigTable, FileInfo,
6
9
  set_property_to_sim_component, set_property_to_parameter, set_property_to_value_field,
7
10
  set_property_to_file_info, set_property_to_list, set_property_to_dict)
8
11
 
12
+ from .simultan_object import SimultanObject, MetaMock
13
+
9
14
  from .default_types import ComponentList, ComponentDictionary
10
15
 
11
16
  from SIMULTAN.Data.Components import (ComponentWalker, SimComponent, SimBoolParameter, SimDoubleParameter,
@@ -14,46 +19,54 @@ from SIMULTAN.Data.Components import (ComponentWalker, SimComponent, SimBoolPara
14
19
  SimParameterOperations, SimComponentReference)
15
20
 
16
21
 
17
- lookup_dict = {None: lambda x: None,
18
- SimComponent: set_property_to_sim_component,
19
- SimultanObject: set_property_to_sim_component,
20
- SimDoubleParameter: set_property_to_parameter,
21
- SimIntegerParameter: set_property_to_parameter,
22
- SimStringParameter: set_property_to_parameter,
23
- SimBoolParameter: set_property_to_parameter,
24
- SimEnumParameter: set_property_to_parameter,
25
- SimMultiValueField3D: set_property_to_value_field,
26
- SimMultiValueBigTable: set_property_to_value_field,
27
- int: set_property_to_parameter,
28
- float: set_property_to_parameter,
29
- str: set_property_to_parameter,
30
- bool: set_property_to_parameter,
31
- FileInfo: set_property_to_file_info,
32
- list: set_property_to_list,
33
- tuple: set_property_to_list,
34
- set: set_property_to_list,
35
- dict: set_property_to_dict,
36
- ComponentDictionary: set_property_to_dict,
37
- ComponentList: set_property_to_list,
38
- np.ndarray: set_property_to_value_field,
39
- pd.DataFrame: set_property_to_value_field}
40
-
41
-
42
22
  class TypeSetterFcnLookupDict(object):
43
23
 
24
+ lookup_dict = {None: lambda x: None,
25
+ SimComponent: set_property_to_sim_component,
26
+ SimultanObject: set_property_to_sim_component,
27
+ SimDoubleParameter: set_property_to_parameter,
28
+ SimIntegerParameter: set_property_to_parameter,
29
+ SimStringParameter: set_property_to_parameter,
30
+ SimBoolParameter: set_property_to_parameter,
31
+ SimEnumParameter: set_property_to_parameter,
32
+ SimMultiValueField3D: set_property_to_value_field,
33
+ SimMultiValueBigTable: set_property_to_value_field,
34
+ int: set_property_to_parameter,
35
+ float: set_property_to_parameter,
36
+ str: set_property_to_parameter,
37
+ bool: set_property_to_parameter,
38
+ FileInfo: set_property_to_file_info,
39
+ list: set_property_to_list,
40
+ tuple: set_property_to_list,
41
+ set: set_property_to_list,
42
+ dict: set_property_to_dict,
43
+ enum.Enum: set_property_to_parameter,
44
+ enum.IntEnum: set_property_to_parameter,
45
+ enum.EnumType: set_property_to_parameter,
46
+ ComponentDictionary: set_property_to_sim_component,
47
+ ComponentList: set_property_to_list,
48
+ np.ndarray: set_property_to_value_field,
49
+ pd.DataFrame: set_property_to_value_field}
50
+
44
51
  def __getitem__(self, item: type):
45
- if item in lookup_dict:
46
- return lookup_dict[item]
47
- elif SimultanObject in item.__bases__:
52
+ bases = [item, *inspect.getmro(type(item))]
53
+
54
+ if SimultanObject in bases or MetaMock in bases:
48
55
  return set_property_to_sim_component
49
56
  else:
50
- return None
57
+ for base in bases:
58
+ if base in self.lookup_dict:
59
+ return self.lookup_dict[base]
60
+ return None
51
61
 
52
62
  def get(self,
53
- item: type,
54
- default=None):
55
- val = self.__getitem__(item)
63
+ item: Any,
64
+ default='_____'):
65
+
66
+ val = self.__getitem__(type(item))
56
67
  if val is None:
68
+ if default == '_____':
69
+ raise KeyError(f'No setter function found for type {type(item)}')
57
70
  return default
58
71
  else:
59
72
  return val
PySimultan2/utils.py CHANGED
@@ -62,7 +62,10 @@ class CircularReferenceResolver(object):
62
62
  circ_ref_resolver = CircularReferenceResolver()
63
63
 
64
64
 
65
- def create_python_object(wrapped_obj: SimComponent, cls: Type[SimultanObject], *args, **kwargs):
65
+ def create_python_object(wrapped_obj: SimComponent,
66
+ cls: Type[SimultanObject],
67
+ *args,
68
+ **kwargs):
66
69
  """
67
70
  Create a new mapped python object from a wrapped object
68
71
  :param wrapped_obj: wrapped object to create the python object from
@@ -104,6 +107,7 @@ def create_python_object(wrapped_obj: SimComponent, cls: Type[SimultanObject], *
104
107
  kwargs[content.text_or_key] = get_property(wrapped_obj=wrapped_obj,
105
108
  text_or_key=content.text_or_key,
106
109
  object_mapper=kwargs.get('object_mapper', None),
110
+ data_model=data_model
107
111
  )
108
112
 
109
113
  kwargs['name'] = wrapped_obj.Name
@@ -300,12 +304,16 @@ def create_sim_string_parameter(**kwargs) -> SimStringParameter:
300
304
  :return:
301
305
  """
302
306
 
303
- init_dict = ['slot', 'value']
307
+ try:
308
+ init_dict = ['slot', 'value']
304
309
 
305
- args = [x for x in [kwargs.get(key, None) for key in init_dict] if x is not None]
306
- args.append(SimParameterOperations(0).All)
310
+ args = [x for x in [kwargs.get(key, None) for key in init_dict] if x is not None]
311
+ args.append(SimParameterOperations(0).All)
307
312
 
308
- return SimStringParameter(*args)
313
+ return SimStringParameter(*args)
314
+ except Exception as e:
315
+ logger.error(f'Error creating string parameter: {e}\n{traceback.format_exc()}')
316
+ raise e
309
317
 
310
318
 
311
319
  def create_sim_bool_parameter(**kwargs) -> SimBoolParameter:
@@ -354,7 +362,7 @@ def create_parameter(value: Union[int, float, str, SimTaxonomyEntry] = 0,
354
362
  if type(value) is float:
355
363
  parameter_type = float
356
364
  elif type(value) is int:
357
- parameter_type = float
365
+ parameter_type = int
358
366
  elif type(value) is str:
359
367
  parameter_type = str
360
368
  elif type(value) is SimTaxonomyEntry:
@@ -548,6 +556,8 @@ def add_referenced_component(component: Union[SimComponent, SimultanObject],
548
556
  ref = SimComponentReference(new_slot, referenced_wrapped_obj._wrapped_obj)
549
557
  component_wrapped_obj.ReferencedComponents.Add(ref)
550
558
 
559
+ return
560
+
551
561
 
552
562
  def remove_referenced_component(component: Union[SimComponent, SimultanObject],
553
563
  referenced_component: Union[SimComponent, SimultanObject]):
@@ -625,7 +635,9 @@ def get_component_geometry(data_model, geometry_model, component) -> tuple[list[
625
635
  return points, edges, faces, volumes
626
636
 
627
637
 
628
- def create_simultan_component_for_taxonomy(cls, *args, **kwargs) -> SimComponent:
638
+ def create_simultan_component_for_taxonomy(cls: Type[SimultanObject],
639
+ *args,
640
+ **kwargs) -> SimComponent:
629
641
  """
630
642
  Create a new Simultan component for a taxonomy
631
643
  :param cls:
@@ -698,7 +710,8 @@ def get_property(prop_name: Optional[str] = None,
698
710
  text_or_key: Optional[str] = None,
699
711
  component=None,
700
712
  wrapped_obj=None,
701
- object_mapper=None):
713
+ object_mapper=None,
714
+ data_model=None) -> Any:
702
715
 
703
716
  if prop_name is None and text_or_key is None:
704
717
  raise ValueError('Either prop_name or text_or_key must be set.')
@@ -708,11 +721,14 @@ def get_property(prop_name: Optional[str] = None,
708
721
 
709
722
  if component is not None:
710
723
  obj = get_component_taxonomy_entry(component._wrapped_obj, text_or_key)
711
- data_model = component._data_model
724
+ if data_model is None:
725
+ data_model = component._data_model
712
726
  object_mapper = component._object_mapper
713
727
  else:
714
- data_model = config.get_default_data_model()
715
- obj = get_component_taxonomy_entry(wrapped_obj, text_or_key)
728
+ if data_model is None:
729
+ data_model = config.get_default_data_model()
730
+ obj = get_component_taxonomy_entry(wrapped_obj,
731
+ text_or_key)
716
732
 
717
733
  return get_obj_value(obj, data_model=data_model, object_mapper=object_mapper)
718
734
 
@@ -768,6 +784,8 @@ def get_obj_value(obj: Union[SimComponent, SimDoubleParameter, SimIntegerParamet
768
784
 
769
785
  if obj is None:
770
786
  return
787
+ elif isinstance(obj, SimultanObject):
788
+ return obj
771
789
  elif isinstance(obj, (int, float, str)):
772
790
  return obj
773
791
  elif type(obj) in type_convert_dict.keys():
@@ -924,7 +942,6 @@ def create_mapped_python_object(value: Any,
924
942
  data_model=data_model,
925
943
  object_mapper=object_mapper,
926
944
  add_to_data_model=add_to_data_model)
927
-
928
945
  # logger.debug(f'Created mapped python object {new_val} for {value}.')
929
946
  return new_val
930
947
  elif isinstance(value, dict):
@@ -944,6 +961,16 @@ def create_mapped_python_object(value: Any,
944
961
  elif isinstance(value, UnresolvedObject):
945
962
  return value.resolve()
946
963
  else:
964
+ sub_classes = [issubclass(x, value.__class__) for x in object_mapper.registered_classes.values()]
965
+ if sum(sub_classes) == 1:
966
+ key = list(object_mapper.registered_classes.keys())[sub_classes.index(True)]
967
+ mapped_cls = object_mapper.get_mapped_class(key)
968
+ new_val = mapped_cls(**value.__dict__,
969
+ data_model=data_model,
970
+ object_mapper=object_mapper,
971
+ add_to_data_model=add_to_data_model)
972
+ return new_val
973
+
947
974
  raise TypeError(f'Error creating mapped python object for {value}.')
948
975
 
949
976
 
@@ -1125,7 +1152,7 @@ def set_property_to_file_info(value: FileInfo,
1125
1152
  tag=taxonomy_entry)
1126
1153
 
1127
1154
 
1128
- def set_property_to_parameter(value: Union[int, float, str],
1155
+ def set_property_to_parameter(value: Union[int, float, str, Enum, bool],
1129
1156
  component: SimultanObject,
1130
1157
  prop_name: str,
1131
1158
  taxonomy_entry: SimTaxonomyEntry,
@@ -1145,6 +1172,9 @@ def set_property_to_parameter(value: Union[int, float, str],
1145
1172
 
1146
1173
  wrapped_obj = component._wrapped_obj
1147
1174
 
1175
+ if isinstance(value, Enum):
1176
+ value = value.value
1177
+
1148
1178
  if parameter_idx is not None:
1149
1179
  existing_parameter_type = type(wrapped_obj.Parameters.Items[parameter_idx])
1150
1180
 
@@ -1354,6 +1384,9 @@ def add_properties(prop_name: str,
1354
1384
  content = taxonomy_map.get_content_by_property_name(prop_name)
1355
1385
 
1356
1386
  def setx(self, value: Union[int, float, str, tuple, set, SimComponent, SimultanObject]):
1387
+
1388
+ # logger.debug(f'Setting property {prop_name} to {value}.')
1389
+
1357
1390
  self.__property_cache__.pop(content.text_or_key, None)
1358
1391
 
1359
1392
  slot_extension = content.slot_extension
@@ -1389,7 +1422,9 @@ def add_properties(prop_name: str,
1389
1422
  return
1390
1423
 
1391
1424
  from .type_setter_lookup import type_setter_fcn_lookup_dict
1392
- setter_fcn = type_setter_fcn_lookup_dict.get(type(value), set_property_to_unknown_type)
1425
+
1426
+ setter_fcn = type_setter_fcn_lookup_dict.get(value, set_property_to_unknown_type)
1427
+
1393
1428
  setter_fcn(*fcn_arg_list)
1394
1429
 
1395
1430
  setx.__taxonomy__ = taxonomy
@@ -1,12 +1,11 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: PySimultan
3
- Version: 0.4.22
3
+ Version: 0.5.0
4
4
  Project-URL: Documentation, https://github.com/Bühler Maximilian/PySimultan2#readme
5
5
  Project-URL: Issues, https://github.com/Bühler Maximilian/PySimultan2/issues
6
6
  Project-URL: Source, https://github.com/Bühler Maximilian/PySimultan2
7
7
  Author-email: Bühler Maximilian <maximilian.buehler@tuwien.ac.at>
8
- License-Expression: MIT
9
- License-File: LICENSE.txt
8
+ License: MIT
10
9
  Classifier: Development Status :: 4 - Beta
11
10
  Classifier: Programming Language :: Python
12
11
  Classifier: Programming Language :: Python :: 3.8
@@ -1,14 +1,14 @@
1
- PySimultan2/__about__.py,sha256=P-nQJsKMEB57RcETBb098-YVGYuTXD81e-dFo3rZ2so,20
2
- PySimultan2/__init__.py,sha256=cabTN1Oz8xtFM31ouBKg5lwLqW5vtexDP669PYyNLnA,3224
3
- PySimultan2/data_model.py,sha256=xosu5TAfgsrxwyhd6SfHFp4Wvo1_YtxdHsSuZmuNVJU,27022
4
- PySimultan2/default_types.py,sha256=7M6-nEvyoGr9gFoPlmyy9jrglEcjosc7e9XBsQfoDjY,23912
5
- PySimultan2/files.py,sha256=8F1QC9nTsTSrCpu5vGx1xGx-7UgkDwoICXau_5j7UzI,12725
1
+ PySimultan2/__about__.py,sha256=r3KZ-VR8WzImzZtG_Cy9406RiC9eKWaqtTphrx4AlGw,19
2
+ PySimultan2/__init__.py,sha256=PGVR1uhY01dF5tHyad-znURUZ_LVB95vsjId2BT0aJM,3245
3
+ PySimultan2/data_model.py,sha256=wSEHnx5uU81CSbUpKkmpQ2gbWfDziDxNGIiKnF9-Bck,31731
4
+ PySimultan2/default_types.py,sha256=xJ7nSdUhNj9P_WX_OoEo6gmvJ0P3I33k160nOsMbkAU,27234
5
+ PySimultan2/files.py,sha256=_KQNn1WS9LEETSADbxaFXNaTZ9e66dAGhPU5K1iOcOk,14068
6
6
  PySimultan2/multi_values.py,sha256=ZFXlTLuZo32x7_7diYAp2XEjp5uwgHLgNOzN7v74-5I,13650
7
- PySimultan2/object_mapper.py,sha256=yYVGeIzkdYvNMqW_kz9NwVxi6IJWGAqLS8CrYzW2oEg,13210
8
- PySimultan2/simultan_object.py,sha256=P047pfjgScysBMIsW7Co63VlzXGnLqGwxjyAEVLh8kg,16917
9
- PySimultan2/taxonomy_maps.py,sha256=YXOE-vUan2vLQyk96W728Vw5elBvIwH56tTuRBYeUyQ,8420
10
- PySimultan2/type_setter_lookup.py,sha256=mCOYAnxNxofPcWUl59axNCFXe1gkilV_yWz2-0MGeGM,2782
11
- PySimultan2/utils.py,sha256=32pHmzSIITC7WjFsfxmcMxMhHZPsk5K_KtQ5Uwi-pUs,61735
7
+ PySimultan2/object_mapper.py,sha256=Inx7jj8VkuvjMibWiP3PcymATllvP2prUW-pRQaT15M,15535
8
+ PySimultan2/simultan_object.py,sha256=akaSUZZWIVfwx1wT5EdOgRR2UeShUthX-LE2Uk6w8CQ,19058
9
+ PySimultan2/taxonomy_maps.py,sha256=abMB2RSKEaliW-Ewegq-Inq9npHeOD1VVrMYoKJAlC0,8762
10
+ PySimultan2/type_setter_lookup.py,sha256=WtopIR2Z3v3wNFtqmeVorH7ZUbKoJYTTe5I3vfQuKUI,3404
11
+ PySimultan2/utils.py,sha256=wIN169fAne6xc_DgppscyB17uj8pAkptyaX_89CcJrc,63110
12
12
  PySimultan2/geometry/__init__.py,sha256=nJolTD1i5J8qUkOQa-r3D20aq3Co3sN31Xc0n4wJpJo,248
13
13
  PySimultan2/geometry/geometry_base.py,sha256=nbb9U2W3vFviVLxISLHRi2CVyLEM-3zIKvoZ1uSYs_8,23420
14
14
  PySimultan2/geometry/utils.py,sha256=J25YsK8sso_UL7xRusItQZvyjtvxdOsSPelBQYFABhY,8519
@@ -16,19 +16,16 @@ PySimultan2/resources/AssimpNet.dll,sha256=x8uwMHPRmEH9fDQihfEQLUdblM1u7RP-CCnUj
16
16
  PySimultan2/resources/AvalonDock.dll,sha256=9tCcw7cpaVq0bh1H2sfcxb8EWhySmgujPs89lAqIPZs,500224
17
17
  PySimultan2/resources/BruTile.dll,sha256=ZiE_vovBW_CZOjDgOn8eaq_tfWRBD3-nSEk0ctBSdKI,198144
18
18
  PySimultan2/resources/ClosedXML.dll,sha256=dzkwJaBvIdou7SZSE5lsEART_jlnMMztEZu_jBuHp74,1198592
19
- PySimultan2/resources/ComponentBuilder.dll,sha256=lFTtNFDu-PBClyBHzQFDzxY1hKS5BsgnVJPe8TD_2j8,2303488
19
+ PySimultan2/resources/ComponentBuilder.dll,sha256=h1muHkr2D3cITs39GEAlc73jPomuBT6tpuZaHYEAgg8,2304512
20
20
  PySimultan2/resources/ComponentBuilder.dll.config,sha256=jP5s_8OMg9085DyGtrLZcguy8etqm4ra21KwDXq1sy0,3032
21
- PySimultan2/resources/ComponentBuilder.runtimeconfig.json,sha256=DSp4MGmJyWjNc_SmtGLu8DcWOcu4eQJIAo4Sy6A1RFo,372
22
- PySimultan2/resources/ComponentBuilder.xml,sha256=YzLCny4j4FcuI09CxrWOVPl6y9ROImowL8oryEUwQ8Q,1036992
21
+ PySimultan2/resources/ComponentBuilder.runtimeconfig.json,sha256=YBIGLYblUb1QapC3Td-VcI9HtfEQ_6rQssb-JbeODyA,458
22
+ PySimultan2/resources/ComponentBuilder.xml,sha256=5jkNgGaRzrSS2Umvcs_7vRuJqIZUc8GSKfAT0kfV4GA,1039253
23
23
  PySimultan2/resources/ControlzEx.dll,sha256=S26xw5MnNiIoyiCmVFbFOmUx1yx_zAyXBdDSOSidZxQ,463160
24
24
  PySimultan2/resources/Cyotek.Drawing.BitmapFont.dll,sha256=JG8HbAq5s796e02jB9QklO2cOyKPtHmhY6vc7KUs0OQ,41800
25
25
  PySimultan2/resources/DocumentFormat.OpenXml.dll,sha256=JjiBI17BpHztipV39dQdXAjhHo6Ic0xRjijJJuBQLLo,6108592
26
26
  PySimultan2/resources/DotSpatial.Projections.dll,sha256=dK4oFLcpUK3i6CZ3qIcX5B0npYd-W4hHJz7RJvM77ho,1541632
27
27
  PySimultan2/resources/ExcelNumberFormat.dll,sha256=18Rbjk4QJ4MeL8jN-UH69R0opm_qz8qqc32nMmLntQc,30720
28
28
  PySimultan2/resources/Fluent.dll,sha256=9b7QKKj8-Ynhe4WqSVfiP82PkxYz_kI_GXYi_KQxrEU,2598400
29
- PySimultan2/resources/GeometryViewer.dll,sha256=XSL8_RE1WaMQEE63lWfRyT3c2mGp4he2sV3aVqZAraM,674816
30
- PySimultan2/resources/GeometryViewer.dll.config,sha256=Mh7DX9B2wny9xirQXMGItReL1tu6dr9eZs_snTJfazc,2218
31
- PySimultan2/resources/GeometryViewer.xml,sha256=RScFj5qG1LsCNFPMVQlX1IH6_T2oh-2oM8Ru7GJP6mw,327644
32
29
  PySimultan2/resources/HelixToolkit.Core.Wpf.dll,sha256=fja1q_EVnu7tVMh_7t-fJUEllzBjPBCCJi4XUPkqdXI,586240
33
30
  PySimultan2/resources/HelixToolkit.SharpDX.Core.Wpf.dll,sha256=UKAHS0g37VbEtnEOXDaEgSH5OK6Au9edAECfWWLolIQ,613376
34
31
  PySimultan2/resources/HelixToolkit.SharpDX.Core.dll,sha256=rTdGZRKbcjsY-qQQDDTwwrOQRc_Nb9DpxBV_n2zfm2M,1729536
@@ -45,18 +42,18 @@ PySimultan2/resources/Microsoft.WindowsAPICodePack.dll,sha256=aB9FK5RWRh1onyayOe
45
42
  PySimultan2/resources/Microsoft.Xaml.Behaviors.dll,sha256=j3gq16397qqTMYMGWqegvpOHq85gOOkSRV54UnsErco,145272
46
43
  PySimultan2/resources/Newtonsoft.Json.Bson.dll,sha256=tgbl3XemJCyh8d9xfrU9lQWuVpBDMLl1wI1PLb6MMxk,90624
47
44
  PySimultan2/resources/Newtonsoft.Json.dll,sha256=etsgJYQb32kqVnEuCK_nXhcwxx1keKj-1XWs1DJRpmI,639488
48
- PySimultan2/resources/SIMULTAN.AutoUpdate.Client.dll,sha256=L_IcvvsiilPHOdD7dy1hpoKwp313LAhAP0HYaGGXrwU,25088
45
+ PySimultan2/resources/SIMULTAN.AutoUpdate.Client.dll,sha256=dtErCiJG-De-0WAXbsCjaQiCMo9HxKdIj7xqQnPMCPs,25088
49
46
  PySimultan2/resources/SIMULTAN.AutoUpdate.Client.dll.config,sha256=4rhndDRQFzX7AjPtDML_7lv2-0OHxR28slhacOQuTwg,432
50
- PySimultan2/resources/SIMULTAN.AutoUpdate.DataTransferLibrary.dll,sha256=r5h0jGfVcUEdBhlWOW7Vc3Dd2vK6rSr18nzwMWCphY0,16384
47
+ PySimultan2/resources/SIMULTAN.AutoUpdate.DataTransferLibrary.dll,sha256=7dqMPmwPrrCpLS69IRuVQEux8nzA-wINx1CFG0Ji5j8,16384
51
48
  PySimultan2/resources/SIMULTAN.AutoUpdate.DataTransferLibrary.dll.config,sha256=HvbeaSHEkocT9rD29HBz5uBbH3lmvCBBwzo9DD8RGo4,706
52
- PySimultan2/resources/SIMULTAN.Lang.dll,sha256=-P1geu8i0_1cj6wzXH4FxsvgwVEf3dPpGlchyhr_tEw,2572288
53
- PySimultan2/resources/SIMULTAN.Lang.xml,sha256=I9k6GE69fgOryxxyXDwamAf19rMjVemvF0T4ItfsqaE,731579
54
- PySimultan2/resources/SIMULTAN.Plugins.dll,sha256=lkpKS6A9E36w2F0nMXPh3kl0OIFQlsAH7uMD2iAVGBo,17920
49
+ PySimultan2/resources/SIMULTAN.Lang.dll,sha256=v6CvF1yAP3Y_ZSDLM4M1neDslSEUoN2QWh7xp5eeb_w,2584576
50
+ PySimultan2/resources/SIMULTAN.Lang.xml,sha256=RB5sIQdIqpqyM_b9xxRprWlOs8cr6XgeDbdk7rN6Tbg,736513
51
+ PySimultan2/resources/SIMULTAN.Plugins.dll,sha256=lDyPykpM5AyhgSlU4JjZsmMqH0NjcS12zP0HFKGrwP0,18944
55
52
  PySimultan2/resources/SIMULTAN.Plugins.xml,sha256=TqS3AuLxIKvHWoSkodX8RKhviwm8Isz3xC3QQcOT0rs,17708
56
- PySimultan2/resources/SIMULTAN.UI.dll,sha256=ICBY3d48juozSpXXDbGpF7j-IeGvpnU1clf6R08Jto0,1215488
57
- PySimultan2/resources/SIMULTAN.UI.xml,sha256=bCoi0ukQlL-X31vrVlb56m2J_T9gT380GE12CKnvzS4,828700
58
- PySimultan2/resources/SIMULTAN.dll,sha256=aEoSOoXNxHxD9GSSk9PY772jhwy3P4zCKGTEFVQcLn8,1727488
59
- PySimultan2/resources/SIMULTAN.xml,sha256=36bvzcFA1OOLQg-CkU86sNtCtoS5e8tv_fY1S5P2AXI,1945730
53
+ PySimultan2/resources/SIMULTAN.UI.dll,sha256=_qq5w1MdpjkJMGll3osNalDilDOsVDkEadxw6I_PS-I,1216512
54
+ PySimultan2/resources/SIMULTAN.UI.xml,sha256=Ot5-CtpwT6Cng0EjmlBKHkUQFlJ4SMZYlLxqLfeuDW8,833822
55
+ PySimultan2/resources/SIMULTAN.dll,sha256=GuFGoqJH1m2k19Fb8K_yJGI55f_BmSBuyKY-Q51YZZs,1768448
56
+ PySimultan2/resources/SIMULTAN.xml,sha256=k0ZClCQhdXKWLhRRgN94WnVl2m5w7_PPN9AMBdE-sPc,1963736
60
57
  PySimultan2/resources/SharpDX.D3DCompiler.dll,sha256=qyDGhqpcMo0zkNAdSdyX9sxWRxGRZq6ce4FIBXvxXSI,57856
61
58
  PySimultan2/resources/SharpDX.DXGI.dll,sha256=GMTsibwN7s_JG8t-ofKaJpDpKIADw2bqAnAzdLS21zI,147968
62
59
  PySimultan2/resources/SharpDX.Direct2D1.dll,sha256=HkRyV1YspAeY05q0E4pkFy3Hrrkd96fr9SzlmVnDekc,495616
@@ -64,19 +61,20 @@ PySimultan2/resources/SharpDX.Direct3D11.dll,sha256=XBwIVxhA-_S5haBjrGlXEwWWqIg5
64
61
  PySimultan2/resources/SharpDX.Direct3D9.dll,sha256=aXAe2nQzrAAQq6QWudnCRc14aUdw1LtrdUG4O6zkHVU,338944
65
62
  PySimultan2/resources/SharpDX.Mathematics.dll,sha256=ajtUzW3A6l7UwfVpZgpPacGrVHHP24QZmdSyZOHOThI,215552
66
63
  PySimultan2/resources/SharpDX.dll,sha256=UY1FparshMs36D7iz1jFA6tqJf67jEi1MxY0DJZ-hL0,275968
67
- PySimultan2/resources/SitePlanner.dll,sha256=a591d7c4yLZ3f-BzUKUtQb89uklzuQ1YT-UMBhsppck,4535808
68
- PySimultan2/resources/SitePlanner.dll.config,sha256=DLowURBQA7YOMY03hQDZIGlFR0eJsnSIovgf5cKJdlY,427
69
- PySimultan2/resources/SitePlanner.xml,sha256=80cFeETNe67PaiFk3JluQvG7p5m78GCQqybJ4gptgCM,140105
70
64
  PySimultan2/resources/Sprache.Calc.dll,sha256=QyBWSMEL5UXootOCTzYWlAkDgGcseeVgDaw_W7K32zc,22528
71
65
  PySimultan2/resources/Sprache.dll,sha256=4c4dDHP9ztxaBDpgWYBUhKKkzPl5eISQimpThGZl0t8,59904
66
+ PySimultan2/resources/System.Collections.Immutable.dll,sha256=YkpsmK2tsFnupt75OgF4vW0fedXRXfvGwPKONArInxk,245920
72
67
  PySimultan2/resources/System.Data.OleDb.dll,sha256=-AAzdmyo01QNgD9qnUIewEImplJFVNDGUlqE17qmRYA,124024
73
68
  PySimultan2/resources/System.Net.Http.Formatting.dll,sha256=xQBIin4YpqDObdqwau_5dr8XQEq54hlxV4gBgNtUqbc,179672
69
+ PySimultan2/resources/System.Reflection.Metadata.dll,sha256=Z_vYHE6IgOvBi3DLxLhfX-v6o01lTfD0B4oW6B8IsyA,475912
70
+ PySimultan2/resources/System.Reflection.MetadataLoadContext.dll,sha256=Fbu6xb2TISqYo235SFdcXBxG-0nbtA2XNftoDa4FqIA,253600
74
71
  PySimultan2/resources/XAMLMarkupExtensions.dll,sha256=Ck7FAAFHqSSwMtGJebfun-88OCEplWxY2YKMwlFaF84,36864
75
72
  PySimultan2/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
76
73
  PySimultan2/resources/assimp.dll,sha256=HwfDwXqoPDTFRyoQpA3qmgZoUdFtziJkV5fNtktEZEU,6081536
74
+ PySimultan2/resources/componentmanager.user,sha256=hrzr1US4pqkFnLHXcvPkvrgGd7QvlxaV8mhS6fuikEs,760
77
75
  PySimultan2/resources/defaultsettings.xml,sha256=s6Tk1tubLz5UYqXZWpD42EDHzedemRY1nEneoIVcUfg,392
78
76
  PySimultan2/resources/setup.bat,sha256=fjvvYfVM6TalS-QTSiKAbAId5nTsk8kGGo06ba-wWaY,32
79
- pysimultan-0.4.22.dist-info/METADATA,sha256=Paj_DgUNejfkhUoBgU4-jEfanNmt2YIJyeWUS2gIWTg,2703
80
- pysimultan-0.4.22.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
81
- pysimultan-0.4.22.dist-info/licenses/LICENSE.txt,sha256=pmSr98k6N005KMojnZxzLGRuRlDjDx3PUrK1lFj53HA,1126
82
- pysimultan-0.4.22.dist-info/RECORD,,
77
+ pysimultan-0.5.0.dist-info/METADATA,sha256=ija9DqBqK2nmbyuXJ1h6EboV-sWF_M6vx5n6IZjaQY0,2665
78
+ pysimultan-0.5.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
79
+ pysimultan-0.5.0.dist-info/licenses/LICENSE.txt,sha256=pmSr98k6N005KMojnZxzLGRuRlDjDx3PUrK1lFj53HA,1126
80
+ pysimultan-0.5.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.25.0
2
+ Generator: hatchling 1.26.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
Binary file