aas-standard-parser 0.2.6__py3-none-any.whl → 0.2.7__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.
@@ -1,11 +1,26 @@
1
+ """AAS Standard parser Package."""
2
+
1
3
  import importlib.metadata
2
- from datetime import datetime
4
+ from datetime import datetime, timezone
5
+
6
+ from aas_standard_parser import (
7
+ aas_parser,
8
+ aid_parser,
9
+ aimc_parser,
10
+ collection_helpers,
11
+ reference_helpers,
12
+ submodel_json_parser,
13
+ submodel_parser,
14
+ utils,
15
+ )
16
+ from aas_standard_parser.aid_parser import AIDParser
17
+ from aas_standard_parser.version_check import check_for_update
3
18
 
4
- # TODO: introduce MIT license
5
- __copyright__ = f"Copyright (C) {datetime.now().year} :em engineering methods AG. All rights reserved."
19
+ __copyright__ = f"Copyright (C) {datetime.now(tz=timezone.utc).year} Fluid 4.0. All rights reserved."
6
20
  __author__ = "Daniel Klein, Celina Adelhardt, Tom Gneuß"
7
21
 
8
22
  try:
23
+ __license__ = "MIT"
9
24
  __version__ = importlib.metadata.version(__name__)
10
25
  except importlib.metadata.PackageNotFoundError:
11
26
  __version__ = "0.0.0-dev"
@@ -13,7 +28,17 @@ except importlib.metadata.PackageNotFoundError:
13
28
  __project__ = "aas-standard-parser"
14
29
  __package__ = "aas-standard-parser"
15
30
 
16
- from aas_standard_parser import aas_parser, aid_parser, aimc_parser, submodel_parser
17
- from aas_standard_parser.aid_parser import AIDParser
18
31
 
19
- __all__ = ["AIDParser", "aimc_parser", "aas_parser", "aid_parser", "submodel_parser"]
32
+ check_for_update()
33
+
34
+ __all__ = [
35
+ "AIDParser",
36
+ "aas_parser",
37
+ "aid_parser",
38
+ "aimc_parser",
39
+ "collection_helpers",
40
+ "reference_helpers",
41
+ "submodel_json_parser",
42
+ "submodel_parser",
43
+ "utils",
44
+ ]
@@ -8,10 +8,10 @@ logger = logging.getLogger(__name__)
8
8
 
9
9
 
10
10
  def get_submodel_ids(shell: model.AssetAdministrationShell) -> list[str]:
11
- """Get all submodel IDs from the given AAS.
11
+ """Get all IDs from the submodels referenced in the given AAS.
12
12
 
13
- :param shell: parent AAS to search within
14
- :return: list of submodel IDs
13
+ :param shell: The Asset Administration Shell to extract submodel IDs from.
14
+ :return: A list of submodel IDs referenced in the AAS.
15
15
  """
16
16
  submodel_ids = []
17
17
  for submodel in shell.submodel:
@@ -1,15 +1,22 @@
1
+ """Helper functions for working with ModelReference objects in the AAS standard parser."""
2
+
1
3
  from basyx.aas.model import ModelReference
2
4
 
3
5
 
4
- def construct_idshort_path_from_reference(reference: ModelReference) -> str:
5
- idshort_path: str = ""
6
+ def construct_id_short_path_from_reference(reference: ModelReference) -> str:
7
+ """Constructs an idShort path from the given ModelReference.
8
+
9
+ :param reference: The ModelReference to construct the idShort path from.
10
+ :return: The constructed idShort path as a string.
11
+ """
12
+ id_short_path: str = ""
6
13
 
7
14
  # start from the second Key and omit the Identifiable at the beginning of the list
8
15
  for key in reference.key[1:]:
9
- idshort_path += key.value + "."
16
+ id_short_path += key.value + "."
10
17
 
11
18
  # get rid of the trailing dot
12
- return idshort_path[:-1]
19
+ return id_short_path[:-1]
13
20
 
14
21
 
15
22
  def get_values_from_keys(reference: ModelReference) -> list[str]:
@@ -0,0 +1,35 @@
1
+ """Module for parsing submodels JSON data."""
2
+
3
+ import logging
4
+
5
+ logger = logging.getLogger(__name__)
6
+
7
+
8
+ def get_value_from_semantic_id_by_index(submodel_data: dict, index: int) -> str | None:
9
+ """Retrieve the value from the semantic ID from a submodel JSON dictionary by index.
10
+
11
+ :param submodel_data: The submodel data as a dictionary.
12
+
13
+ :param index: The index to access if the element is a list or collection.
14
+ :return: The value of the found submodel element or None if not found.
15
+ """
16
+ if "semantic_id" not in submodel_data or len(submodel_data.semantic_id.key) == 0:
17
+ logger.debug(f"Submodel '{submodel_data}' has no semantic ID")
18
+ return None
19
+
20
+ sm_semantic_id = submodel_data.get("semantic_id", {})
21
+ if "keys" not in sm_semantic_id or len(sm_semantic_id["keys"]) == 0:
22
+ logger.debug(f"Submodel '{submodel_data}' has no semantic ID keys")
23
+ return None
24
+
25
+ if len(sm_semantic_id["keys"]) < index + 1:
26
+ logger.debug(f"Submodel '{submodel_data}' has no semantic ID key at index {index}")
27
+ return None
28
+
29
+ key = sm_semantic_id["keys"][index]
30
+
31
+ if "value" not in key:
32
+ logger.debug(f"Submodel '{submodel_data}' has no semantic ID value")
33
+ return None
34
+
35
+ return key["value"]
@@ -3,32 +3,19 @@
3
3
  import logging
4
4
 
5
5
  from basyx.aas import model
6
- from basyx.aas.model import NamespaceSet, SubmodelElement
7
-
8
- from aas_standard_parser import collection_helpers
9
6
 
10
7
  logger = logging.getLogger(__name__)
11
8
 
12
9
 
13
- def get_element_by_semantic_id(collection: NamespaceSet[SubmodelElement], semantic_id: str) -> SubmodelElement | None:
14
- """Get an element from parent collection by its semantic ID (not recursive).
15
-
16
- :param parent: parent collection to search within
17
- :param semantic_id: semantic ID to search for
18
- :return: the found submodel element or None if not found
19
- """
20
- return collection_helpers.find_by_semantic_id(collection, semantic_id)
21
-
22
-
23
- def get_submodel_element_by_path(submodel: model.Submodel, path: str) -> model.SubmodelElement:
24
- """Returns a specific submodel element from the submodel at a specific path.
10
+ def get_submodel_element_by_id_short_path(submodel: model.Submodel, id_short_path: str) -> model.SubmodelElement:
11
+ """Retrieve a specific submodel element from the submodel at a specific idShort path.
25
12
 
26
13
  :param submodel: The submodel to search within.
27
- :param path: IdShort path to the submodel element (dot-separated), e.g., "Element1.Element2[0].Element3".
14
+ :param id_short_path: IdShort path to the submodel element (dot-separated), e.g., "Element1.Element2[0].Element3".
28
15
  :return: The found submodel element or None if not found.
29
16
  """
30
17
  # Split the path by '.' and traverse the structure
31
- parts = path.split(".")
18
+ parts = id_short_path.split(".")
32
19
  current_elements = submodel.submodel_element
33
20
  part_index = 0
34
21
  for part in parts:
@@ -1,3 +1,5 @@
1
+ """Utility functions for AAS standard parser."""
2
+
1
3
  import json
2
4
  from pathlib import Path
3
5
 
@@ -6,19 +8,19 @@ from basyx.aas import model
6
8
 
7
9
 
8
10
  def create_submodel_from_file(file_path: str) -> model.Submodel:
9
- """Creates a Submodel from a given file path.
11
+ """Loads a Submodel structure from a given JSON file and converts it into a model.Submodel object from the python SDK framework.
10
12
 
11
- :param file_path: Path to the file containing the submodel data.
12
- :return: The created Submodel object.
13
+ :param file_path: Path to the JSON file containing the Submodel structure.
14
+ :return: A model.Submodel object representing the loaded Submodel structure.
13
15
  """
14
16
  file = Path(file_path)
15
17
  if not file.exists():
16
- raise FileNotFoundError(f"Submodel template file not found: {file}")
18
+ raise FileNotFoundError(f"Submodel structure file not found: {file}")
17
19
 
18
20
  template_data = {}
19
21
 
20
22
  # Load the template JSON file
21
- with open(file, "r", encoding="utf-8") as f:
23
+ with file.open("r", encoding="utf-8") as f:
22
24
  template_data = json.load(f)
23
25
 
24
26
  # Load the template JSON into a Submodel object
@@ -0,0 +1,28 @@
1
+ """Utility functions for version checking."""
2
+
3
+ import importlib.metadata
4
+ import logging
5
+
6
+ import requests
7
+
8
+ logger = logging.getLogger(__name__)
9
+
10
+
11
+ def check_for_update(package_name="aas-standard-parser"):
12
+ """Check for updates of the package on PyPI.
13
+
14
+ :param package_name: The name of the package to check for updates, defaults to "aas-standard-parser"
15
+ """
16
+ try:
17
+ current_version = importlib.metadata.version(package_name)
18
+ pypi_url = f"https://pypi.org/pypi/{package_name}/json"
19
+ latest_version = requests.get(pypi_url, timeout=3).json()["info"]["version"]
20
+
21
+ if current_version != latest_version:
22
+ print(
23
+ f"⚠️ A new version for package '{package_name}' is available: "
24
+ f"{latest_version} (currently installed: {current_version}). "
25
+ f"Use the following command to update the package: pip install --upgrade {package_name}"
26
+ )
27
+ except Exception as exc:
28
+ logger.exception(f"Exception occurred while checking for package update: {exc}")
@@ -0,0 +1,92 @@
1
+ Metadata-Version: 2.4
2
+ Name: aas-standard-parser
3
+ Version: 0.2.7
4
+ Summary: Some auxiliary functions for parsing standard submodels
5
+ Author-email: Daniel Klein <daniel.klein@em.ag>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 Fluid4.0
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/fluid40/aas-http-client
29
+ Description-Content-Type: text/markdown
30
+ License-File: LICENSE
31
+ Requires-Dist: typing>=3.7.4.3
32
+ Requires-Dist: basyx-python-sdk>=1.2.1
33
+ Dynamic: license-file
34
+
35
+ # aas-standard-parser
36
+
37
+ <div align="center">
38
+ <!-- change this to your projects logo if you have on.
39
+ If you don't have one it might be worth trying chatgpt dall-e to create one for you...
40
+ -->
41
+ <img src="docs/assets/fluid_logo.svg" alt="aas_http_client" width=500 />
42
+ </div>
43
+
44
+ ---
45
+
46
+ [![License: MIT](https://img.shields.io/badge/license-MIT-%23f8a602?label=License&labelColor=%23992b2e)](LICENSE)
47
+ [![CI](https://github.com/fluid40/aas-standard-parser/actions/workflows/CI.yml/badge.svg?branch=main&cache-bust=1)](https://github.com/fluid40/aas-standard-parser/actions)
48
+ [![PyPI version](https://img.shields.io/pypi/v/aas-standard-parser.svg)](https://pypi.org/project/aas-standard-parser/)
49
+
50
+
51
+ This project provides tools for parsing and handling Asset Administration Shell (AAS) standard submodels, with a focus on AID and AIMC submodels. It enables:
52
+
53
+ - Extraction, interpretation, and mapping of submodel elements and their properties
54
+ - Working with references, semantic IDs, and submodel element collections
55
+ - Representation and processing of mapping configurations and source-sink relations
56
+ - Structured and colored logging, including log file management
57
+
58
+ These components enable efficient parsing, transformation, and analysis of AAS submodels in Python-based workflows.
59
+ > **Note:** Most functions in this project utilize the [python aas sdk framework](https://github.com/aas-core-works/aas-core3.0-python) for parsing and handling AAS submodels, ensuring compatibility with the official AAS data models and structures.
60
+ ---
61
+
62
+ ## Provided Parsers
63
+
64
+ - **AID Parser**: Parses AID submodels to extract interface descriptions, properties, and security/authentication details.
65
+ - **AIMC Parser**: Parses AIMC submodels to extract and process mapping configurations and source-sink relations.
66
+ - **AAS Parser**: Utilities to extract submodel IDs from an Asset Administration Shell.
67
+ - **Submodel Parser**: Helpers to retrieve submodel elements by semantic ID or by path within a submodel.
68
+
69
+ ## Helper Modules
70
+
71
+ - **Collection Helpers**: Functions to search and filter submodel elements by semantic ID, idShort, or supplemental semantic ID within collections.
72
+ - **Reference Helpers**: Utilities for working with references, such as constructing idShort paths and extracting values from reference keys.
73
+ - **Utilities**: General utility functions, including loading a submodel from a file.
74
+
75
+ ---
76
+
77
+ ## API References
78
+ - AID Parser
79
+ - AIMC Parser
80
+ - [AAS Parser](docs/api_references/api_aas_parser.md)
81
+ - [Submodel Parser](docs/api_references/api_submodel_parser.md)
82
+ - Collection Helpers
83
+ - [Reference Helpers](docs/api_references/api_reference_helpers.md)
84
+ - [Utilities](docs/api_references/api_utils.md)
85
+
86
+ ## Resources
87
+
88
+ 🤖 [Releases](http://github.com/fluid40/aas-standard-parser/releases)
89
+
90
+ 📦 [Pypi Packages](https://pypi.org/project/aas-standard-parser/)
91
+
92
+ 📜 [MIT License](LICENSE)
@@ -0,0 +1,18 @@
1
+ aas_standard_parser/__init__.py,sha256=hYQya1mIcVbk8sSSB1PcoUq8Ipu4BYHLlahTS5h-bak,1029
2
+ aas_standard_parser/aas_parser.py,sha256=aKeiq6YFVpYyntfwdqTaMgzab_5Eo_4wV1BWBP5BLvo,744
3
+ aas_standard_parser/aid_parser.py,sha256=9vp8_kJRfExTmw8tjmO32n1eHFAE5ItmfPlZ2ORLZMs,14314
4
+ aas_standard_parser/aimc_parser.py,sha256=3GSM-jBj-9OqNDnL7CssqogNOZEd7_fjRtxwzRZi-iA,9972
5
+ aas_standard_parser/collection_helpers.py,sha256=fTQGQiC-bGD41Qx0FDDBtWhvkeZtEe6Sh-aT93ePwro,4153
6
+ aas_standard_parser/reference_helpers.py,sha256=HJMK1FjoEkPipw9kcT7k75EYioHz_SwcLLqXdFo9Eew,1339
7
+ aas_standard_parser/submodel_json_parser.py,sha256=uy1tEQH5AAiysVbtwLHEK_V_bVRMx7SMQLhhm6m3MOc,1260
8
+ aas_standard_parser/submodel_parser.py,sha256=cKDKUBoKMJb1q6ISalJhLlE1VRqqFHTDWsv6BdeSmXU,2653
9
+ aas_standard_parser/utils.py,sha256=TSOvTZxhPp4s63rn-xzLQasDxEiHyk6BcHhIkzaUTek,905
10
+ aas_standard_parser/version_check.py,sha256=P1nb2WvVVU5RaQ4mWViFLnF9QkUv61Zc2EApYPGiiC8,1058
11
+ aas_standard_parser/classes/aimc_parser_classes.py,sha256=PwKpuyB36urFc8YqQ6KtrG8H5WLd-3R2c3yST8Yyc_w,2581
12
+ aas_standard_parser/demo/demo_process.py,sha256=Xn9uD0xLoNx0ZvB3Lk0oYkGBRHaEfUbfqv5_SpPWYck,530
13
+ aas_standard_parser/demo/logging_handler.py,sha256=x-eX4XDU3sZTJE22rzJSiaWQ8wRMbtaFpFBAeAcbIzI,5752
14
+ aas_standard_parser-0.2.7.dist-info/licenses/LICENSE,sha256=simqYMD2P9Ikm0Kh9n7VGNpaVcm2TMVVQmECYZ_xVZ8,1065
15
+ aas_standard_parser-0.2.7.dist-info/METADATA,sha256=hLgmuUuUXjM6FkGYoPFajsss7XUdzv48apwg0wI5Ru0,4502
16
+ aas_standard_parser-0.2.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
17
+ aas_standard_parser-0.2.7.dist-info/top_level.txt,sha256=OQaK6cwYttR1-eKTz5u4M0jbwSfp4HqJ56chaf0nHnw,20
18
+ aas_standard_parser-0.2.7.dist-info/RECORD,,
@@ -1,36 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: aas-standard-parser
3
- Version: 0.2.6
4
- Summary: Some auxiliary functions for parsing standard submodels
5
- Author-email: Daniel Klein <daniel.klein@em.ag>
6
- License: MIT License
7
-
8
- Copyright (c) 2025 Fluid4.0
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- SOFTWARE.
27
-
28
- Project-URL: Homepage, https://github.com/fluid40/aas-http-client
29
- Description-Content-Type: text/markdown
30
- License-File: LICENSE
31
- Requires-Dist: typing>=3.7.4.3
32
- Requires-Dist: basyx-python-sdk>=1.2.1
33
- Dynamic: license-file
34
-
35
- # aas-standard-parser
36
- Some auxiliary functions for parsing standard submodels
@@ -1,16 +0,0 @@
1
- aas_standard_parser/__init__.py,sha256=lp7rs4UL5yebN0F69JKuNaqI8kI2_lU2LV3B0vUSXAw,687
2
- aas_standard_parser/aas_parser.py,sha256=9SDxG2YGEWlcK2Wyy70r9rOO6ExAOaN79-SbjurOci4,667
3
- aas_standard_parser/aid_parser.py,sha256=9vp8_kJRfExTmw8tjmO32n1eHFAE5ItmfPlZ2ORLZMs,14314
4
- aas_standard_parser/aimc_parser.py,sha256=3GSM-jBj-9OqNDnL7CssqogNOZEd7_fjRtxwzRZi-iA,9972
5
- aas_standard_parser/collection_helpers.py,sha256=fTQGQiC-bGD41Qx0FDDBtWhvkeZtEe6Sh-aT93ePwro,4153
6
- aas_standard_parser/reference_helpers.py,sha256=mUWlxD81aV8J-VLowjZ1prS52cFW1EVwXkaUOFL_P2Y,1037
7
- aas_standard_parser/submodel_parser.py,sha256=XH-XTBB3a0MB1NR5nAzG9C6f9hT_qG42f-ABruN3MzE,3169
8
- aas_standard_parser/utils.py,sha256=5iIPpM_ob2V9MwFL_vTbXd23doYKot30xenRmTPAquo,723
9
- aas_standard_parser/classes/aimc_parser_classes.py,sha256=PwKpuyB36urFc8YqQ6KtrG8H5WLd-3R2c3yST8Yyc_w,2581
10
- aas_standard_parser/demo/demo_process.py,sha256=Xn9uD0xLoNx0ZvB3Lk0oYkGBRHaEfUbfqv5_SpPWYck,530
11
- aas_standard_parser/demo/logging_handler.py,sha256=x-eX4XDU3sZTJE22rzJSiaWQ8wRMbtaFpFBAeAcbIzI,5752
12
- aas_standard_parser-0.2.6.dist-info/licenses/LICENSE,sha256=simqYMD2P9Ikm0Kh9n7VGNpaVcm2TMVVQmECYZ_xVZ8,1065
13
- aas_standard_parser-0.2.6.dist-info/METADATA,sha256=-ikDTRghNsQWEqvTm3X1zntFc5XrXBG_xJA66UpDc4E,1718
14
- aas_standard_parser-0.2.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
- aas_standard_parser-0.2.6.dist-info/top_level.txt,sha256=OQaK6cwYttR1-eKTz5u4M0jbwSfp4HqJ56chaf0nHnw,20
16
- aas_standard_parser-0.2.6.dist-info/RECORD,,