MOBI Output: Don't error out if indexing fails

This commit is contained in:
Kovid Goyal 2009-07-18 14:47:30 -06:00
parent 8290e98838
commit 50d6e86de8

View File

@ -189,15 +189,15 @@ class Serializer(object):
path = urldefrag(ref.href)[0] path = urldefrag(ref.href)[0]
if hrefs[path].media_type not in OEB_DOCS: if hrefs[path].media_type not in OEB_DOCS:
continue continue
if ref.type == 'other.start' : if ref.type == 'other.start' :
# Kindle-specific 'Start Reading' directive # Kindle-specific 'Start Reading' directive
buffer.write('<reference title="Startup Page" ') buffer.write('<reference title="Startup Page" ')
buffer.write('type="start" ') buffer.write('type="start" ')
self.serialize_href(ref.href) self.serialize_href(ref.href)
# Space required or won't work, I kid you not # Space required or won't work, I kid you not
buffer.write(' />') buffer.write(' />')
else: else:
buffer.write('<reference type="') buffer.write('<reference type="')
self.serialize_text(ref.type, quot=True) self.serialize_text(ref.type, quot=True)
buffer.write('" ') buffer.write('" ')
@ -657,7 +657,7 @@ class MobiWriter(object):
thisRecordPrime = thisRecord thisRecordPrime = thisRecord
if (offset + length) // RECORD_SIZE > thisRecord : if (offset + length) // RECORD_SIZE > thisRecord :
thisRecordPrime = (offset + length) // RECORD_SIZE thisRecordPrime = (offset + length) // RECORD_SIZE
sectionChangesInThisRecord = True sectionChangesInThisRecord = True
sectionChangedInRecordNumber = thisRecordPrime sectionChangedInRecordNumber = thisRecordPrime
self._currentSectionIndex += 1 # <<< self._currentSectionIndex += 1 # <<<
@ -669,7 +669,7 @@ class MobiWriter(object):
continue continue
# If no one has taken the openingNode slot, it must be us # If no one has taken the openingNode slot, it must be us
# This could happen before detecting a section change # This could happen before detecting a section change
if self._HTMLRecords[thisRecord].openingNode == -1 : if self._HTMLRecords[thisRecord].openingNode == -1 :
self._HTMLRecords[thisRecord].openingNode = myIndex self._HTMLRecords[thisRecord].openingNode = myIndex
self._HTMLRecords[thisRecord].openingNodeParent = self._currentSectionIndex self._HTMLRecords[thisRecord].openingNodeParent = self._currentSectionIndex
@ -1468,7 +1468,7 @@ class MobiWriter(object):
record0.write('\0\0\0\x01') record0.write('\0\0\0\x01')
# 0xb8 - 0xbb : FCIS record number # 0xb8 - 0xbb : FCIS record number
if FCIS_FLIS : if FCIS_FLIS and self._indexable:
# Write these if FCIS/FLIS turned on # Write these if FCIS/FLIS turned on
# 0xb8 - 0xbb : FCIS record number # 0xb8 - 0xbb : FCIS record number
record0.write(pack('>I', self._fcis_number)) record0.write(pack('>I', self._fcis_number))