mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-29 13:46:49 +00:00
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:
parent
85ac88627b
commit
74e48d0797
@ -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:]:
|
||||
|
Loading…
x
Reference in New Issue
Block a user