aas-standard-parser 0.1.8__py3-none-any.whl → 0.2.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.
- aas_standard_parser/aimc_parser.py +49 -31
- aas_standard_parser/submodel_parser.py +2 -2
- {aas_standard_parser-0.1.8.dist-info → aas_standard_parser-0.2.0.dist-info}/METADATA +1 -1
- {aas_standard_parser-0.1.8.dist-info → aas_standard_parser-0.2.0.dist-info}/RECORD +7 -7
- {aas_standard_parser-0.1.8.dist-info → aas_standard_parser-0.2.0.dist-info}/WHEEL +0 -0
- {aas_standard_parser-0.1.8.dist-info → aas_standard_parser-0.2.0.dist-info}/licenses/LICENSE +0 -0
- {aas_standard_parser-0.1.8.dist-info → aas_standard_parser-0.2.0.dist-info}/top_level.txt +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import json
|
|
4
4
|
import logging
|
|
5
|
-
from dataclasses import
|
|
5
|
+
from dataclasses import field
|
|
6
6
|
|
|
7
7
|
import basyx.aas.adapter.json
|
|
8
8
|
from basyx.aas import model
|
|
@@ -12,14 +12,25 @@ import aas_standard_parser.collection_helpers as ch
|
|
|
12
12
|
logger = logging.getLogger(__name__)
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
class ReferenceProperties:
|
|
16
|
+
"""Class representing properties of a reference in the mapping configuration."""
|
|
17
|
+
|
|
18
|
+
submodel_id: str = field(metadata={"description": "Identifier of the submodel used by the reference."})
|
|
19
|
+
property_name: str = field(metadata={"description": "Name of the mapped property."})
|
|
20
|
+
parent_path: list[str] = field(metadata={"description": "List of idShorts representing the parent path of the reference."})
|
|
21
|
+
|
|
22
|
+
|
|
15
23
|
class SourceSinkRelation:
|
|
16
24
|
"""Class representing a source-sink relation in the mapping configuration."""
|
|
17
25
|
|
|
18
|
-
|
|
26
|
+
source_submodel_id: str = field(metadata={"description": "Identifier of the source (AID) submodel used by the source reference."})
|
|
27
|
+
sink_submodel_id: str = field(metadata={"description": "Identifier of the target submodel used by the sink reference."})
|
|
19
28
|
source: model.ExternalReference = field(metadata={"description": "Reference to the source property in the AID submodel."})
|
|
20
29
|
sink: model.ExternalReference = field(metadata={"description": "Reference to the sink property in the target submodel."})
|
|
21
|
-
|
|
22
|
-
|
|
30
|
+
source_property_name: str = field(metadata={"description": "Name of the mapped property in source."})
|
|
31
|
+
sink_property_name: str = field(metadata={"description": "Name of the mapped property in sink."})
|
|
32
|
+
source_parent_path: list[str] = field(metadata={"description": "List of idShorts representing the parent path of the source reference."})
|
|
33
|
+
sink_parent_path: list[str] = field(metadata={"description": "List of idShorts representing the parent path of the reference."})
|
|
23
34
|
|
|
24
35
|
def source_as_dict(self) -> dict:
|
|
25
36
|
"""Convert the source reference to a dictionary.
|
|
@@ -37,13 +48,6 @@ class SourceSinkRelation:
|
|
|
37
48
|
"""
|
|
38
49
|
return json.loads(json.dumps(self.sink, cls=basyx.aas.adapter.json.AASToJsonEncoder))
|
|
39
50
|
|
|
40
|
-
def get_source_parent_property_group_name(self) -> str:
|
|
41
|
-
"""Get the name of the parent property group from the source. Ignore 'properties' entries from the path."""
|
|
42
|
-
if len(self.source_parent_path) == 0:
|
|
43
|
-
return ""
|
|
44
|
-
|
|
45
|
-
return next((n for n in reversed(self.source_parent_path) if n != "properties"), "")
|
|
46
|
-
|
|
47
51
|
|
|
48
52
|
class MappingConfiguration:
|
|
49
53
|
"""Class representing a mapping configuration."""
|
|
@@ -164,7 +168,7 @@ def parse_mapping_configuration_element(
|
|
|
164
168
|
return None
|
|
165
169
|
|
|
166
170
|
# check if all relations have the same AID submodel
|
|
167
|
-
aid_submodel_ids = list({source_sink_relation.
|
|
171
|
+
aid_submodel_ids = list({source_sink_relation.source_submodel_id for source_sink_relation in source_sink_relations})
|
|
168
172
|
|
|
169
173
|
if len(aid_submodel_ids) != 1:
|
|
170
174
|
logger.error(
|
|
@@ -233,35 +237,49 @@ def _generate_source_sink_relations(mapping_configuration_element: model.Submode
|
|
|
233
237
|
logger.warning(f"'second' reference is missing in RelationshipElement '{source_sink_relation.id_short}'")
|
|
234
238
|
continue
|
|
235
239
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
global_ref = next((key for key in source_ref.key if key.type == model.KeyTypes.GLOBAL_REFERENCE), None)
|
|
239
|
-
|
|
240
|
-
if global_ref is None:
|
|
241
|
-
logger.warning(f"No GLOBAL_REFERENCE key found in 'first' reference of RelationshipElement '{source_sink_relation.id_short}'")
|
|
242
|
-
continue
|
|
243
|
-
|
|
244
|
-
last_fragment_ref = next(
|
|
245
|
-
(key for key in reversed(source_ref.key) if key.type == model.KeyTypes.FRAGMENT_REFERENCE),
|
|
246
|
-
None,
|
|
247
|
-
)
|
|
248
|
-
|
|
249
|
-
if last_fragment_ref is None:
|
|
250
|
-
logger.warning(f"No FRAGMENT_REFERENCE key found in 'first' reference of RelationshipElement '{source_sink_relation.id_short}'")
|
|
251
|
-
continue
|
|
240
|
+
source_ref_properties = _get_reference_properties(source_sink_relation.first)
|
|
241
|
+
sink_ref_properties = _get_reference_properties(source_sink_relation.second)
|
|
252
242
|
|
|
253
243
|
relation = SourceSinkRelation()
|
|
244
|
+
|
|
254
245
|
relation.source = source_sink_relation.first
|
|
246
|
+
relation.source_submodel_id = source_ref_properties.submodel_id
|
|
247
|
+
relation.source_property_name = source_ref_properties.property_name
|
|
248
|
+
relation.source_parent_path = source_ref_properties.parent_path
|
|
249
|
+
|
|
255
250
|
relation.sink = source_sink_relation.second
|
|
256
|
-
relation.
|
|
257
|
-
relation.
|
|
258
|
-
relation.
|
|
251
|
+
relation.sink_submodel_id = sink_ref_properties.submodel_id
|
|
252
|
+
relation.sink_property_name = sink_ref_properties.property_name
|
|
253
|
+
relation.sink_parent_path = sink_ref_properties.parent_path
|
|
259
254
|
|
|
260
255
|
source_sink_relations.append(relation)
|
|
261
256
|
|
|
262
257
|
return source_sink_relations
|
|
263
258
|
|
|
264
259
|
|
|
260
|
+
def _get_reference_properties(reference: model.ExternalReference) -> ReferenceProperties | None:
|
|
261
|
+
global_ref = next((key for key in reference.key if key.type == model.KeyTypes.GLOBAL_REFERENCE), None)
|
|
262
|
+
|
|
263
|
+
if global_ref is None:
|
|
264
|
+
logger.warning(f"No GLOBAL_REFERENCE key found in 'first' reference of RelationshipElement '{reference}'")
|
|
265
|
+
return None
|
|
266
|
+
|
|
267
|
+
last_fragment_ref = next((key for key in reversed(reference.key) if key.type == model.KeyTypes.FRAGMENT_REFERENCE), None)
|
|
268
|
+
|
|
269
|
+
if last_fragment_ref is None:
|
|
270
|
+
logger.warning(f"No FRAGMENT_REFERENCE key found in 'first' reference of RelationshipElement '{reference.id_short}'")
|
|
271
|
+
return None
|
|
272
|
+
|
|
273
|
+
parent_path = _get_reference_parent_path(reference)
|
|
274
|
+
|
|
275
|
+
ref_properties = ReferenceProperties()
|
|
276
|
+
ref_properties.submodel_id = global_ref.value
|
|
277
|
+
ref_properties.property_name = last_fragment_ref.value
|
|
278
|
+
ref_properties.parent_path = parent_path
|
|
279
|
+
|
|
280
|
+
return ref_properties
|
|
281
|
+
|
|
282
|
+
|
|
265
283
|
def _get_reference_parent_path(reference: model.ExternalReference) -> list[str]:
|
|
266
284
|
"""Get the parent path of a reference as a list of idShorts.
|
|
267
285
|
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import logging
|
|
4
4
|
|
|
5
5
|
from basyx.aas import model
|
|
6
|
-
from basyx.aas.model import
|
|
6
|
+
from basyx.aas.model import NamespaceSet, SubmodelElement
|
|
7
7
|
|
|
8
|
-
import collection_helpers
|
|
8
|
+
from aas_standard_parser import collection_helpers
|
|
9
9
|
|
|
10
10
|
logger = logging.getLogger(__name__)
|
|
11
11
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
aas_standard_parser/__init__.py,sha256=3iBTUUlJ97ImkAHdss_GP970BANEU1uNeg0HlRzzois,599
|
|
2
2
|
aas_standard_parser/aid_parser.py,sha256=9vp8_kJRfExTmw8tjmO32n1eHFAE5ItmfPlZ2ORLZMs,14314
|
|
3
|
-
aas_standard_parser/aimc_parser.py,sha256=
|
|
3
|
+
aas_standard_parser/aimc_parser.py,sha256=3hAKH3F1_r9ZDPLz82PYIehJnUsZodqX6ysVx2wM3fg,13440
|
|
4
4
|
aas_standard_parser/collection_helpers.py,sha256=fTQGQiC-bGD41Qx0FDDBtWhvkeZtEe6Sh-aT93ePwro,4153
|
|
5
5
|
aas_standard_parser/reference_helpers.py,sha256=UbqXaub5PTvt_W3VPntSSFcTS59PUwlTpoujny8rIRI,377
|
|
6
|
-
aas_standard_parser/submodel_parser.py,sha256=
|
|
6
|
+
aas_standard_parser/submodel_parser.py,sha256=XH-XTBB3a0MB1NR5nAzG9C6f9hT_qG42f-ABruN3MzE,3169
|
|
7
7
|
aas_standard_parser/utils.py,sha256=5iIPpM_ob2V9MwFL_vTbXd23doYKot30xenRmTPAquo,723
|
|
8
8
|
aas_standard_parser/demo/demo_process.py,sha256=Xn9uD0xLoNx0ZvB3Lk0oYkGBRHaEfUbfqv5_SpPWYck,530
|
|
9
9
|
aas_standard_parser/demo/logging_handler.py,sha256=x-eX4XDU3sZTJE22rzJSiaWQ8wRMbtaFpFBAeAcbIzI,5752
|
|
10
|
-
aas_standard_parser-0.
|
|
11
|
-
aas_standard_parser-0.
|
|
12
|
-
aas_standard_parser-0.
|
|
13
|
-
aas_standard_parser-0.
|
|
14
|
-
aas_standard_parser-0.
|
|
10
|
+
aas_standard_parser-0.2.0.dist-info/licenses/LICENSE,sha256=simqYMD2P9Ikm0Kh9n7VGNpaVcm2TMVVQmECYZ_xVZ8,1065
|
|
11
|
+
aas_standard_parser-0.2.0.dist-info/METADATA,sha256=FjntnuF2IPILHFc5n6A2EITPZQGPJKAdN9nXTR1uSL8,1718
|
|
12
|
+
aas_standard_parser-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
13
|
+
aas_standard_parser-0.2.0.dist-info/top_level.txt,sha256=OQaK6cwYttR1-eKTz5u4M0jbwSfp4HqJ56chaf0nHnw,20
|
|
14
|
+
aas_standard_parser-0.2.0.dist-info/RECORD,,
|
|
File without changes
|
{aas_standard_parser-0.1.8.dist-info → aas_standard_parser-0.2.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|