From a72538589f6b663dfa122e510808d4d17dc21dd5 Mon Sep 17 00:00:00 2001 From: danielhrisca Date: Fri, 10 Nov 2023 14:43:54 +0200 Subject: [PATCH] fixes #949L pretty format the header block xml comment --- src/asammdf/blocks/v4_blocks.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/asammdf/blocks/v4_blocks.py b/src/asammdf/blocks/v4_blocks.py index 6c45bb148..1def886c7 100644 --- a/src/asammdf/blocks/v4_blocks.py +++ b/src/asammdf/blocks/v4_blocks.py @@ -15,6 +15,7 @@ from traceback import format_exc from typing import Any, TYPE_CHECKING import xml.etree.ElementTree as ET +from xml.dom import minidom import dateutil.tz @@ -5596,12 +5597,16 @@ def common_properties_to_xml(root, common_properties): common_properties_to_xml(common, self._common_properties) - return ( + comment_xml = ( ET.tostring(root, encoding="utf8", method="xml") .replace(b"\n", b"") .decode("utf-8") ) + comment_xml = minidom.parseString(comment_xml).toprettyxml(indent=" ") + + return "\n".join(comment_xml.splitlines()[1:]) + @comment.setter def comment(self, string): self._common_properties.clear()