PySimultan 0.4.17__py3-none-any.whl → 0.4.19__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
PySimultan2/__about__.py CHANGED
@@ -1 +1 @@
1
- version = '0.4.17'
1
+ version = '0.4.19'
@@ -341,6 +341,9 @@ class ComponentDictionary(SimultanObject):
341
341
  super().__init__(*args, **kwargs)
342
342
  self.component_policy = kwargs.get('component_policy', 'subcomponent') # component add policy of the content/parameter/property, 'reference' or 'subcomponent'
343
343
 
344
+ def __load_init__(self, *args, **kwargs):
345
+ self._dict = {}
346
+
344
347
  @classmethod
345
348
  def create_from_values(cls,
346
349
  values: dict[str, Any],
@@ -377,10 +380,48 @@ class ComponentDictionary(SimultanObject):
377
380
  return object.__getattribute__(self, '_dict')[key]
378
381
  else:
379
382
  # data_model = config.default_data_model
380
- obj = get_component_taxonomy_entry(self._wrapped_obj, key)
381
- if obj is not None:
382
- val = get_obj_value(obj, data_model=self._data_model, object_mapper=self._object_mapper)
383
- self._dict[key] = val
383
+ # obj = get_component_taxonomy_entry(self._wrapped_obj, key)
384
+ # if obj is not None:
385
+ # val = get_obj_value(obj, data_model=self._data_model, object_mapper=self._object_mapper)
386
+
387
+ if key in self._taxonomy_map.parameter_taxonomy_entry_dict.keys():
388
+ text_or_key = self._taxonomy_map.parameter_taxonomy_entry_dict[key]
389
+ else:
390
+ content = Content(text_or_key=f'__dict_key__{key}',
391
+ property_name=key,
392
+ type=None,
393
+ unit=None,
394
+ documentation=f'Property {key} in ComponentDictionary',
395
+ component_policy=self.component_policy)
396
+ self._taxonomy_map.add_content(content)
397
+ text_or_key = content.text_or_key
398
+
399
+ try:
400
+ components = list(self._wrapped_obj.Components.Items)
401
+ val = next((get_obj_value(x.Component,
402
+ data_model=self._data_model,
403
+ object_mapper=self._object_mapper) for x in components if
404
+ x.Slot.SlotBase.Target.Key == text_or_key), None)
405
+ if val is None:
406
+ ref_components = list(self._wrapped_obj.ReferencedComponents.Items)
407
+ val = next((get_obj_value(x.Target,
408
+ data_model=self._data_model,
409
+ object_mapper=self._object_mapper) for x in ref_components
410
+ if x.Slot.SlotBase.Target.Key == text_or_key), None)
411
+ if val is None:
412
+ parameters = list(self._wrapped_obj.Parameters.Items)
413
+ val = next((get_obj_value(x,
414
+ data_model=self._data_model,
415
+ object_mapper=self._object_mapper) for x in parameters if
416
+ x.NameTaxonomyEntry.TextOrKey == text_or_key), None)
417
+
418
+ except Exception as e:
419
+ logger.error(f'Could not get value for key {key} ({text_or_key}) in {self}:\n{e}')
420
+ raise ValueError(f'Could not get value for key {key} ({text_or_key}) in {self}:\n{e}')
421
+
422
+ self._dict[key] = get_obj_value(val,
423
+ data_model=self._data_model,
424
+ object_mapper=self._object_mapper)
384
425
  return self._dict[key]
385
426
 
386
427
  def __setitem__(self, key, value):
@@ -391,7 +432,7 @@ class ComponentDictionary(SimultanObject):
391
432
  if key in self._taxonomy_map.content_dict.keys():
392
433
  content = self._taxonomy_map.content_dict[key]
393
434
  else:
394
- content = Content(text_or_key=key,
435
+ content = Content(text_or_key=f'__dict_key__{key}',
395
436
  property_name=key,
396
437
  type=None,
397
438
  unit=None,
@@ -399,7 +440,6 @@ class ComponentDictionary(SimultanObject):
399
440
  component_policy=self.component_policy)
400
441
  self._taxonomy_map.add_content(content)
401
442
  taxonomy_entry = content.get_taxonomie_entry(self._data_model)
402
-
403
443
  component_idx, ref_component_idx, parameter_idx, ref_asset_idx = get_param_indices(self._wrapped_obj,
404
444
  taxonomy_entry)
405
445
 
@@ -425,6 +465,7 @@ class ComponentDictionary(SimultanObject):
425
465
  ref_component_idx=ref_component_idx,
426
466
  parameter_idx=parameter_idx,
427
467
  keep=[])
468
+ return
428
469
 
429
470
  if isinstance(value, (list, tuple, set, ComponentList)):
430
471
  setter_fcn = set_property_to_list
@@ -87,6 +87,7 @@ class TaxonomyMap(object):
87
87
 
88
88
  self._content = []
89
89
  self._content_dict = {}
90
+ self._parameter_taxonomy_entry_dict = {}
90
91
 
91
92
  self.taxonomy_name = kwargs.get('taxonomy_name', kwargs.get('taxonomy_key', None))
92
93
  self.taxonomy_key = kwargs.get('taxonomy_key', None)
@@ -124,6 +125,13 @@ class TaxonomyMap(object):
124
125
  self._content_dict[content.text_or_key] = content
125
126
  return self._content_dict
126
127
 
128
+ @property
129
+ def parameter_taxonomy_entry_dict(self):
130
+ 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
133
+ return self._parameter_taxonomy_entry_dict
134
+
127
135
  def write(self, filename=None):
128
136
  if filename is not None:
129
137
  with open(filename, mode='w') as f:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: PySimultan
3
- Version: 0.4.17
3
+ Version: 0.4.19
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
@@ -78,3 +78,9 @@ C:\Program Files\FreeCAD
78
78
 
79
79
 
80
80
  ```
81
+
82
+
83
+ # Change Log
84
+
85
+ ## [0.4.19] - 2024-07-01
86
+ - Refactored dictionaries
@@ -1,12 +1,12 @@
1
- PySimultan2/__about__.py,sha256=eW_nV_PONpUuczCTSMecvA_jA4pFZsPRV1Puf8SmZhQ,20
1
+ PySimultan2/__about__.py,sha256=Z9VH1opxusXUHCDJeWUusEwptfCLQBbFMXR9ph5aJS4,20
2
2
  PySimultan2/__init__.py,sha256=cabTN1Oz8xtFM31ouBKg5lwLqW5vtexDP669PYyNLnA,3224
3
3
  PySimultan2/data_model.py,sha256=xosu5TAfgsrxwyhd6SfHFp4Wvo1_YtxdHsSuZmuNVJU,27022
4
- PySimultan2/default_types.py,sha256=v_4awsUURLbu4Sfw7J_7BoQKirXbKdU9s7-wqgA4nNE,23112
4
+ PySimultan2/default_types.py,sha256=hE_JyKcykL3bSqpeEj-zSA04oLJ6UnsGR17SfdjkXNo,25578
5
5
  PySimultan2/files.py,sha256=8F1QC9nTsTSrCpu5vGx1xGx-7UgkDwoICXau_5j7UzI,12725
6
6
  PySimultan2/multi_values.py,sha256=ZFXlTLuZo32x7_7diYAp2XEjp5uwgHLgNOzN7v74-5I,13650
7
7
  PySimultan2/object_mapper.py,sha256=yYVGeIzkdYvNMqW_kz9NwVxi6IJWGAqLS8CrYzW2oEg,13210
8
8
  PySimultan2/simultan_object.py,sha256=P047pfjgScysBMIsW7Co63VlzXGnLqGwxjyAEVLh8kg,16917
9
- PySimultan2/taxonomy_maps.py,sha256=IYpIat6ZJi5MyCbsjAxWvVOWDRp_VvSMWUY3CApKSik,8061
9
+ PySimultan2/taxonomy_maps.py,sha256=YXOE-vUan2vLQyk96W728Vw5elBvIwH56tTuRBYeUyQ,8420
10
10
  PySimultan2/utils.py,sha256=qhF46rCHmI96Hdp9sdHAAkUJtaQxoG6YJu7Hx5IM4Go,62569
11
11
  PySimultan2/geometry/__init__.py,sha256=nJolTD1i5J8qUkOQa-r3D20aq3Co3sN31Xc0n4wJpJo,248
12
12
  PySimultan2/geometry/geometry_base.py,sha256=nbb9U2W3vFviVLxISLHRi2CVyLEM-3zIKvoZ1uSYs_8,23420
@@ -75,7 +75,7 @@ PySimultan2/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
75
75
  PySimultan2/resources/assimp.dll,sha256=HwfDwXqoPDTFRyoQpA3qmgZoUdFtziJkV5fNtktEZEU,6081536
76
76
  PySimultan2/resources/defaultsettings.xml,sha256=s6Tk1tubLz5UYqXZWpD42EDHzedemRY1nEneoIVcUfg,392
77
77
  PySimultan2/resources/setup.bat,sha256=fjvvYfVM6TalS-QTSiKAbAId5nTsk8kGGo06ba-wWaY,32
78
- pysimultan-0.4.17.dist-info/METADATA,sha256=tODPF7D9orfxF0pw2bKTjWB-3og4HBuB18aa6BWsn2k,2483
79
- pysimultan-0.4.17.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
80
- pysimultan-0.4.17.dist-info/licenses/LICENSE.txt,sha256=pmSr98k6N005KMojnZxzLGRuRlDjDx3PUrK1lFj53HA,1126
81
- pysimultan-0.4.17.dist-info/RECORD,,
78
+ pysimultan-0.4.19.dist-info/METADATA,sha256=1uJ2SKZAtUEgv2A_EB35HQMeh0jCfA1AM0PW8EMGW1w,2551
79
+ pysimultan-0.4.19.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
80
+ pysimultan-0.4.19.dist-info/licenses/LICENSE.txt,sha256=pmSr98k6N005KMojnZxzLGRuRlDjDx3PUrK1lFj53HA,1126
81
+ pysimultan-0.4.19.dist-info/RECORD,,