Fix #2825 ("No such file or directory" error in viewer)

This commit is contained in:
Kovid Goyal 2009-07-13 18:21:58 -06:00
parent f930919523
commit cf818b1c62
2 changed files with 10 additions and 2 deletions

View File

@ -1963,6 +1963,11 @@ class MobiWriter(object):
self._oeb.logger.warn(' Ignoring TOC entry with no href:',
child.title)
continue
if h not in self._id_offsets:
self._oeb.logger.warn(' Ignoring missing TOC entry:',
child)
continue
currentOffset = self._id_offsets[h]
# print "_generate_ctoc: child offset: 0x%X" % currentOffset

View File

@ -41,9 +41,12 @@ class SpineItem(unicode):
def __new__(cls, *args):
args = list(args)
args[0] = args[0].partition('#')[0]
obj = super(SpineItem, cls).__new__(cls, *args)
path = args[0]
ppath = path.partition('#')[0]
if not os.path.exists(path) and os.path.exists(ppath):
path = ppath
args[0] = path
obj = super(SpineItem, cls).__new__(cls, *args)
raw = open(path, 'rb').read()
raw, obj.encoding = xml_to_unicode(raw)
obj.character_count = character_count(raw)