From 843928bf02f29318519bd2f01aa7374e63782cac Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 19 Feb 2021 15:53:25 +0100 Subject: [PATCH] tools (xml_tools): fix pFmtElt: default URI was not handled correctly, and attributes were missing, this patch fixes those bugs. --- sat/tools/xml_tools.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sat/tools/xml_tools.py b/sat/tools/xml_tools.py index 04797ccf..b71d8a53 100644 --- a/sat/tools/xml_tools.py +++ b/sat/tools/xml_tools.py @@ -1818,22 +1818,22 @@ def findAll(elt, namespaces=None, names=None): yield found -def pFmtElt(elt, indent=0): +def pFmtElt(elt, indent=0, defaultUri=""): """Pretty format a domish.Element""" strings = [] for child in elt.children: if domish.IElement.providedBy(child): - strings.append(pFmtElt(child, indent+2)) + strings.append(pFmtElt(child, indent+2, defaultUri=elt.defaultUri)) else: strings.append(f"{(indent+2)*' '}{child!s}") if elt.children: nochild_elt = domish.Element( - (elt.uri, elt.name), elt.defaultUri, elt.attribs, elt.localPrefixes + (elt.uri, elt.name), elt.defaultUri, elt.attributes, elt.localPrefixes ) - strings.insert(0, f"{indent*' '}{nochild_elt.toXml()[:-2]}>") + strings.insert(0, f"{indent*' '}{nochild_elt.toXml(defaultUri=defaultUri)[:-2]}>") strings.append(f"{indent*' '}") else: - strings.append(f"{indent*' '}{elt.toXml()}") + strings.append(f"{indent*' '}{elt.toXml(defaultUri=defaultUri)}") return '\n'.join(strings)