aas-standard-parser 0.3.3__tar.gz → 0.3.4__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.
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/PKG-INFO +1 -1
- aas_standard_parser-0.3.4/aas_standard_parser/classes/descriptor_json_helper_classes.py +12 -0
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser/descriptor_json_helper.py +30 -0
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser/utils.py +23 -0
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser.egg-info/PKG-INFO +1 -1
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser.egg-info/SOURCES.txt +3 -1
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/pyproject.toml +1 -1
- aas_standard_parser-0.3.4/tests/test_descriptor_json_helper.py +18 -0
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/LICENSE +0 -0
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/README.md +0 -0
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser/__init__.py +0 -0
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser/aas_parser.py +0 -0
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser/aid_parser.py +0 -0
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser/aimc_parser.py +0 -0
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser/classes/aimc_parser_classes.py +0 -0
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser/collection_helpers.py +0 -0
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser/demo/demo_process.py +0 -0
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser/demo/logging_handler.py +0 -0
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser/reference_helpers.py +0 -0
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser/submodel_json_helper.py +0 -0
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser/submodel_parser.py +0 -0
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser/version_check.py +0 -0
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser.egg-info/dependency_links.txt +0 -0
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser.egg-info/requires.txt +0 -0
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser.egg-info/top_level.txt +0 -0
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/setup.cfg +0 -0
- {aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/tests/test_aimc_parser.py +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""Helper classes for descriptor JSON parsing."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class EndPointHrefData:
|
|
5
|
+
"""Class to represent an endpoint href data structure."""
|
|
6
|
+
|
|
7
|
+
def __init__(self, href: str):
|
|
8
|
+
"""Initialize the EndPointHrefData with the given href."""
|
|
9
|
+
self.href: str = href
|
|
10
|
+
self.base_url: str = ""
|
|
11
|
+
self.identifier: str = ""
|
|
12
|
+
self.identifier_encoded: str = ""
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
4
|
|
|
5
|
+
from aas_standard_parser.classes.descriptor_json_helper_classes import EndPointHrefData
|
|
6
|
+
from aas_standard_parser.utils import decode_base_64, encode_base_64
|
|
7
|
+
|
|
5
8
|
logger = logging.getLogger(__name__)
|
|
6
9
|
|
|
7
10
|
|
|
@@ -32,3 +35,30 @@ def get_endpoint_hrefs(descriptor_data: dict) -> list[str]:
|
|
|
32
35
|
:return: A list of href strings extracted from the endpoints.
|
|
33
36
|
"""
|
|
34
37
|
return [endpoint.get("protocolInformation", {}).get("href", "") for endpoint in descriptor_data.get("endpoints", [])]
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def parse_endpoint_href(href: str) -> EndPointHrefData | None:
|
|
41
|
+
"""Parse the endpoint href into its components.
|
|
42
|
+
|
|
43
|
+
:param href: The href string to parse.
|
|
44
|
+
:return: An EndPointHrefData object containing parsed components.
|
|
45
|
+
"""
|
|
46
|
+
if "shells/" not in href and "submodels/" not in href:
|
|
47
|
+
logger.warning(f"Invalid href format: {href}")
|
|
48
|
+
return None
|
|
49
|
+
|
|
50
|
+
split_str = ""
|
|
51
|
+
if "/shells/" in href:
|
|
52
|
+
split_str = "/shells/"
|
|
53
|
+
elif "/submodels/" in href:
|
|
54
|
+
split_str = "/submodels/"
|
|
55
|
+
|
|
56
|
+
base_url: str = href.split(split_str, maxsplit=1)[0]
|
|
57
|
+
identifier: str = href.split(split_str)[1]
|
|
58
|
+
|
|
59
|
+
href_data = EndPointHrefData(href)
|
|
60
|
+
href_data.base_url = base_url
|
|
61
|
+
href_data.identifier = identifier
|
|
62
|
+
href_data.identifier_encoded = encode_base_64(identifier)
|
|
63
|
+
|
|
64
|
+
return href_data
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""Utility functions for AAS standard parser."""
|
|
2
2
|
|
|
3
|
+
import base64
|
|
3
4
|
import json
|
|
4
5
|
import logging
|
|
5
6
|
from pathlib import Path
|
|
@@ -48,3 +49,25 @@ def _convert_to_object(content: dict) -> Any | None:
|
|
|
48
49
|
logger.error(f"Decoding error: {e}")
|
|
49
50
|
logger.error(f"In JSON: {content}")
|
|
50
51
|
return None
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def decode_base_64(text: str) -> str:
|
|
55
|
+
"""Decode a Base64 encoded string.
|
|
56
|
+
|
|
57
|
+
:param text: Base64 encoded string to decode
|
|
58
|
+
:return: Decoded string
|
|
59
|
+
"""
|
|
60
|
+
text_bytes = text.encode("utf-8")
|
|
61
|
+
base64_bytes = base64.b64encode(text_bytes)
|
|
62
|
+
return base64_bytes.decode("utf-8")
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def encode_base_64(text: str) -> str:
|
|
66
|
+
"""Encode a string to Base64.
|
|
67
|
+
|
|
68
|
+
:param text: String to encode
|
|
69
|
+
:return: Base64 encoded string
|
|
70
|
+
"""
|
|
71
|
+
text_bytes = text.encode("utf-8")
|
|
72
|
+
base64_bytes = base64.b64decode(text_bytes)
|
|
73
|
+
return base64_bytes.decode("utf-8")
|
{aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser.egg-info/SOURCES.txt
RENAMED
|
@@ -18,6 +18,8 @@ aas_standard_parser.egg-info/dependency_links.txt
|
|
|
18
18
|
aas_standard_parser.egg-info/requires.txt
|
|
19
19
|
aas_standard_parser.egg-info/top_level.txt
|
|
20
20
|
aas_standard_parser/classes/aimc_parser_classes.py
|
|
21
|
+
aas_standard_parser/classes/descriptor_json_helper_classes.py
|
|
21
22
|
aas_standard_parser/demo/demo_process.py
|
|
22
23
|
aas_standard_parser/demo/logging_handler.py
|
|
23
|
-
tests/test_aimc_parser.py
|
|
24
|
+
tests/test_aimc_parser.py
|
|
25
|
+
tests/test_descriptor_json_helper.py
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from basyx.aas import model
|
|
3
|
+
|
|
4
|
+
from aas_standard_parser.descriptor_json_helper import parse_endpoint_href
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@pytest.fixture(scope="module")
|
|
8
|
+
def href() -> model.Property:
|
|
9
|
+
# create a Submodel
|
|
10
|
+
return "http://aas-server:8075/shells/aHR0cHM6Ly9mbHVpZDQwLmRlL2lkcy9zaGVsbC81NzkzXzU0NDlfNzgzMF80MjIz"
|
|
11
|
+
|
|
12
|
+
def test_001_get_mapping_configuration_root_element(href: str):
|
|
13
|
+
href_data = parse_endpoint_href(href)
|
|
14
|
+
|
|
15
|
+
assert href_data is not None
|
|
16
|
+
assert href_data.base_url == "http://aas-server:8075"
|
|
17
|
+
assert href_data.identifier == "aHR0cHM6Ly9mbHVpZDQwLmRlL2lkcy9zaGVsbC81NzkzXzU0NDlfNzgzMF80MjIz"
|
|
18
|
+
assert href_data.identifier_encoded == "https://fluid40.de/ids/shell/5793_5449_7830_4223"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser/collection_helpers.py
RENAMED
|
File without changes
|
{aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser/demo/demo_process.py
RENAMED
|
File without changes
|
{aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser/demo/logging_handler.py
RENAMED
|
File without changes
|
{aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser/reference_helpers.py
RENAMED
|
File without changes
|
{aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser/submodel_json_helper.py
RENAMED
|
File without changes
|
{aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser/submodel_parser.py
RENAMED
|
File without changes
|
{aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser/version_check.py
RENAMED
|
File without changes
|
|
File without changes
|
{aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser.egg-info/requires.txt
RENAMED
|
File without changes
|
{aas_standard_parser-0.3.3 → aas_standard_parser-0.3.4}/aas_standard_parser.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|