PySimultan 0.4.2__py3-none-any.whl → 0.4.4__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/__init__.py +12 -6
- PySimultan2/default_types.py +6 -5
- PySimultan2/object_mapper.py +19 -10
- PySimultan2/simultan_object.py +8 -4
- PySimultan2/utils.py +9 -4
- {pysimultan-0.4.2.dist-info → pysimultan-0.4.4.dist-info}/METADATA +1 -1
- {pysimultan-0.4.2.dist-info → pysimultan-0.4.4.dist-info}/RECORD +10 -10
- {pysimultan-0.4.2.dist-info → pysimultan-0.4.4.dist-info}/WHEEL +0 -0
- {pysimultan-0.4.2.dist-info → pysimultan-0.4.4.dist-info}/licenses/LICENSE.txt +0 -0
PySimultan2/__about__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
version = '0.4.
|
1
|
+
version = '0.4.4'
|
PySimultan2/__init__.py
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
import os
|
2
2
|
import sys
|
3
3
|
import colorlog
|
4
|
-
|
5
|
-
|
4
|
+
from ruamel.yaml import YAML, add_representer
|
5
|
+
|
6
|
+
from typing import TYPE_CHECKING
|
7
|
+
if TYPE_CHECKING:
|
8
|
+
from .data_model import DataModel
|
9
|
+
from .object_mapper import PythonMapper
|
6
10
|
|
7
11
|
def setup_logging():
|
8
12
|
handler = colorlog.StreamHandler()
|
@@ -85,16 +89,18 @@ class Config:
|
|
85
89
|
self._default_mapper = None
|
86
90
|
self.logger = logger
|
87
91
|
|
88
|
-
def get_default_data_model(self, *args, **kwargs):
|
92
|
+
def get_default_data_model(self, *args, **kwargs) -> 'DataModel':
|
89
93
|
return self._default_data_model
|
90
94
|
|
91
|
-
def get_default_mapper(self, *args, **kwargs):
|
95
|
+
def get_default_mapper(self, *args, **kwargs) -> 'PythonMapper':
|
92
96
|
return self._default_mapper
|
93
97
|
|
94
|
-
def set_default_data_model(self, data_model):
|
98
|
+
def set_default_data_model(self, data_model: 'DataModel'):
|
99
|
+
self.logger.debug(f'set_default_data_model: {id(data_model)}')
|
95
100
|
self._default_data_model = data_model
|
96
101
|
|
97
|
-
def set_default_mapper(self, mapper):
|
102
|
+
def set_default_mapper(self, mapper: 'PythonMapper'):
|
103
|
+
self.logger.debug(f'set_default_model: {id(mapper)}')
|
98
104
|
self._default_mapper = mapper
|
99
105
|
|
100
106
|
|
PySimultan2/default_types.py
CHANGED
@@ -117,7 +117,7 @@ class ComponentList(SimultanObject):
|
|
117
117
|
[all_components[i] for i in np.argsort(indices)]]
|
118
118
|
except TypeError as e:
|
119
119
|
logger.warning(f'Could not sort list {all_components}:\n{e}')
|
120
|
-
return [self._object_mapper.create_python_object(x) for x in all_components]
|
120
|
+
return [self._object_mapper.create_python_object(x, data_model=self._data_model) for x in all_components]
|
121
121
|
except Exception as e:
|
122
122
|
logger.error(f'Could not get data from list {self}:\n{e}')
|
123
123
|
return []
|
@@ -249,11 +249,12 @@ class ComponentList(SimultanObject):
|
|
249
249
|
if isinstance(i, slice):
|
250
250
|
if self._object_mapper is None:
|
251
251
|
return self.__class__(self.data[i])
|
252
|
-
return [self._object_mapper.create_python_object(x
|
252
|
+
return [self._object_mapper.create_python_object(x, data_model=self._data_model)
|
253
|
+
for x in self.__class__(self.data[i])]
|
253
254
|
else:
|
254
255
|
if self._object_mapper is None:
|
255
256
|
return self.data[i]
|
256
|
-
return self._object_mapper.create_python_object(self.data[i])
|
257
|
+
return self._object_mapper.create_python_object(self.data[i], data_model=self._data_model)
|
257
258
|
|
258
259
|
def __repr__(self):
|
259
260
|
return f'List {self.name}: ' + repr(list(self.data))
|
@@ -278,13 +279,13 @@ class ComponentList(SimultanObject):
|
|
278
279
|
return None
|
279
280
|
|
280
281
|
if self._wrapped_obj.Parent is not None:
|
281
|
-
return self._object_mapper.create_python_object(self._wrapped_obj.Parent)
|
282
|
+
return self._object_mapper.create_python_object(self._wrapped_obj.Parent, data_model=self._data_model)
|
282
283
|
else:
|
283
284
|
return None
|
284
285
|
|
285
286
|
@property
|
286
287
|
def referenced_by(self):
|
287
|
-
return set([self._object_mapper.create_python_object(x.Target) for x in self._wrapped_obj.ReferencedBy if
|
288
|
+
return set([self._object_mapper.create_python_object(x.Target, data_model=self._data_model) for x in self._wrapped_obj.ReferencedBy if
|
288
289
|
x.Target != self._wrapped_obj])
|
289
290
|
|
290
291
|
def clear(self):
|
PySimultan2/object_mapper.py
CHANGED
@@ -33,6 +33,8 @@ class PythonMapper(object):
|
|
33
33
|
return instance
|
34
34
|
|
35
35
|
def __init__(self, *args, **kwargs):
|
36
|
+
|
37
|
+
self.name = kwargs.get('name', 'PythonMapper')
|
36
38
|
self.registered_classes = default_registered_classes # dict with all registered classes: {taxonomy: class}
|
37
39
|
self.mapped_classes = default_mapped_classes # dict with all mapped classes: {taxonomy: class}
|
38
40
|
self.taxonomy_maps = default_taxonomy_maps # dict with all taxonomie maps: {taxonomy: taxonomie_map}
|
@@ -136,8 +138,7 @@ class PythonMapper(object):
|
|
136
138
|
typed_data.append(typed_object)
|
137
139
|
return typed_data
|
138
140
|
|
139
|
-
|
140
|
-
def create_python_object(self, component, cls=None, data_model=None, *args, **kwargs):
|
141
|
+
def create_python_geometry_object(self, component, data_model=None, *args, **kwargs):
|
141
142
|
|
142
143
|
if component is None:
|
143
144
|
return None
|
@@ -145,11 +146,6 @@ class PythonMapper(object):
|
|
145
146
|
if data_model is None:
|
146
147
|
logger.warning(f'No data model provided. Using default data model: {config.get_default_data_model().id}.')
|
147
148
|
data_model = config.get_default_data_model()
|
148
|
-
data_model_id = data_model.id
|
149
|
-
# data_model_id = list(data_models)[0].id
|
150
|
-
# data_model = list(data_models)[0]
|
151
|
-
else:
|
152
|
-
data_model_id = data_model.id
|
153
149
|
|
154
150
|
if isinstance(component, (Layer, Vertex, Edge, PEdge, Face, Volume, EdgeLoop)):
|
155
151
|
if isinstance(component, Layer):
|
@@ -157,7 +153,22 @@ class PythonMapper(object):
|
|
157
153
|
else:
|
158
154
|
geometry_model = component.Layer.Model.Model
|
159
155
|
cls = self.registered_geometry_classes[type(component)]
|
160
|
-
return create_python_geometry(cls, component,
|
156
|
+
return create_python_geometry(cls, component, data_model, self, geometry_model)
|
157
|
+
else:
|
158
|
+
self.create_python_object(component, data_model, *args, **kwargs)
|
159
|
+
|
160
|
+
# @lru_cache(maxsize=500)
|
161
|
+
def create_python_object(self, component, cls=None, data_model=None, *args, **kwargs):
|
162
|
+
|
163
|
+
if component is None:
|
164
|
+
return None
|
165
|
+
|
166
|
+
if data_model is None:
|
167
|
+
logger.warning(f'No data model provided. Using default data model: {config.get_default_data_model().id}.')
|
168
|
+
data_model = config.get_default_data_model()
|
169
|
+
|
170
|
+
if isinstance(component, (Layer, Vertex, Edge, PEdge, Face, Volume, EdgeLoop)):
|
171
|
+
self.create_python_geometry_object(component, data_model, *args, **kwargs)
|
161
172
|
|
162
173
|
if cls is None:
|
163
174
|
c_slots = [x.Target.Key for x in component.Slots.Items]
|
@@ -181,10 +192,8 @@ class PythonMapper(object):
|
|
181
192
|
else:
|
182
193
|
return create_python_object(component,
|
183
194
|
cls,
|
184
|
-
data_model_id=data_model_id,
|
185
195
|
object_mapper=self,
|
186
196
|
data_model=data_model,
|
187
|
-
|
188
197
|
*args,
|
189
198
|
**kwargs)
|
190
199
|
|
PySimultan2/simultan_object.py
CHANGED
@@ -223,7 +223,7 @@ class SimultanObject(object, metaclass=MetaMock):
|
|
223
223
|
return None
|
224
224
|
|
225
225
|
if self._wrapped_obj.Parent is not None:
|
226
|
-
return self._object_mapper.create_python_object(self._wrapped_obj.Parent)
|
226
|
+
return self._object_mapper.create_python_object(self._wrapped_obj.Parent, data_model=self._data_model)
|
227
227
|
else:
|
228
228
|
return None
|
229
229
|
|
@@ -239,7 +239,8 @@ class SimultanObject(object, metaclass=MetaMock):
|
|
239
239
|
|
240
240
|
@property
|
241
241
|
def referenced_by(self) -> set['SimultanObject']:
|
242
|
-
return set([self._object_mapper.create_python_object(x.Target
|
242
|
+
return set([self._object_mapper.create_python_object(x.Target, data_model=self._data_model)
|
243
|
+
for x in self._wrapped_obj.ReferencedBy if
|
243
244
|
x.Target != self._wrapped_obj])
|
244
245
|
|
245
246
|
@property
|
@@ -259,14 +260,17 @@ class SimultanObject(object, metaclass=MetaMock):
|
|
259
260
|
def get_subcomponents(self) -> dict[[str, str], Union['SimultanObject', SimComponent]]:
|
260
261
|
subcomponents = {}
|
261
262
|
for comp in self._wrapped_obj.Components:
|
262
|
-
subcomponents[(comp.Slot.SlotBase.Target.Key,
|
263
|
+
subcomponents[(comp.Slot.SlotBase.Target.Key,
|
264
|
+
comp.Slot.SlotExtension)] = self._object_mapper.create_python_object(comp.Component,
|
265
|
+
data_model=self._data_model)
|
263
266
|
return subcomponents
|
264
267
|
|
265
268
|
def get_subcomponent_list(self) -> list[Union['SimultanObject', SimComponent]]:
|
266
269
|
return list(self.get_subcomponents().values())
|
267
270
|
|
268
271
|
def get_referenced_components(self) -> list['SimultanObject']:
|
269
|
-
return [self._object_mapper.create_python_object(x
|
272
|
+
return [self._object_mapper.create_python_object(x, data_model=self._data_model)
|
273
|
+
for x in self._wrapped_obj.ReferencedComponents]
|
270
274
|
|
271
275
|
def add_taxonomy_entry_reference(self,
|
272
276
|
taxonomy_entry_reference: SimTaxonomyEntryReference,
|
PySimultan2/utils.py
CHANGED
@@ -64,14 +64,19 @@ def create_python_object(wrapped_obj: SimComponent, cls: Type[SimultanObject], *
|
|
64
64
|
:param cls: class of the python object
|
65
65
|
:param args: additional arguments
|
66
66
|
:param kwargs: additional keyword arguments
|
67
|
+
:param data_model: DataModel
|
68
|
+
:param object_mapper: PythonMapper
|
69
|
+
|
70
|
+
:return: SimultanObject
|
67
71
|
:return:
|
68
72
|
"""
|
69
73
|
|
70
74
|
from .default_types import ComponentList, ComponentDictionary
|
71
75
|
|
72
|
-
|
73
|
-
|
74
|
-
|
76
|
+
data_model = kwargs.get('data_model', None)
|
77
|
+
|
78
|
+
if data_model is None:
|
79
|
+
data_model = config.get_default_data_model()
|
75
80
|
|
76
81
|
if wrapped_obj is None:
|
77
82
|
return None
|
@@ -103,7 +108,7 @@ def create_python_object(wrapped_obj: SimComponent, cls: Type[SimultanObject], *
|
|
103
108
|
obj.__obj_init__ = True
|
104
109
|
obj.__property_cache__ = dict()
|
105
110
|
obj._wrapped_obj = wrapped_obj
|
106
|
-
obj._data_model =
|
111
|
+
obj._data_model = data_model
|
107
112
|
obj._object_mapper = kwargs.get('object_mapper', None)
|
108
113
|
obj.component_policy = kwargs.get('component_policy', 'subcomponent')
|
109
114
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: PySimultan
|
3
|
-
Version: 0.4.
|
3
|
+
Version: 0.4.4
|
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
|
@@ -1,13 +1,13 @@
|
|
1
|
-
PySimultan2/__about__.py,sha256=
|
2
|
-
PySimultan2/__init__.py,sha256=
|
1
|
+
PySimultan2/__about__.py,sha256=RwaUDZkdRtoi8pyQVrSiEtzw9q_PCdOE9ss7GpWaKIw,19
|
2
|
+
PySimultan2/__init__.py,sha256=HwoNLP41zezJFN1gJrCiN2lFtYIj47xm4P43J5bl_Ug,3174
|
3
3
|
PySimultan2/data_model.py,sha256=m9q3P5SfxYXdmwdQuPoTazHZAJ1xwazixFtdetJ2Dgk,26968
|
4
|
-
PySimultan2/default_types.py,sha256=
|
4
|
+
PySimultan2/default_types.py,sha256=v_4awsUURLbu4Sfw7J_7BoQKirXbKdU9s7-wqgA4nNE,23112
|
5
5
|
PySimultan2/files.py,sha256=gx3BA6WYjNVplqqes7jkPopp6O50pgLvantXgmitx54,12657
|
6
6
|
PySimultan2/multi_values.py,sha256=ZFXlTLuZo32x7_7diYAp2XEjp5uwgHLgNOzN7v74-5I,13650
|
7
|
-
PySimultan2/object_mapper.py,sha256=
|
8
|
-
PySimultan2/simultan_object.py,sha256=
|
7
|
+
PySimultan2/object_mapper.py,sha256=UUP8oZNkCG68DpizNJlcj14nrPTKMiq5oWAmA_XO1AY,10116
|
8
|
+
PySimultan2/simultan_object.py,sha256=Plr9nwgRmKzdkTO7l8ksWekEow9pT-MgjjAfLlChgDI,17208
|
9
9
|
PySimultan2/taxonomy_maps.py,sha256=aU9zUJph7QcInIZq0W-Vqoy4DYr0CEs-VsXwPMK_cxU,7976
|
10
|
-
PySimultan2/utils.py,sha256=
|
10
|
+
PySimultan2/utils.py,sha256=J3T7KDfONFeLWBulXmGMCaaOu5sfkDSHmI92JWO8dW4,62553
|
11
11
|
PySimultan2/geometry/__init__.py,sha256=nJolTD1i5J8qUkOQa-r3D20aq3Co3sN31Xc0n4wJpJo,248
|
12
12
|
PySimultan2/geometry/geometry_base.py,sha256=jOTNMISGLRjUUjVfPZ64A2Fp4oinv42polIct9bgIY4,23417
|
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.4.dist-info/METADATA,sha256=Ircg-qlFiM1A3IxrcFpM7zEeRinZdufhYRWuMzCKrFI,1657
|
79
|
+
pysimultan-0.4.4.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
|
80
|
+
pysimultan-0.4.4.dist-info/licenses/LICENSE.txt,sha256=pmSr98k6N005KMojnZxzLGRuRlDjDx3PUrK1lFj53HA,1126
|
81
|
+
pysimultan-0.4.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|