Skip to content

Commit 08e1110

Browse files
authored
Merge pull request #1987 from jan-cerny/issue1817_workaround
Produce pretty output by autotailor
2 parents b7f6aa3 + b9a4160 commit 08e1110

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

utils/autotailor

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import re
2323
import sys
2424
import pathlib
2525
import xml.etree.ElementTree as ET
26+
import xml.dom.minidom
2627

2728

2829
ALL_NS = {
@@ -110,10 +111,10 @@ class Tailoring:
110111
change.set("idref", self._full_var_id(varname))
111112
change.text = str(value)
112113

113-
if location == "-":
114-
location = sys.stdout.buffer
115-
116-
ET.ElementTree(root).write(location)
114+
root_str = ET.tostring(root)
115+
pretty_xml = xml.dom.minidom.parseString(root_str).toprettyxml()
116+
with open(location, "w") if location != "-" else sys.stdout as f:
117+
f.write(pretty_xml)
117118

118119

119120
def parse_args():

0 commit comments

Comments
 (0)