EPUB Input: Remove non XML documents from the spine automatically, instead of erroring out

This commit is contained in:
Kovid Goyal 2012-02-28 11:21:46 +05:30
parent 013377db7e
commit b19169d192

View File

@ -321,6 +321,12 @@ class OEBReader(object):
if len(spine) == 0: if len(spine) == 0:
raise OEBError("Spine is empty") raise OEBError("Spine is empty")
self._spine_add_extra() self._spine_add_extra()
for item in spine:
if item.media_type.lower() not in OEB_DOCS:
if not hasattr(item.data, 'xpath'):
self.oeb.log.warn('The item %s is not an XML document.'
' Removing it from spine.'%item.href)
spine.remove(item)
def _guide_from_opf(self, opf): def _guide_from_opf(self, opf):
guide = self.oeb.guide guide = self.oeb.guide