mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #2624 (KeyError: 'last_læight_of_the_sun')
This commit is contained in:
parent
5b1aacfdca
commit
77bfb1c08d
@ -478,15 +478,15 @@ class MobiWriter(object):
|
||||
# Variables for trailing byte sequence
|
||||
tbsType = 0x00
|
||||
tbSequence = ""
|
||||
|
||||
|
||||
# Generate TBS for type 0x002 - mobi_book
|
||||
if self._initialIndexRecordFound == False :
|
||||
|
||||
|
||||
# Is there any indexed content yet?
|
||||
if self._HTMLRecords[nrecords].currentSectionNodeCount == -1 :
|
||||
# No indexing data - write vwi length of 1 only
|
||||
tbSequence = decint(len(tbSequence) + 1, DECINT_FORWARD)
|
||||
|
||||
|
||||
else :
|
||||
# First indexed HTML record is a special case
|
||||
# One or more nodes
|
||||
@ -495,7 +495,7 @@ class MobiWriter(object):
|
||||
tbsType = 2
|
||||
else :
|
||||
tbsType = 6
|
||||
|
||||
|
||||
tbSequence = decint(tbsType, DECINT_FORWARD)
|
||||
tbSequence += decint(0x00, DECINT_FORWARD)
|
||||
# Don't write a nodecount for opening type 2 record
|
||||
@ -1104,7 +1104,7 @@ class MobiWriter(object):
|
||||
exth.write(data)
|
||||
nrecs += 1
|
||||
if oeb.metadata.cover:
|
||||
id = str(oeb.metadata.cover[0])
|
||||
id = unicode(oeb.metadata.cover[0])
|
||||
item = oeb.manifest.ids[id]
|
||||
href = item.href
|
||||
index = self._images[href] - 1
|
||||
|
@ -725,7 +725,7 @@ class Manifest(object):
|
||||
self._data = data
|
||||
|
||||
def __repr__(self):
|
||||
return 'Item(id=%r, href=%r, media_type=%r)' \
|
||||
return u'Item(id=%r, href=%r, media_type=%r)' \
|
||||
% (self.id, self.href, self.media_type)
|
||||
|
||||
def _parse_xhtml(self, data):
|
||||
|
@ -40,7 +40,7 @@ class SVGRasterizer(object):
|
||||
@classmethod
|
||||
def generate(cls, opts):
|
||||
return cls()
|
||||
|
||||
|
||||
def __call__(self, oeb, context):
|
||||
oeb.logger.info('Rasterizing SVG images...')
|
||||
self.oeb = oeb
|
||||
@ -98,7 +98,7 @@ class SVGRasterizer(object):
|
||||
data = "data:%s;base64,%s" % (linkee.media_type, data)
|
||||
elem.attrib[XLINK('href')] = data
|
||||
return svg
|
||||
|
||||
|
||||
def rasterize_spine(self):
|
||||
for item in self.oeb.spine:
|
||||
html = item.data
|
||||
@ -182,12 +182,12 @@ class SVGRasterizer(object):
|
||||
elem.text = None
|
||||
for child in elem:
|
||||
elem.remove(child)
|
||||
|
||||
|
||||
def rasterize_cover(self):
|
||||
covers = self.oeb.metadata.cover
|
||||
if not covers:
|
||||
return
|
||||
cover = self.oeb.manifest.ids[str(covers[0])]
|
||||
cover = self.oeb.manifest.ids[unicode(covers[0])]
|
||||
if not cover.media_type == SVG_MIME:
|
||||
return
|
||||
width = (self.profile.width / 72) * self.profile.dpi
|
||||
|
Loading…
x
Reference in New Issue
Block a user