PySimultan 0.4.18__py3-none-any.whl → 0.4.20__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- PySimultan2/__about__.py +1 -1
- PySimultan2/default_types.py +53 -13
- PySimultan2/taxonomy_maps.py +8 -0
- PySimultan2/utils.py +34 -2
- {pysimultan-0.4.18.dist-info → pysimultan-0.4.20.dist-info}/METADATA +10 -1
- {pysimultan-0.4.18.dist-info → pysimultan-0.4.20.dist-info}/RECORD +8 -8
- {pysimultan-0.4.18.dist-info → pysimultan-0.4.20.dist-info}/WHEEL +0 -0
- {pysimultan-0.4.18.dist-info → pysimultan-0.4.20.dist-info}/licenses/LICENSE.txt +0 -0
PySimultan2/__about__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
version = '0.4.
|
1
|
+
version = '0.4.20'
|
PySimultan2/default_types.py
CHANGED
@@ -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],
|
@@ -374,13 +377,54 @@ class ComponentDictionary(SimultanObject):
|
|
374
377
|
|
375
378
|
if kwargs.get('check_dict', True) and comp_dict is not None and key in object.__getattribute__(self,
|
376
379
|
'_dict').keys():
|
377
|
-
return object.__getattribute__(self, '_dict')
|
380
|
+
return object.__getattribute__(self, '_dict').get(key, None)
|
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
|
-
|
383
|
-
|
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
|
+
data_model = self._data_model
|
387
|
+
object_mapper = self._object_mapper
|
388
|
+
wrapped_obj = self._wrapped_obj
|
389
|
+
|
390
|
+
if key in self._taxonomy_map.parameter_taxonomy_entry_dict.keys():
|
391
|
+
text_or_key = self._taxonomy_map.parameter_taxonomy_entry_dict[key]
|
392
|
+
else:
|
393
|
+
content = Content(text_or_key=f'__dict_key__{key}',
|
394
|
+
property_name=key,
|
395
|
+
type=None,
|
396
|
+
unit=None,
|
397
|
+
documentation=f'Property {key} in ComponentDictionary',
|
398
|
+
component_policy=self.component_policy)
|
399
|
+
self._taxonomy_map.add_content(content)
|
400
|
+
text_or_key = content.text_or_key
|
401
|
+
|
402
|
+
try:
|
403
|
+
components = list(wrapped_obj.Components.Items)
|
404
|
+
val = next((get_obj_value(x.Component,
|
405
|
+
data_model=data_model,
|
406
|
+
object_mapper=object_mapper) for x in components if
|
407
|
+
x.Slot.SlotBase.Target.Key == text_or_key), None)
|
408
|
+
if val is None:
|
409
|
+
ref_components = list(wrapped_obj.ReferencedComponents.Items)
|
410
|
+
val = next((get_obj_value(x.Target,
|
411
|
+
data_model=data_model,
|
412
|
+
object_mapper=object_mapper) for x in ref_components
|
413
|
+
if x.Slot.SlotBase.Target.Key == text_or_key), None)
|
414
|
+
if val is None:
|
415
|
+
parameters = list(wrapped_obj.Parameters.Items)
|
416
|
+
val = next((get_obj_value(x,
|
417
|
+
data_model=data_model,
|
418
|
+
object_mapper=object_mapper) for x in parameters if
|
419
|
+
x.NameTaxonomyEntry.TextOrKey == text_or_key), None)
|
420
|
+
|
421
|
+
except Exception as e:
|
422
|
+
logger.error(f'Could not get value for key {key} ({text_or_key}) in {self}:\n{e}')
|
423
|
+
raise ValueError(f'Could not get value for key {key} ({text_or_key}) in {self}:\n{e}')
|
424
|
+
|
425
|
+
self._dict[key] = get_obj_value(val,
|
426
|
+
data_model=data_model,
|
427
|
+
object_mapper=object_mapper)
|
384
428
|
return self._dict[key]
|
385
429
|
|
386
430
|
def __setitem__(self, key, value):
|
@@ -391,7 +435,7 @@ class ComponentDictionary(SimultanObject):
|
|
391
435
|
if key in self._taxonomy_map.content_dict.keys():
|
392
436
|
content = self._taxonomy_map.content_dict[key]
|
393
437
|
else:
|
394
|
-
content = Content(text_or_key=key,
|
438
|
+
content = Content(text_or_key=f'__dict_key__{key}',
|
395
439
|
property_name=key,
|
396
440
|
type=None,
|
397
441
|
unit=None,
|
@@ -399,7 +443,6 @@ class ComponentDictionary(SimultanObject):
|
|
399
443
|
component_policy=self.component_policy)
|
400
444
|
self._taxonomy_map.add_content(content)
|
401
445
|
taxonomy_entry = content.get_taxonomie_entry(self._data_model)
|
402
|
-
|
403
446
|
component_idx, ref_component_idx, parameter_idx, ref_asset_idx = get_param_indices(self._wrapped_obj,
|
404
447
|
taxonomy_entry)
|
405
448
|
|
@@ -425,6 +468,7 @@ class ComponentDictionary(SimultanObject):
|
|
425
468
|
ref_component_idx=ref_component_idx,
|
426
469
|
parameter_idx=parameter_idx,
|
427
470
|
keep=[])
|
471
|
+
return
|
428
472
|
|
429
473
|
if isinstance(value, (list, tuple, set, ComponentList)):
|
430
474
|
setter_fcn = set_property_to_list
|
@@ -436,11 +480,7 @@ class ComponentDictionary(SimultanObject):
|
|
436
480
|
setter_fcn(*fcn_arg_list)
|
437
481
|
item = self.__getitem__(key, check_dict=False)
|
438
482
|
|
439
|
-
|
440
|
-
#
|
441
|
-
# if isinstance(value, ):
|
442
|
-
|
443
|
-
self._dict[key] = self.__getitem__(key, check_dict=False)
|
483
|
+
self._dict[key] = item
|
444
484
|
|
445
485
|
def __delitem__(self, key):
|
446
486
|
self[key] = None
|
@@ -471,7 +511,7 @@ class ComponentDictionary(SimultanObject):
|
|
471
511
|
data_model=self._data_model,
|
472
512
|
object_mapper=self._object_mapper)
|
473
513
|
for ref_component in self._wrapped_obj.ReferencedComponents.Items:
|
474
|
-
comp_dict[ref_component.Slot.SlotBase.Target.
|
514
|
+
comp_dict[ref_component.Slot.SlotBase.Target.Key] = get_obj_value(ref_component.Target,
|
475
515
|
data_model=self._data_model,
|
476
516
|
object_mapper=self._object_mapper)
|
477
517
|
for ref_asset in self._wrapped_obj.ReferencedAssets.Items:
|
PySimultan2/taxonomy_maps.py
CHANGED
@@ -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:
|
PySimultan2/utils.py
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
+
import sys
|
4
|
+
import traceback
|
5
|
+
|
3
6
|
from enum import Enum
|
4
7
|
from weakref import WeakSet
|
5
8
|
import numpy as np
|
6
9
|
import pandas as pd
|
7
10
|
from typing import List as TypeList, Union, Optional, Type, Any, TYPE_CHECKING
|
11
|
+
|
12
|
+
from System import ArgumentException, NotSupportedException
|
13
|
+
|
8
14
|
from SIMULTAN.Data.Components import (ComponentWalker, SimComponent, SimBoolParameter, SimDoubleParameter,
|
9
15
|
SimEnumParameter, SimIntegerParameter, SimStringParameter, ComponentMapping,
|
10
16
|
SimSlot, SimComponentVisibility, SimChildComponentEntry, SimDefaultSlots,
|
@@ -417,8 +423,31 @@ def add_sub_component(comp: SimComponent,
|
|
417
423
|
new_slot = SimSlot(sub_comp.Slots[0].Target, str(slot_extension))
|
418
424
|
|
419
425
|
entry = SimChildComponentEntry(new_slot, sub_comp)
|
426
|
+
|
427
|
+
error = None
|
428
|
+
new_slot_extension = 0
|
429
|
+
|
420
430
|
if entry not in comp.Components.Items:
|
421
|
-
|
431
|
+
try:
|
432
|
+
comp.Components.InsertItem(len(comp.Components.Items), entry)
|
433
|
+
except (ArgumentException, NotSupportedException) as e:
|
434
|
+
error = e
|
435
|
+
|
436
|
+
while error is not None and new_slot_extension < 100:
|
437
|
+
try:
|
438
|
+
try:
|
439
|
+
slot_extension += 1
|
440
|
+
if slot_extension > 1000:
|
441
|
+
break
|
442
|
+
except Exception as e:
|
443
|
+
new_slot_extension += 1
|
444
|
+
slot_extension = slot_extension + f'_{new_slot_extension}'
|
445
|
+
new_slot = SimSlot(sub_comp.Slots[0].Target, str(slot_extension))
|
446
|
+
entry = SimChildComponentEntry(new_slot, sub_comp)
|
447
|
+
comp.Components.InsertItem(len(comp.Components.Items), entry)
|
448
|
+
error = None
|
449
|
+
except (ArgumentException, NotSupportedException) as e:
|
450
|
+
error = e
|
422
451
|
return True
|
423
452
|
|
424
453
|
|
@@ -727,7 +756,8 @@ type_convert_dict = {SimComponent: get_sim_component_value,
|
|
727
756
|
SimEnumParameter: get_parameter_value,
|
728
757
|
ResourceEntry: get_resource_entry_value,
|
729
758
|
ContainedResourceFileEntry: get_resource_entry_value,
|
730
|
-
LinkedResourceFileEntry: get_resource_entry_value
|
759
|
+
LinkedResourceFileEntry: get_resource_entry_value
|
760
|
+
}
|
731
761
|
|
732
762
|
|
733
763
|
def get_obj_value(obj: Union[SimComponent, SimDoubleParameter, SimIntegerParameter, SimStringParameter,
|
@@ -738,6 +768,8 @@ def get_obj_value(obj: Union[SimComponent, SimDoubleParameter, SimIntegerParamet
|
|
738
768
|
|
739
769
|
if obj is None:
|
740
770
|
return
|
771
|
+
elif isinstance(obj, (int, float, str)):
|
772
|
+
return obj
|
741
773
|
elif type(obj) in type_convert_dict.keys():
|
742
774
|
return type_convert_dict[type(obj)](obj, data_model=data_model, object_mapper=object_mapper)
|
743
775
|
else:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: PySimultan
|
3
|
-
Version: 0.4.
|
3
|
+
Version: 0.4.20
|
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,12 @@ C:\Program Files\FreeCAD
|
|
78
78
|
│
|
79
79
|
|
80
80
|
```
|
81
|
+
|
82
|
+
|
83
|
+
# Change Log
|
84
|
+
|
85
|
+
## [0.4.20] - 2024-07-01
|
86
|
+
- Fixed Bug in nested dictionary creation
|
87
|
+
|
88
|
+
## [0.4.19] - 2024-07-01
|
89
|
+
- Refactored dictionaries
|
@@ -1,13 +1,13 @@
|
|
1
|
-
PySimultan2/__about__.py,sha256=
|
1
|
+
PySimultan2/__about__.py,sha256=5LZKy2_Q7Bsu50daCLBwex_Hb1mMwOUMiteIDt5jRXI,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=
|
4
|
+
PySimultan2/default_types.py,sha256=MvZuU7qQW-ybRIT5Fl5yKdyidXhTQjFZuUq2W8hvEI4,25504
|
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=
|
10
|
-
PySimultan2/utils.py,sha256=
|
9
|
+
PySimultan2/taxonomy_maps.py,sha256=YXOE-vUan2vLQyk96W728Vw5elBvIwH56tTuRBYeUyQ,8420
|
10
|
+
PySimultan2/utils.py,sha256=NOetVGG51-JTCrTTXMMmUz2pZpAGmvuojtoXd1UmLtA,63716
|
11
11
|
PySimultan2/geometry/__init__.py,sha256=nJolTD1i5J8qUkOQa-r3D20aq3Co3sN31Xc0n4wJpJo,248
|
12
12
|
PySimultan2/geometry/geometry_base.py,sha256=nbb9U2W3vFviVLxISLHRi2CVyLEM-3zIKvoZ1uSYs_8,23420
|
13
13
|
PySimultan2/geometry/utils.py,sha256=J25YsK8sso_UL7xRusItQZvyjtvxdOsSPelBQYFABhY,8519
|
@@ -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.
|
79
|
-
pysimultan-0.4.
|
80
|
-
pysimultan-0.4.
|
81
|
-
pysimultan-0.4.
|
78
|
+
pysimultan-0.4.20.dist-info/METADATA,sha256=TlRBXFruRV99PRNlQ_BOu8m4VeW3bgFu6-7Ufy-fjao,2619
|
79
|
+
pysimultan-0.4.20.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
80
|
+
pysimultan-0.4.20.dist-info/licenses/LICENSE.txt,sha256=pmSr98k6N005KMojnZxzLGRuRlDjDx3PUrK1lFj53HA,1126
|
81
|
+
pysimultan-0.4.20.dist-info/RECORD,,
|
File without changes
|
File without changes
|