From 727d96cc2229dace563ef84db4d2c2ea79cbda2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Rapinat?= Date: Fri, 20 Mar 2015 09:06:06 +0100 Subject: [PATCH] Improve TipsParse for python3 support --- po/update_po.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/po/update_po.py b/po/update_po.py index fc483569d..6c710af21 100644 --- a/po/update_po.py +++ b/po/update_po.py @@ -169,12 +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", method="xml") if sys.version_info[0] < 3: - tip = ElementTree.tostring(key, encoding="UTF-8") - else: # no python3 support yet - return - tip = tip.replace("", "") - tip = tip.replace('\n<_tip number="%(number)s">' % key.attrib, "") + tip = tip.replace("", "") + tip = tip.replace('\n<_tip number="%(number)s">' % key.attrib, "") + else: # python3 support + tip = tip.decode(encoding="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