changeset 3466:80f8635dc66e

tools (xml_tools): fix pFmtElt: default URI was not handled correctly, and attributes were missing, this patch fixes those bugs.
author Goffi <goffi@goffi.org>
date Fri, 19 Feb 2021 15:53:25 +0100
parents 1c7f4ce6a4a2
children 5901a7170528
files sat/tools/xml_tools.py
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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*' '}</{nochild_elt.name}>")
     else:
-        strings.append(f"{indent*' '}{elt.toXml()}")
+        strings.append(f"{indent*' '}{elt.toXml(defaultUri=defaultUri)}")
     return '\n'.join(strings)