Skip to content

Commit

Permalink
Merge pull request #46 from rwth-iat/merge/main_in_feature_http_api
Browse files Browse the repository at this point in the history
Merge/main in feature http api
  • Loading branch information
s-heppner authored Jun 20, 2024
2 parents 69f3955 + a6af1af commit b0e1148
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 168 deletions.
6 changes: 3 additions & 3 deletions basyx/aas/adapter/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ def serialize(self, obj: ResponseData, cursor: Optional[int], stripped: bool) ->
root_elem.append(child)
etree.cleanup_namespaces(root_elem)
xml_str = etree.tostring(root_elem, xml_declaration=True, encoding="utf-8")
return xml_str
return xml_str # type: ignore[return-value]


class XmlResponseAlt(XmlResponse):
def __init__(self, *args, content_type="text/xml", **kwargs):
super().__init__(*args, **kwargs, content_type=content_type)


def result_to_xml(result: Result, **kwargs) -> etree.Element:
def result_to_xml(result: Result, **kwargs) -> etree._Element:
result_elem = etree.Element("result", **kwargs)
success_elem = etree.Element("success")
success_elem.text = xml_serialization.boolean_to_xml(result.success)
Expand All @@ -177,7 +177,7 @@ def result_to_xml(result: Result, **kwargs) -> etree.Element:
return result_elem


def message_to_xml(message: Message) -> etree.Element:
def message_to_xml(message: Message) -> etree._Element:
message_elem = etree.Element("message")
message_type_elem = etree.Element("messageType")
message_type_elem.text = str(message.message_type)
Expand Down
143 changes: 73 additions & 70 deletions basyx/aas/adapter/xml/xml_deserialization.py

Large diffs are not rendered by default.

172 changes: 87 additions & 85 deletions basyx/aas/adapter/xml/xml_serialization.py

Large diffs are not rendered by default.

9 changes: 2 additions & 7 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import os
import sys
import datetime
from sphinx.ext import intersphinx


sys.path.insert(0, os.path.abspath('../..'))
Expand Down Expand Up @@ -71,14 +70,10 @@

def on_missing_reference(app, env, node, contnode):
path = node["reftarget"].split(".")
# pyecma376_2 doesn't have a documentation we can link to, so suppress missing reference warnings.
# TODO: pyecma376_2 doesn't have a documentation we can link to, so suppress missing reference warnings.
# see: https://github.com/rwth-iat/PyECMA376-2/issues/3
if path[0] == "pyecma376_2":
return contnode
# lxml uses _Element instead of Element and _ElementTree instead of ElementTree in its documentation,
# causing missing references if untreated.
if len(path) > 2 and path[0:2] == ["lxml", "etree"] and path[2] in {"Element", "ElementTree"}:
node["reftarget"] = ".".join(path[0:2] + ["_" + path[2]] + path[3:])
return intersphinx.resolve_reference_in_inventory(env, "lxml", node, contnode)
return None


Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ urllib3>=1.26,<2.0
Werkzeug~=3.0
schemathesis~=3.7
hypothesis~=6.13
lxml-stubs~=0.5.1
4 changes: 2 additions & 2 deletions test/adapter/xml/test_xml_deserialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from basyx.aas.adapter.xml import StrictAASFromXmlDecoder, XMLConstructables, read_aas_xml_file, \
read_aas_xml_file_into, read_aas_xml_element
from basyx.aas.adapter._generic import XML_NS_MAP
from lxml import etree # type: ignore
from lxml import etree
from typing import Iterable, Type, Union


Expand Down Expand Up @@ -434,7 +434,7 @@ def __init__(self, *args, **kwargs):

class EnhancedAASDecoder(StrictAASFromXmlDecoder):
@classmethod
def construct_submodel(cls, element: etree.Element, object_class=EnhancedSubmodel, **kwargs) \
def construct_submodel(cls, element: etree._Element, object_class=EnhancedSubmodel, **kwargs) \
-> model.Submodel:
return super().construct_submodel(element, object_class=object_class, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion test/adapter/xml/test_xml_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
import unittest

from lxml import etree # type: ignore
from lxml import etree

from basyx.aas import model
from basyx.aas.adapter.xml import write_aas_xml_file, xml_serialization
Expand Down

0 comments on commit b0e1148

Please sign in to comment.