kodi/xml_merge.py: make python3 compatible; bug fixes

* decode byte object
* f was not visible in exception, resulting in an unhanled second exception
* fix indenting
This commit is contained in:
MilhouseVH 2019-10-24 22:51:28 +01:00
parent 85ac88627b
commit 74e48d0797

View File

@ -18,17 +18,19 @@ class hashabledict(dict):
class XMLCombiner(object):
def __init__(self, filenames):
if len(filenames) == 0:
raise Exception('No filenames!')
raise Exception('No filenames!')
try:
self.roots = [et.parse(f).getroot() for f in filenames]
self.roots = []
for f in filenames:
self.roots.append(et.parse(f).getroot())
except xml.etree.ElementTree.ParseError:
printerr("ERROR: Unable to parse XML file %s" % f)
raise
printerr("ERROR: Unable to parse XML file %s" % f)
raise
def prettyPrint(self, etree_xml):
minidom = xml.dom.minidom.parseString(et.tostring(etree_xml))
return "\n".join([line for line in minidom.toprettyxml(indent=" ", encoding="utf-8").split('\n') if line.strip() != ""])
return "\n".join([line for line in minidom.toprettyxml(indent=" ", encoding="utf-8").decode('utf-8').split('\n') if line.strip() != ""])
def combine(self):
for r in self.roots[1:]: