# HG changeset patch # User Goffi # Date 1613746405 -3600 # Node ID 80f8635dc66eb7589856200af30e1f14425f9b6b # Parent 1c7f4ce6a4a2e7c2418b42c0b63509ebd37fd4e4 tools (xml_tools): fix pFmtElt: default URI was not handled correctly, and attributes were missing, this patch fixes those bugs. diff -r 1c7f4ce6a4a2 -r 80f8635dc66e sat/tools/xml_tools.py --- a/sat/tools/xml_tools.py Fri Feb 19 15:53:24 2021 +0100 +++ b/sat/tools/xml_tools.py Fri Feb 19 15:53:25 2021 +0100 @@ -1818,22 +1818,22 @@ 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)