From 37410d60891999ffee37b128ec82afe7c86c1c57 Mon Sep 17 00:00:00 2001 From: j Date: Sat, 8 Jun 2024 12:23:25 +0100 Subject: [PATCH] use list instead of get_children --- oml/media/epub.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/oml/media/epub.py b/oml/media/epub.py index 552a134..92ab289 100644 --- a/oml/media/epub.py +++ b/oml/media/epub.py @@ -68,17 +68,17 @@ def cover(path): if manifest: manifest = manifest[0] if metadata and manifest: - for e in metadata.getchildren(): + for e in list(metadata): if e.tag == '{http://www.idpf.org/2007/opf}meta' and e.attrib.get('name') == 'cover': cover_id = e.attrib['content'] - for e in manifest.getchildren(): + for e in list(manifest): if e.attrib['id'] == cover_id: filename = unquote(e.attrib['href']) filename = normpath(os.path.join(os.path.dirname(opf[0]), filename)) if filename in files: return use(filename) if manifest: - images = [e for e in manifest.getchildren() if 'image' in e.attrib['media-type']] + images = [e for e in list(manifest) if 'image' in e.attrib['media-type']] if images: image_data = [] for e in images: @@ -89,7 +89,7 @@ def cover(path): if image_data: image_data.sort(key=lambda name: z.getinfo(name).file_size) return use(image_data[-1]) - for e in manifest.getchildren(): + for e in list(manifest): if 'html' in e.attrib['media-type']: filename = unquote(e.attrib['href']) filename = normpath(os.path.join(os.path.dirname(opf[0]), filename)) @@ -118,7 +118,7 @@ def info(epub): metadata = info.findall('{http://www.idpf.org/2007/opf}metadata') if metadata: metadata = metadata[0] - for e in metadata.getchildren(): + for e in list(metadata): if e.text and e.text.strip() and e.text not in ('unknown', 'none'): key = e.tag.split('}')[-1] key = { @@ -148,7 +148,7 @@ def info(epub): for point in nav_map.findall('{http://www.daisy.org/z3986/2005/ncx/}navPoint'): label = point.find('{http://www.daisy.org/z3986/2005/ncx/}navLabel') if label: - txt = label.getchildren()[0].text + txt = list(label)[0].text if txt: contents.append(txt) if contents: