This commit is contained in:
Kovid Goyal 2012-03-16 09:02:18 +05:30
parent a9f0a04128
commit c4ed54aaf1
2 changed files with 31 additions and 5 deletions

View File

@ -652,9 +652,26 @@ class Tag(object): # {{{
INTERPRET_MAP = {
'subchapter': {
21 : ('Parent chapter index', 'parent_index')
21 : ('Parent chapter index', 'parent_index'),
5 : ('Unknown (koffs)', 'koffs'),
},
'section' : {
6 : ('File Index', 'pos_fid'),
},
'section_with_subsections' : {
6 : ('File Index', 'pos_fid'),
22 : ('First subsection index', 'first_child_index'),
23 : ('Last subsection index', 'last_child_index'),
},
'subsection' : {
6 : ('File Index', 'pos_fid'),
21 : ('Parent section index', 'parent_index'),
},
'article' : {
5 : ('Class offset in cncx', 'class_offset'),
21 : ('Parent section index', 'parent_index'),
@ -707,13 +724,17 @@ class Tag(object): # {{{
try:
self.desc, self.attr = td[tag_type]
except:
print ('Unknown tag value: %d'%tag_type)
print ('Unknown tag value: %d in entry type: %s'%(tag_type,
entry_type))
self.desc = '??Unknown (tag value: %d type: %s)'%(
tag_type, entry_type)
self.attr = 'unknown'
if '_offset' in self.attr:
self.cncx_value = cncx[self.value]
if self.attr == 'pos_fid':
print (1111111, vals)
def __str__(self):
if self.cncx_value is not None:
return '%s : %r [%r]'%(self.desc, self.value, self.cncx_value)
@ -738,6 +759,9 @@ class IndexEntry(object): # {{{
0x0f : 'chapter',
0x6f : 'chapter_with_subchapters',
0x1f : 'subchapter',
0x8f : 'section',
0xef : 'section_with_subsections',
0x9f : 'subsection',
# Present in periodicals
0xdf : 'periodical',
0xff : 'section',

View File

@ -105,9 +105,11 @@ def get_tag_map(control_byte_count, tags, data, start, end):
if value != 0:
if value == mask:
if count_set_bits(mask) > 1:
# If all bits of masked value are set and the mask has more than one bit, a variable width value
# will follow after the control bytes which defines the length of bytes (NOT the value count!)
# which will contain the corresponding variable width values.
# If all bits of masked value are set and the mask has more
# than one bit, a variable width value will follow after
# the control bytes which defines the length of bytes (NOT
# the value count!) which will contain the corresponding
# variable width values.
value, consumed = decint(data[data_start:])
data_start += consumed
ptags.append((tag, None, value, values_per_entry))