aas-standard-parser 0.2.1__tar.gz → 0.2.2__tar.gz

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 (21) hide show
  1. {aas_standard_parser-0.2.1 → aas_standard_parser-0.2.2}/PKG-INFO +1 -1
  2. {aas_standard_parser-0.2.1 → aas_standard_parser-0.2.2}/aas_standard_parser/aimc_parser.py +1 -50
  3. aas_standard_parser-0.2.2/aas_standard_parser/classes/aimc_parser_classes.py +52 -0
  4. {aas_standard_parser-0.2.1 → aas_standard_parser-0.2.2}/aas_standard_parser.egg-info/PKG-INFO +1 -1
  5. {aas_standard_parser-0.2.1 → aas_standard_parser-0.2.2}/aas_standard_parser.egg-info/SOURCES.txt +1 -0
  6. {aas_standard_parser-0.2.1 → aas_standard_parser-0.2.2}/pyproject.toml +1 -1
  7. {aas_standard_parser-0.2.1 → aas_standard_parser-0.2.2}/tests/test_aimc_parser.py +3 -3
  8. {aas_standard_parser-0.2.1 → aas_standard_parser-0.2.2}/LICENSE +0 -0
  9. {aas_standard_parser-0.2.1 → aas_standard_parser-0.2.2}/README.md +0 -0
  10. {aas_standard_parser-0.2.1 → aas_standard_parser-0.2.2}/aas_standard_parser/__init__.py +0 -0
  11. {aas_standard_parser-0.2.1 → aas_standard_parser-0.2.2}/aas_standard_parser/aid_parser.py +0 -0
  12. {aas_standard_parser-0.2.1 → aas_standard_parser-0.2.2}/aas_standard_parser/collection_helpers.py +0 -0
  13. {aas_standard_parser-0.2.1 → aas_standard_parser-0.2.2}/aas_standard_parser/demo/demo_process.py +0 -0
  14. {aas_standard_parser-0.2.1 → aas_standard_parser-0.2.2}/aas_standard_parser/demo/logging_handler.py +0 -0
  15. {aas_standard_parser-0.2.1 → aas_standard_parser-0.2.2}/aas_standard_parser/reference_helpers.py +0 -0
  16. {aas_standard_parser-0.2.1 → aas_standard_parser-0.2.2}/aas_standard_parser/submodel_parser.py +0 -0
  17. {aas_standard_parser-0.2.1 → aas_standard_parser-0.2.2}/aas_standard_parser/utils.py +0 -0
  18. {aas_standard_parser-0.2.1 → aas_standard_parser-0.2.2}/aas_standard_parser.egg-info/dependency_links.txt +0 -0
  19. {aas_standard_parser-0.2.1 → aas_standard_parser-0.2.2}/aas_standard_parser.egg-info/requires.txt +0 -0
  20. {aas_standard_parser-0.2.1 → aas_standard_parser-0.2.2}/aas_standard_parser.egg-info/top_level.txt +0 -0
  21. {aas_standard_parser-0.2.1 → aas_standard_parser-0.2.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aas-standard-parser
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Some auxiliary functions for parsing standard submodels
5
5
  Author-email: Daniel Klein <daniel.klein@em.ag>
6
6
  License: MIT License
@@ -1,64 +1,15 @@
1
1
  """Parser for Mapping Configurations in AIMC Submodel."""
2
2
 
3
- import json
4
3
  import logging
5
- from dataclasses import field
6
4
 
7
- import basyx.aas.adapter.json
8
5
  from basyx.aas import model
9
6
 
10
7
  import aas_standard_parser.collection_helpers as ch
8
+ from aas_standard_parser.classes.aimc_parser_classes import MappingConfiguration, MappingConfigurations, ReferenceProperties, SourceSinkRelation
11
9
 
12
10
  logger = logging.getLogger(__name__)
13
11
 
14
12
 
15
- class ReferenceProperties:
16
- """Class representing properties of a reference in the mapping configuration."""
17
-
18
- reference: model.ExternalReference = field(metadata={"description": "Reference to the property in the submodel."})
19
- submodel_id: str = field(metadata={"description": "Identifier of the submodel used by the reference."})
20
- property_name: str = field(metadata={"description": "Name of the mapped property."})
21
- parent_path: list[str] = field(metadata={"description": "List of idShorts representing the parent path of the reference."})
22
-
23
-
24
- class SourceSinkRelation:
25
- """Class representing a source-sink relation in the mapping configuration."""
26
-
27
- source_properties: ReferenceProperties = field(metadata={"description": "Properties of the source reference."})
28
- sink_properties: ReferenceProperties = field(metadata={"description": "Properties of the sink reference."})
29
-
30
- def source_as_dict(self) -> dict:
31
- """Convert the source reference to a dictionary.
32
-
33
- :return: The source reference as a dictionary.
34
- """
35
- dict_string = json.dumps(self.source_properties.reference, cls=basyx.aas.adapter.json.AASToJsonEncoder)
36
- dict_string = dict_string.replace("GlobalReference", "Submodel").replace("FragmentReference", "SubmodelElementCollection")
37
- return json.loads(dict_string)
38
-
39
- def sink_as_dict(self) -> dict:
40
- """Convert the sink reference to a dictionary.
41
-
42
- :return: The sink reference as a dictionary.
43
- """
44
- return json.dumps(self.sink_properties.reference, cls=basyx.aas.adapter.json.AASToJsonEncoder)
45
-
46
-
47
- class MappingConfiguration:
48
- """Class representing a mapping configuration."""
49
-
50
- interface_reference: model.ReferenceElement = field(metadata={"description": "Reference to the interface in the AID submodel."})
51
- aid_submodel_id: str = field(metadata={"description": "Identifier of the AID submodel used by the interface reference."})
52
- source_sink_relations: list[SourceSinkRelation] = field(metadata={"description": "List of source-sink relations in the mapping configuration."})
53
-
54
-
55
- class MappingConfigurations:
56
- """Class representing mapping configurations from AIMC submodel."""
57
-
58
- configurations: list[MappingConfiguration] = field(metadata={"description": "List of mapping configurations."})
59
- aid_submodel_ids: list[str] = field(metadata={"description": "List of AID submodel IDs used in the mapping configurations."})
60
-
61
-
62
13
  def get_mapping_configuration_root_element(aimc_submodel: model.Submodel) -> model.SubmodelElementCollection | None:
63
14
  """Get the mapping configuration root submodel element collection from the AIMC submodel.
64
15
 
@@ -0,0 +1,52 @@
1
+ import json
2
+ from dataclasses import field
3
+
4
+ import basyx.aas.adapter.json
5
+ from basyx.aas import model
6
+
7
+
8
+ class ReferenceProperties:
9
+ """Class representing properties of a reference in the mapping configuration."""
10
+
11
+ reference: model.ExternalReference = field(metadata={"description": "Reference to the property in the submodel."})
12
+ submodel_id: str = field(metadata={"description": "Identifier of the submodel used by the reference."})
13
+ property_name: str = field(metadata={"description": "Name of the mapped property."})
14
+ parent_path: list[str] = field(metadata={"description": "List of idShorts representing the parent path of the reference."})
15
+
16
+
17
+ class SourceSinkRelation:
18
+ """Class representing a source-sink relation in the mapping configuration."""
19
+
20
+ source_properties: ReferenceProperties = field(metadata={"description": "Properties of the source reference."})
21
+ sink_properties: ReferenceProperties = field(metadata={"description": "Properties of the sink reference."})
22
+
23
+ def source_reference_as_dict(self) -> dict:
24
+ """Convert the source reference to a dictionary.
25
+
26
+ :return: The source reference as a dictionary.
27
+ """
28
+ dict_string = json.dumps(self.source_properties.reference, cls=basyx.aas.adapter.json.AASToJsonEncoder)
29
+ dict_string = dict_string.replace("GlobalReference", "Submodel").replace("FragmentReference", "SubmodelElementCollection")
30
+ return json.loads(dict_string)
31
+
32
+ def sink_reference_as_dict(self) -> dict:
33
+ """Convert the sink reference to a dictionary.
34
+
35
+ :return: The sink reference as a dictionary.
36
+ """
37
+ return json.dumps(self.sink_properties.reference, cls=basyx.aas.adapter.json.AASToJsonEncoder)
38
+
39
+
40
+ class MappingConfiguration:
41
+ """Class representing a mapping configuration."""
42
+
43
+ interface_reference: model.ReferenceElement = field(metadata={"description": "Reference to the interface in the AID submodel."})
44
+ aid_submodel_id: str = field(metadata={"description": "Identifier of the AID submodel used by the interface reference."})
45
+ source_sink_relations: list[SourceSinkRelation] = field(metadata={"description": "List of source-sink relations in the mapping configuration."})
46
+
47
+
48
+ class MappingConfigurations:
49
+ """Class representing mapping configurations from AIMC submodel."""
50
+
51
+ configurations: list[MappingConfiguration] = field(metadata={"description": "List of mapping configurations."})
52
+ aid_submodel_ids: list[str] = field(metadata={"description": "List of AID submodel IDs used in the mapping configurations."})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aas-standard-parser
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Some auxiliary functions for parsing standard submodels
5
5
  Author-email: Daniel Klein <daniel.klein@em.ag>
6
6
  License: MIT License
@@ -13,6 +13,7 @@ aas_standard_parser.egg-info/SOURCES.txt
13
13
  aas_standard_parser.egg-info/dependency_links.txt
14
14
  aas_standard_parser.egg-info/requires.txt
15
15
  aas_standard_parser.egg-info/top_level.txt
16
+ aas_standard_parser/classes/aimc_parser_classes.py
16
17
  aas_standard_parser/demo/demo_process.py
17
18
  aas_standard_parser/demo/logging_handler.py
18
19
  tests/test_aimc_parser.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "aas-standard-parser"
7
- version = "0.2.1"
7
+ version = "0.2.2"
8
8
  description = "Some auxiliary functions for parsing standard submodels"
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE" }
@@ -1,7 +1,7 @@
1
1
  import pytest
2
2
  from basyx.aas import model
3
3
 
4
- from aas_standard_parser.aimc_parser import MappingConfiguration, SourceSinkRelation, ReferenceProperties
4
+ from aas_standard_parser.classes.aimc_parser_classes import MappingConfiguration, SourceSinkRelation, ReferenceProperties
5
5
  import aas_standard_parser.aimc_parser as aimc_parser
6
6
  from aas_standard_parser.utils import create_submodel_from_file
7
7
 
@@ -120,10 +120,10 @@ def _check_relations_sink(reference_properties: ReferenceProperties):
120
120
 
121
121
  def _check_relation_methods(relation: SourceSinkRelation):
122
122
  # test to_json methods
123
- source_json = relation.source_as_dict()
123
+ source_json = relation.source_reference_as_dict()
124
124
  assert source_json is not None
125
125
  assert "type" in source_json
126
126
 
127
- sink_json = relation.sink_as_dict()
127
+ sink_json = relation.sink_reference_as_dict()
128
128
  assert sink_json is not None
129
129
  assert "type" in sink_json