def _unpack_header_adjunct(hdr):
"""
Unpacks the adjunct from a BLUE file header dictionary. Expects
the 'adjunct' field to be a 256 byte raw string, or None (in which
case it returns with default values).
"""
# Convert the adjunct (file type specific) part of the header
file_class = int(hdr['type'] / 1000)
endian = _rep_tran[hdr['head_rep']]
hdr.update(_unpack_blue_struct(hdr['adjunct'],
_bluestructs['T%dADJUNCT' % file_class],
endian))
del hdr['adjunct']
if file_class == 3:
hdr['subr'] = _unpack_blue_struct_array(hdr['subr'],
_bluestructs['SUBRECSTRUCT'],
hdr['subrecords'], endian)
elif file_class == 5:
hdr['comp'] = _unpack_blue_struct_array(hdr['comp'],
_bluestructs['COMPSTRUCT'],
hdr['components'], endian)
hdr['quadwords'] = _unpack_blue_struct(hdr['quadwords'],
_bluestructs['T5QUADWORDS'],
endian)
elif file_class == 6:
# For Type 6000 files, the hdr['subr'] field gets filled in from
# information in the extended header, which is not unpacked
# until after the main header and header adjunct are unpacked.
# See _open_t6subrecords(), which gets called by readheader().
# Just initialize it to an empty list here.
hdr['subr'] = []
评论列表
文章目录