|
19 | 19 |
|
20 | 20 | from basyx.aas import model |
21 | 21 |
|
22 | | -from basyx.aas.adapter.xml import XMLConstructables |
| 22 | +from basyx.aas.adapter.xml import XMLConstructables, read_aas_xml_element |
23 | 23 |
|
24 | 24 | from server.app import server_model |
25 | | -from server.app.adapter.xmlization import ServerXMLConstructables, read_server_aas_xml_element |
26 | 25 | from server.app.adapter.jsonization import ServerStrictAASFromJsonDecoder, ServerStrictStrippedAASFromJsonDecoder |
27 | 26 |
|
28 | 27 | from typing import Callable, List, Optional, Type, TypeVar, Union |
@@ -67,15 +66,16 @@ class HTTPApiDecoder: |
67 | 66 | model.Submodel: XMLConstructables.SUBMODEL, |
68 | 67 | model.SubmodelElement: XMLConstructables.SUBMODEL_ELEMENT, |
69 | 68 | model.Reference: XMLConstructables.REFERENCE, |
70 | | - |
71 | | - server_model.AssetAdministrationShellDescriptor: ServerXMLConstructables.ASSET_ADMINISTRATION_SHELL_DESCRIPTOR, |
72 | | - server_model.SubmodelDescriptor: ServerXMLConstructables.SUBMODEL_DESCRIPTOR, |
73 | | - server_model.AssetLink: ServerXMLConstructables.ASSET_LINK, |
74 | 69 | } |
75 | 70 |
|
76 | 71 | @classmethod |
77 | 72 | def check_type_support(cls, type_: type): |
78 | | - if type_ not in cls.type_constructables_map: |
| 73 | + tolerated_types = ( |
| 74 | + server_model.AssetAdministrationShellDescriptor, |
| 75 | + server_model.SubmodelDescriptor, |
| 76 | + server_model.AssetLink, |
| 77 | + ) |
| 78 | + if type_ not in cls.type_constructables_map and type_ not in tolerated_types: |
79 | 79 | raise TypeError(f"Parsing {type_} is not supported!") |
80 | 80 |
|
81 | 81 | @classmethod |
@@ -146,7 +146,7 @@ def xml(cls, data: bytes, expect_type: Type[T], stripped: bool) -> T: |
146 | 146 | cls.check_type_support(expect_type) |
147 | 147 | try: |
148 | 148 | xml_data = io.BytesIO(data) |
149 | | - rv = read_server_aas_xml_element(xml_data, cls.type_constructables_map[expect_type], |
| 149 | + rv = read_aas_xml_element(xml_data, cls.type_constructables_map[expect_type], |
150 | 150 | stripped=stripped, failsafe=False) |
151 | 151 | except (KeyError, ValueError) as e: |
152 | 152 | # xml deserialization creates an error chain. since we only return one error, return the root cause |
|
0 commit comments