diff --git a/src/dsp_tools/xmllib/internal_helpers.py b/src/dsp_tools/xmllib/internal_helpers.py index 80c1f824f..8014e1d08 100644 --- a/src/dsp_tools/xmllib/internal_helpers.py +++ b/src/dsp_tools/xmllib/internal_helpers.py @@ -3,15 +3,12 @@ import warnings from typing import Any -from lxml import etree - from dsp_tools.models.custom_warnings import DspToolsUserInfo from dsp_tools.models.custom_warnings import DspToolsUserWarning from dsp_tools.models.exceptions import InputError from dsp_tools.xmllib.models.config_options import NewlineReplacement from dsp_tools.xmllib.models.config_options import Permissions from dsp_tools.xmllib.models.values import Richtext -from dsp_tools.xmllib.models.values import Value from dsp_tools.xmllib.value_checkers import is_string_like from dsp_tools.xmllib.value_converters import replace_newlines_with_tags @@ -91,18 +88,3 @@ def check_and_fix_collection_input(value: Any, prop_name: str, res_id: str) -> l raise InputError(msg) case _: return [value] - - -def serialise_values_of_the_same_property(values: list[Value]) -> etree._Element: - """ - Takes a list of values with the same property name and serialises them as one element. - - Args: - values: List of values to serialise - - Returns: - etree Element to add to the resource - """ - main_prop = values[0].make_prop() - main_prop.extend([prop.make_element() for prop in values]) - return main_prop diff --git a/src/dsp_tools/xmllib/models/dsp_base_resources.py b/src/dsp_tools/xmllib/models/dsp_base_resources.py index 3a0f5c349..24e67d4c5 100644 --- a/src/dsp_tools/xmllib/models/dsp_base_resources.py +++ b/src/dsp_tools/xmllib/models/dsp_base_resources.py @@ -13,7 +13,6 @@ from dsp_tools.models.exceptions import InputError from dsp_tools.xmllib.internal_helpers import check_and_fix_collection_input from dsp_tools.xmllib.internal_helpers import create_richtext_with_checks -from dsp_tools.xmllib.internal_helpers import serialise_values_of_the_same_property from dsp_tools.xmllib.models.config_options import NewlineReplacement from dsp_tools.xmllib.models.config_options import Permissions from dsp_tools.xmllib.models.geometry import Circle @@ -407,7 +406,7 @@ def serialise(self) -> etree._Element: res_ele = self._serialise_resource_element() res_ele.extend(self._serialise_geometry_shape()) if self.comments: - res_ele.append(serialise_values_of_the_same_property(cast(list[Value], self.comments))) + res_ele.extend(serialise_values(cast(list[Value], self.comments))) return res_ele def _serialise_resource_element(self) -> etree._Element: @@ -649,10 +648,8 @@ def add_migration_metadata( def serialise(self) -> etree._Element: res_ele = self._serialise_resource_element() self._final_checks() - if self.comments: - res_ele.append(serialise_values_of_the_same_property(cast(list[Value], self.comments))) - if self.link_to: - res_ele.append(serialise_values_of_the_same_property(cast(list[Value], self.link_to))) + generic_vals = self.comments + self.link_to + res_ele.extend(serialise_values(cast(list[Value], generic_vals))) return res_ele def _final_checks(self) -> None: