Skip to content

Commit b9a4160

Browse files
committed
Produce pretty output by autotailor
If the autotailor will produce pretty output it will work around issue #1817.
1 parent b746e31 commit b9a4160

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)