[IMP]XML write : pretty print for py2

This commit is contained in:
Fabien BOURGEOIS 2020-04-25 16:50:49 +02:00
parent 4744b46ba8
commit bb5c3a8cb8
1 changed files with 3 additions and 2 deletions

View File

@ -61,9 +61,10 @@
"Write XML file according to filename and given tree" "Write XML file according to filename and given tree"
`(do `(do
(import [os [path]] (import [os [path]]
[xml.etree.ElementTree :as ET]) [xml.etree.ElementTree :as ET]
[xml.dom [minidom]])
(if-python2 (if-python2
(setv ~g!output-xml (.tostring ET ~tree)) (setv ~g!output-xml (.toprettyxml :indent " " (.parseString minidom (.tostring ET ~tree))))
(setv ~g!output-xml (.decode (.tostring ET ~tree) "utf-8"))) (setv ~g!output-xml (.decode (.tostring ET ~tree) "utf-8")))
(setv ~g!output-path (.dirname path (.abspath path __file__)) (setv ~g!output-path (.dirname path (.abspath path __file__))
~g!fpath (+ ~g!output-path "/" ~filename)) ~g!fpath (+ ~g!output-path "/" ~filename))