mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #2174 (Error with epub viewer)
This commit is contained in:
parent
5e8b74b303
commit
01b1a28392
@ -9,7 +9,7 @@ lxml based OPF parser.
|
|||||||
|
|
||||||
import sys, unittest, functools, os, mimetypes, uuid, glob, cStringIO
|
import sys, unittest, functools, os, mimetypes, uuid, glob, cStringIO
|
||||||
from urllib import unquote
|
from urllib import unquote
|
||||||
from urlparse import urlparse, urldefrag
|
from urlparse import urlparse
|
||||||
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
from dateutil import parser
|
from dateutil import parser
|
||||||
@ -258,6 +258,11 @@ class Manifest(ResourceCollection):
|
|||||||
if i.id == id:
|
if i.id == id:
|
||||||
return i.path
|
return i.path
|
||||||
|
|
||||||
|
def type_for_id(self, id):
|
||||||
|
for i in self:
|
||||||
|
if i.id == id:
|
||||||
|
return i.mime_type
|
||||||
|
|
||||||
class Spine(ResourceCollection):
|
class Spine(ResourceCollection):
|
||||||
|
|
||||||
class Item(Resource):
|
class Item(Resource):
|
||||||
@ -487,7 +492,10 @@ class OPF(object):
|
|||||||
|
|
||||||
if toc is None: return
|
if toc is None: return
|
||||||
self.toc = TOC(base_path=self.base_dir)
|
self.toc = TOC(base_path=self.base_dir)
|
||||||
if toc.lower() in ('ncx', 'ncxtoc'):
|
is_ncx = getattr(self, 'manifest', None) is not None and \
|
||||||
|
self.manifest.type_for_id(toc) is not None and \
|
||||||
|
'dtbncx' in self.manifest.type_for_id(toc)
|
||||||
|
if is_ncx or toc.lower() in ('ncx', 'ncxtoc'):
|
||||||
path = self.manifest.path_for_id(toc)
|
path = self.manifest.path_for_id(toc)
|
||||||
if path:
|
if path:
|
||||||
self.toc.read_ncx_toc(path)
|
self.toc.read_ncx_toc(path)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user