From 3fc008c4971d7f5090a42cedff7aabe44277baf8 Mon Sep 17 00:00:00 2001 From: Rolf Niepraschk <Rolf.Niepraschk@ptb.de> Date: Tue, 1 Dec 2020 11:57:36 +0100 Subject: [PATCH] much better formatting --- trans.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/trans.py b/trans.py index 62e5e7c..7b21703 100644 --- a/trans.py +++ b/trans.py @@ -21,9 +21,11 @@ def cert_to_xml(cert_doc): } cert_doc['DCC']['administrativeData']['dccSoftware'].append(s) try: - xml = render_template(dcc_template, doc=cert_doc['DCC'], utils=utils) - xml = etree.canonicalize(prettify_xml(xml, indent=2, debug=False)) - + xml = render_template(dcc_template, doc=cert_doc['DCC'], utils=utils) + xml = etree.canonicalize(xml, with_comments=True, strip_text=True) + # Bad side-effect: adds XML declaration again + xml = prettify_xml(xml, indent=2, debug=False) + xml = etree.canonicalize(xml, with_comments=True) except Exception as error: xml = '<error>' + str(error) + '</error>\n' -- GitLab