mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
EPUB Input: Speed up processing of files with very large manifest/spines
This commit is contained in:
parent
32464b666b
commit
d84a8a721a
@ -175,18 +175,18 @@ class EPUBInput(InputFormatPlugin):
|
|||||||
raise ValueError(
|
raise ValueError(
|
||||||
'EPUB files with DTBook markup are not supported')
|
'EPUB files with DTBook markup are not supported')
|
||||||
|
|
||||||
|
not_for_spine = set()
|
||||||
|
for y in opf.itermanifest():
|
||||||
|
id_ = y.get('id', None)
|
||||||
|
if id_ and y.get('media-type', None) in \
|
||||||
|
('application/vnd.adobe-page-template+xml',):
|
||||||
|
not_for_spine.add(id_)
|
||||||
|
|
||||||
for x in list(opf.iterspine()):
|
for x in list(opf.iterspine()):
|
||||||
ref = x.get('idref', None)
|
ref = x.get('idref', None)
|
||||||
if ref is None:
|
if ref is None or ref in not_for_spine:
|
||||||
x.getparent().remove(x)
|
x.getparent().remove(x)
|
||||||
continue
|
continue
|
||||||
for y in opf.itermanifest():
|
|
||||||
if y.get('id', None) == ref and y.get('media-type', None) in \
|
|
||||||
('application/vnd.adobe-page-template+xml',):
|
|
||||||
p = x.getparent()
|
|
||||||
if p is not None:
|
|
||||||
p.remove(x)
|
|
||||||
break
|
|
||||||
|
|
||||||
with open('content.opf', 'wb') as nopf:
|
with open('content.opf', 'wb') as nopf:
|
||||||
nopf.write(opf.render())
|
nopf.write(opf.render())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user