Skip to content

Commit

Permalink
Merge 2870fd5 into be62b1c
Browse files Browse the repository at this point in the history
  • Loading branch information
mristin committed Feb 14, 2024
2 parents be62b1c + 2870fd5 commit b93d4e0
Show file tree
Hide file tree
Showing 2 changed files with 669 additions and 10 deletions.
33 changes: 23 additions & 10 deletions aas_core3/xmlization.py
Original file line number Diff line number Diff line change
Expand Up @@ -9340,7 +9340,7 @@ def _raise_if_has_tail_or_attrib(element: Element) -> None:

def _read_end_element(
element: Element, iterator: Iterator[Tuple[str, Element]]
) -> None:
) -> Element:
"""
Read the end element corresponding to the start :paramref:`element`
from :paramref:`iterator`.
Expand All @@ -9367,6 +9367,8 @@ def _read_end_element(

_raise_if_has_tail_or_attrib(next_element)

return next_element


def _read_text_from_element(
element: Element, iterator: Iterator[Tuple[str, Element]]
Expand All @@ -9387,14 +9389,20 @@ def _read_text_from_element(
"""
_raise_if_has_tail_or_attrib(element)

if element.text is None:
raise DeserializationException(
"Expected an element with text, but got an element with no text."
)

text = element.text

_read_end_element(element, iterator)
end_element = _read_end_element(
element,
iterator,
)

if text is None:
if end_element.text is None:
raise DeserializationException(
"Expected an element with text, but got an element with no text."
)

text = end_element.text

return text

Expand Down Expand Up @@ -9520,10 +9528,15 @@ def _read_str_from_element_text(
# the ``element`` to contain *some* text. In contrast, this function
# can also deal with empty text, in which case it returns an empty string.

_raise_if_has_tail_or_attrib(element)
result = element.text if element.text is not None else ""
text = element.text

_read_end_element(element, iterator)
end_element = _read_end_element(element, iterator)

if text is None:
text = end_element.text

_raise_if_has_tail_or_attrib(element)
result = text if text is not None else ""

return result

Expand Down
Loading

0 comments on commit b93d4e0

Please sign in to comment.