mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
8d866f63df
commit
709099ddf1
@ -367,14 +367,18 @@ class TagX(object):
|
|||||||
def __init__(self, raw, control_byte_count):
|
def __init__(self, raw, control_byte_count):
|
||||||
self.tag = ord(raw[0])
|
self.tag = ord(raw[0])
|
||||||
self.num_values = ord(raw[1])
|
self.num_values = ord(raw[1])
|
||||||
self.bitmask = bin(ord(raw[2]))
|
self.bmask = ord(raw[2])
|
||||||
|
self.bitmask = bin(self.bmask)
|
||||||
# End of file = 1 iff last entry
|
# End of file = 1 iff last entry
|
||||||
# When it is 1 all others are 0
|
# When it is 1 all others are 0
|
||||||
self.eof = ord(raw[3])
|
self.eof = ord(raw[3])
|
||||||
|
|
||||||
|
self.is_eof = (self.eof == 1 and self.tag == 0 and self.num_values == 0
|
||||||
|
and self.bmask == 0)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return 'TAGX(tag=%02d, num_values=%d, bitmask=%r, eof=%d)' % (self.tag,
|
return 'TAGX(tag=%02d, num_values=%d, bitmask=%r (%d), eof=%d)' % (self.tag,
|
||||||
self.num_values, self.bitmask, self.eof)
|
self.num_values, self.bitmask, self.bmask, self.eof)
|
||||||
|
|
||||||
class PrimaryIndexRecord(object):
|
class PrimaryIndexRecord(object):
|
||||||
|
|
||||||
@ -424,6 +428,8 @@ class PrimaryIndexRecord(object):
|
|||||||
for i in range(num_tagx_entries):
|
for i in range(num_tagx_entries):
|
||||||
self.tagx_entries.append(TagX(tag_table[i*4:(i+1)*4],
|
self.tagx_entries.append(TagX(tag_table[i*4:(i+1)*4],
|
||||||
self.tagx_control_byte_count))
|
self.tagx_control_byte_count))
|
||||||
|
if self.tagx_entries and not self.tagx_entries[-1].is_eof:
|
||||||
|
raise ValueError('TAGX last entry is not EOF')
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user