From 88f5fbeb9e44a18b0ad82b5e77412293d84e4c9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Rapinat?= Date: Fri, 20 Mar 2015 09:24:46 +0100 Subject: [PATCH] Improve TipsParse for python3 support --- po/update_po.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/po/update_po.py b/po/update_po.py index 2feac19b5..594402455 100644 --- a/po/update_po.py +++ b/po/update_po.py @@ -169,9 +169,13 @@ def TipsParse(filename, mark): tips = open('../data/tips.xml.in.h', 'w') marklist = root.iter(mark) for key in marklist: - tip = ElementTree.tostring(key, encoding="UTF-8") - tip = tip.replace("", "") - tip = tip.replace('\n<_tip number="%(number)s">' % key.attrib, "") + tip = ElementTree.tostring(key, encoding="UTF-8", method="xml") + if sys.version_info[0] < 3: + tip = tip.replace("", "") + tip = tip.replace('\n<_tip number="%(number)s">' % key.attrib, "") + else: # python3 support + tip = tip.decode("utf-8") + tip = tip.replace('<_tip number="%(number)s">' % key.attrib, "") tip = tip.replace("
", "
") #tip = tip.replace("\n\n", "\n") # special case tip 7 #tip = tip.replace("\n", "") # special case tip 18