Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions android2po/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,23 @@ def xml2string(tree, action):
"""
ENCODING = 'utf-8'
dom = convert.write_xml(tree, warnfunc=action.message)
return etree.tostring(dom, xml_declaration=True,
encoding=ENCODING, pretty_print=True).decode('utf-8')

# By default lxml's pretty print uses 2 spaces to indent. There's no way to
# change this without manually adding more spaces line by line.
lines = etree.tostring(dom, xml_declaration=True, encoding=ENCODING,
pretty_print=True).decode(ENCODING).split("\n")

for i in range(len(lines)):
line = lines[i]
new_line = ""
for j in range(0, len(line), 2):
if line[j:j + 2] == " ":
new_line += " "
else:
new_line += line[j:]
break
lines[i] = new_line
return "\n".join(lines)


def read_xml(action, filename, **kw):
Expand Down