mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
py3: miscellaneous strings need to be marked as bytes
This commit is contained in:
parent
8c6698abf7
commit
92052e79d4
@ -79,17 +79,17 @@ class MobiReader(object):
|
|||||||
stream = open(filename_or_stream, 'rb')
|
stream = open(filename_or_stream, 'rb')
|
||||||
|
|
||||||
raw = stream.read()
|
raw = stream.read()
|
||||||
if raw.startswith('TPZ'):
|
if raw.startswith(b'TPZ'):
|
||||||
raise TopazError(_('This is an Amazon Topaz book. It cannot be processed.'))
|
raise TopazError(_('This is an Amazon Topaz book. It cannot be processed.'))
|
||||||
if raw.startswith(b'\xeaDRMION\xee'):
|
if raw.startswith(b'\xeaDRMION\xee'):
|
||||||
raise KFXError()
|
raise KFXError()
|
||||||
|
|
||||||
self.header = raw[0:72]
|
self.header = raw[0:72]
|
||||||
self.name = self.header[:32].replace('\x00', '')
|
self.name = self.header[:32].replace(b'\x00', b'')
|
||||||
self.num_sections, = struct.unpack('>H', raw[76:78])
|
self.num_sections, = struct.unpack('>H', raw[76:78])
|
||||||
|
|
||||||
self.ident = self.header[0x3C:0x3C + 8].upper()
|
self.ident = self.header[0x3C:0x3C + 8].upper()
|
||||||
if self.ident not in ['BOOKMOBI', 'TEXTREAD']:
|
if self.ident not in [b'BOOKMOBI', b'TEXTREAD']:
|
||||||
raise MobiError('Unknown book type: %s' % repr(self.ident))
|
raise MobiError('Unknown book type: %s' % repr(self.ident))
|
||||||
|
|
||||||
self.sections = []
|
self.sections = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user