mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-30 06:06:43 +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):
|
class XMLCombiner(object):
|
||||||
def __init__(self, filenames):
|
def __init__(self, filenames):
|
||||||
if len(filenames) == 0:
|
if len(filenames) == 0:
|
||||||
raise Exception('No filenames!')
|
raise Exception('No filenames!')
|
||||||
|
|
||||||
try:
|
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:
|
except xml.etree.ElementTree.ParseError:
|
||||||
printerr("ERROR: Unable to parse XML file %s" % f)
|
printerr("ERROR: Unable to parse XML file %s" % f)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def prettyPrint(self, etree_xml):
|
def prettyPrint(self, etree_xml):
|
||||||
minidom = xml.dom.minidom.parseString(et.tostring(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):
|
def combine(self):
|
||||||
for r in self.roots[1:]:
|
for r in self.roots[1:]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user