mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Don't trim <guide/> references, as they may *not* be spine items.
This commit is contained in:
parent
14db43a40b
commit
fc246ebdd5
@ -9,6 +9,7 @@ __copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
from urlparse import urldefrag
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
import cssutils
|
import cssutils
|
||||||
from calibre.ebooks.oeb.base import XPNSMAP, CSS_MIME, OEB_DOCS
|
from calibre.ebooks.oeb.base import XPNSMAP, CSS_MIME, OEB_DOCS
|
||||||
@ -29,6 +30,11 @@ class ManifestTrimmer(object):
|
|||||||
used.add(oeb.manifest.hrefs[item.value])
|
used.add(oeb.manifest.hrefs[item.value])
|
||||||
elif item.value in oeb.manifest.ids:
|
elif item.value in oeb.manifest.ids:
|
||||||
used.add(oeb.manifest.ids[item.value])
|
used.add(oeb.manifest.ids[item.value])
|
||||||
|
for ref in oeb.guide.values():
|
||||||
|
path, _ = urldefrag(ref.href)
|
||||||
|
if path in oeb.manifest.hrefs:
|
||||||
|
used.add(oeb.manifest.hrefs[path])
|
||||||
|
# TOC items are required to be in the spine
|
||||||
for item in oeb.spine:
|
for item in oeb.spine:
|
||||||
used.add(item)
|
used.add(item)
|
||||||
unchecked = used
|
unchecked = used
|
||||||
@ -56,7 +62,6 @@ class ManifestTrimmer(object):
|
|||||||
cssutils.replaceUrls(sheet, replacer)
|
cssutils.replaceUrls(sheet, replacer)
|
||||||
used.update(new)
|
used.update(new)
|
||||||
unchecked = new
|
unchecked = new
|
||||||
# All guide and TOC items are required to be in the spine
|
|
||||||
for item in oeb.manifest.values():
|
for item in oeb.manifest.values():
|
||||||
if item not in used:
|
if item not in used:
|
||||||
oeb.logger.info('Trimming %r from manifest' % item.href)
|
oeb.logger.info('Trimming %r from manifest' % item.href)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user