aas-standard-parser 0.2.3__tar.gz → 0.2.5__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 (23) hide show
  1. {aas_standard_parser-0.2.3 → aas_standard_parser-0.2.5}/PKG-INFO +1 -1
  2. {aas_standard_parser-0.2.3 → aas_standard_parser-0.2.5}/aas_standard_parser/__init__.py +2 -2
  3. aas_standard_parser-0.2.5/aas_standard_parser/aas_parser.py +24 -0
  4. {aas_standard_parser-0.2.3 → aas_standard_parser-0.2.5}/aas_standard_parser/classes/aimc_parser_classes.py +2 -2
  5. aas_standard_parser-0.2.5/aas_standard_parser/reference_helpers.py +31 -0
  6. {aas_standard_parser-0.2.3 → aas_standard_parser-0.2.5}/aas_standard_parser.egg-info/PKG-INFO +1 -1
  7. {aas_standard_parser-0.2.3 → aas_standard_parser-0.2.5}/aas_standard_parser.egg-info/SOURCES.txt +1 -0
  8. {aas_standard_parser-0.2.3 → aas_standard_parser-0.2.5}/pyproject.toml +1 -1
  9. {aas_standard_parser-0.2.3 → aas_standard_parser-0.2.5}/tests/test_aimc_parser.py +2 -0
  10. aas_standard_parser-0.2.3/aas_standard_parser/reference_helpers.py +0 -12
  11. {aas_standard_parser-0.2.3 → aas_standard_parser-0.2.5}/LICENSE +0 -0
  12. {aas_standard_parser-0.2.3 → aas_standard_parser-0.2.5}/README.md +0 -0
  13. {aas_standard_parser-0.2.3 → aas_standard_parser-0.2.5}/aas_standard_parser/aid_parser.py +0 -0
  14. {aas_standard_parser-0.2.3 → aas_standard_parser-0.2.5}/aas_standard_parser/aimc_parser.py +0 -0
  15. {aas_standard_parser-0.2.3 → aas_standard_parser-0.2.5}/aas_standard_parser/collection_helpers.py +0 -0
  16. {aas_standard_parser-0.2.3 → aas_standard_parser-0.2.5}/aas_standard_parser/demo/demo_process.py +0 -0
  17. {aas_standard_parser-0.2.3 → aas_standard_parser-0.2.5}/aas_standard_parser/demo/logging_handler.py +0 -0
  18. {aas_standard_parser-0.2.3 → aas_standard_parser-0.2.5}/aas_standard_parser/submodel_parser.py +0 -0
  19. {aas_standard_parser-0.2.3 → aas_standard_parser-0.2.5}/aas_standard_parser/utils.py +0 -0
  20. {aas_standard_parser-0.2.3 → aas_standard_parser-0.2.5}/aas_standard_parser.egg-info/dependency_links.txt +0 -0
  21. {aas_standard_parser-0.2.3 → aas_standard_parser-0.2.5}/aas_standard_parser.egg-info/requires.txt +0 -0
  22. {aas_standard_parser-0.2.3 → aas_standard_parser-0.2.5}/aas_standard_parser.egg-info/top_level.txt +0 -0
  23. {aas_standard_parser-0.2.3 → aas_standard_parser-0.2.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aas-standard-parser
3
- Version: 0.2.3
3
+ Version: 0.2.5
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,7 +13,7 @@ except importlib.metadata.PackageNotFoundError:
13
13
  __project__ = "aas-standard-parser"
14
14
  __package__ = "aas-standard-parser"
15
15
 
16
- from aas_standard_parser import aimc_parser
16
+ from aas_standard_parser import aas_parser, aid_parser, aimc_parser, submodel_parser
17
17
  from aas_standard_parser.aid_parser import AIDParser
18
18
 
19
- __all__ = ["AIDParser", "aimc_parser"]
19
+ __all__ = ["AIDParser", "aimc_parser", "aas_parser", "aid_parser", "submodel_parser"]
@@ -0,0 +1,24 @@
1
+ """Module for parsing AAS."""
2
+
3
+ import logging
4
+
5
+ from basyx.aas import model
6
+
7
+ logger = logging.getLogger(__name__)
8
+
9
+
10
+ def get_submodel_ids(shell: model.AssetAdministrationShell) -> list[str]:
11
+ """Get all submodel IDs from the given AAS.
12
+
13
+ :param shell: parent AAS to search within
14
+ :return: list of submodel IDs
15
+ """
16
+ submodel_ids = []
17
+ for submodel in shell.submodel:
18
+ if len(submodel.key) < 1 or submodel.key[0].type != model.KeyTypes.SUBMODEL:
19
+ logger.warning(f"Submodel reference {submodel} does not start with SUBMODEL key type.")
20
+ continue
21
+
22
+ submodel_ids.append(submodel.key[0].value)
23
+
24
+ return submodel_ids
@@ -27,14 +27,14 @@ class SourceSinkRelation:
27
27
  """
28
28
  dict_string = json.dumps(self.source_properties.reference, cls=basyx.aas.adapter.json.AASToJsonEncoder)
29
29
  dict_string = dict_string.replace("GlobalReference", "Submodel").replace("FragmentReference", "SubmodelElementCollection")
30
- return json.dumps(dict_string)
30
+ return json.loads(dict_string)
31
31
 
32
32
  def sink_reference_as_dict(self) -> dict:
33
33
  """Convert the sink reference to a dictionary.
34
34
 
35
35
  :return: The sink reference as a dictionary.
36
36
  """
37
- return json.dumps(self.sink_properties.reference, cls=basyx.aas.adapter.json.AASToJsonEncoder)
37
+ return json.loads(json.dumps(self.sink_properties.reference, cls=basyx.aas.adapter.json.AASToJsonEncoder))
38
38
 
39
39
 
40
40
  class MappingConfiguration:
@@ -0,0 +1,31 @@
1
+ from basyx.aas.model import ModelReference
2
+
3
+
4
+ def construct_idshort_path_from_reference(reference: ModelReference) -> str:
5
+ idshort_path: str = ""
6
+
7
+ # start from the second Key and omit the Identifiable at the beginning of the list
8
+ for key in reference.key[1:]:
9
+ idshort_path += key.value + "."
10
+
11
+ # get rid of the trailing dot
12
+ return idshort_path[:-1]
13
+
14
+
15
+ def get_values_from_keys(reference: ModelReference) -> list[str]:
16
+ """Returns the values from all keys in reference as list.
17
+
18
+ :param reference: reference to extract values from
19
+ :return: list of values from all keys in the reference
20
+ """
21
+ return [key.value for key in reference.key]
22
+
23
+
24
+ def get_value_from_key_at_index(reference: ModelReference, index: int) -> str:
25
+ """Returns the value from the key at the given index in reference.
26
+
27
+ :param reference: reference to extract value from
28
+ :param index: index of the key to get the value from
29
+ :return: value from the key at the given index
30
+ """
31
+ return reference.key[index].value
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aas-standard-parser
3
- Version: 0.2.3
3
+ Version: 0.2.5
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
@@ -2,6 +2,7 @@ LICENSE
2
2
  README.md
3
3
  pyproject.toml
4
4
  aas_standard_parser/__init__.py
5
+ aas_standard_parser/aas_parser.py
5
6
  aas_standard_parser/aid_parser.py
6
7
  aas_standard_parser/aimc_parser.py
7
8
  aas_standard_parser/collection_helpers.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.3"
7
+ version = "0.2.5"
8
8
  description = "Some auxiliary functions for parsing standard submodels"
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE" }
@@ -121,9 +121,11 @@ def _check_relations_sink(reference_properties: ReferenceProperties):
121
121
  def _check_relation_methods(relation: SourceSinkRelation):
122
122
  # test to_json methods
123
123
  source_json = relation.source_reference_as_dict()
124
+ assert isinstance(source_json, dict)
124
125
  assert source_json is not None
125
126
  assert "type" in source_json
126
127
 
127
128
  sink_json = relation.sink_reference_as_dict()
129
+ assert isinstance(sink_json, dict)
128
130
  assert sink_json is not None
129
131
  assert "type" in sink_json
@@ -1,12 +0,0 @@
1
- from basyx.aas.model import ModelReference
2
-
3
-
4
- def construct_idshort_path_from_reference(reference: ModelReference) -> str:
5
- idshort_path: str = ""
6
-
7
- # start from the second Key and omit the Identifiable at the beginning of the list
8
- for key in reference.key[1:]:
9
- idshort_path += (key.value + ".")
10
-
11
- # get rid of the trailing dot
12
- return idshort_path[:-1]