From c24472bc883160cd81dcb5b6ac4e5bcc66deabfd Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Sat, 6 Jul 2024 13:16:43 +0200 Subject: [PATCH] impl Signed-off-by: Jan Kowalleck --- serializable/__init__.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/serializable/__init__.py b/serializable/__init__.py index 482134c..9c9322a 100644 --- a/serializable/__init__.py +++ b/serializable/__init__.py @@ -510,7 +510,8 @@ def as_xml(self: Any, view_: Optional[Type[ViewType]] = None, SubElement(this_e, new_key).text = _xs_string_mod_apply(str(prop_info.custom_type(v)), prop_info.xml_string_config) elif prop_info.is_enum: - SubElement(this_e, new_key).text = _xs_string_mod_apply(str(v.value), prop_info.xml_string_config) + SubElement(this_e, new_key).text = _xs_string_mod_apply(str(v.value), + prop_info.xml_string_config) elif not prop_info.is_primitive_type(): global_klass_name = f'{prop_info.concrete_type.__module__}.{prop_info.concrete_type.__name__}' if global_klass_name in ObjectMetadataLibrary.klass_mappings: @@ -519,16 +520,19 @@ def as_xml(self: Any, view_: Optional[Type[ViewType]] = None, else: # Handle properties that have a type that is not a Python Primitive (e.g. int, float, str) if prop_info.string_format: - SubElement(this_e, new_key).text = f'{v:{prop_info.string_format}}' + SubElement(this_e, new_key).text = _xs_string_mod_apply(f'{v:{prop_info.string_format}}', + prop_info.xml_string_config) else: - SubElement(this_e, new_key).text = str(v) + SubElement(this_e, new_key).text = _xs_string_mod_apply(str(v), + prop_info.xml_string_config) elif prop_info.concrete_type in (float, int): SubElement(this_e, new_key).text = str(v) elif prop_info.concrete_type is bool: SubElement(this_e, new_key).text = str(v).lower() else: # Assume type is str - SubElement(this_e, new_key).text = _xs_string_mod_apply(str(v), prop_info.xml_string_config) + SubElement(this_e, new_key).text = _xs_string_mod_apply(str(v), + prop_info.xml_string_config) if as_string: return cast(Element, SafeElementTree.tostring(this_e, 'unicode'))