Skip to content

Commit

Permalink
Merge branch 'main' into wip/dev-4485-xmllib-add-permissions-to-dsp-i…
Browse files Browse the repository at this point in the history
…nbuilt-resource-values
  • Loading branch information
jnussbaum authored Dec 23, 2024
2 parents fec5d29 + 895274b commit 0d03a7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/dsp_tools/xmllib/models/dsp_base_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ def serialise(self) -> etree._Element:
res_ele.extend(self._serialise_geometry_shape())
if self.comments:
res_ele.extend(serialise_values(cast(list[Value], self.comments)))

return res_ele

def _serialise_resource_element(self) -> etree._Element:
Expand Down
8 changes: 4 additions & 4 deletions src/dsp_tools/xmllib/serialise/serialise_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ def _serialise_complete_simple_text_prop(values: list[SimpleText], prop_name: st
def _serialise_complete_richtext_prop(values: list[Richtext], prop_name: str) -> etree._Element:
prop = _serialise_generic_prop(prop_name, "text")
for val in values:
val_ele = _serialise_generic_element(val, "text")
val_ele = _serialise_generic_element(val, "text") # produces wrong text content
val_ele.attrib["encoding"] = "xml"
prop.append(_create_richtext_elements_from_string(val, val_ele))
prop.append(_create_richtext_elements_from_string(val, val_ele)) # overwrite the wrong text content
return prop


Expand All @@ -137,10 +137,10 @@ def _create_richtext_elements_from_string(value: Richtext, text_element: etree._
except etree.XMLSyntaxError as err:
msg = (
f"The resource with the ID '{value.resource_id}' and the property '{value.prop_name}' "
f"contains richtext that is invalid XMl."
f"contains richtext which is not in correct XML syntax."
)
msg += f"\nOriginal error message: {err.msg}"
msg += f"\nEventual line/column numbers are relative to this text: {pseudo_xml}"
msg += f"\nPotential line/column numbers are relative to this text: {pseudo_xml}"
raise InputError(msg) from None
new_element.text = parsed.text # everything before the first child tag
new_element.extend(list(parsed)) # all (nested) children of the pseudo-xml
Expand Down

0 comments on commit 0d03a7c

Please sign in to comment.