def pack_ext_header(hdr, structured=0):
"""
Packs the value of the given BLUE file hdr dictionary's
'ext_header' key into the BLUE file extended header format and
updates the value of 'ext_size'. The value of 'ext_header' can be
a list of (key, value) tuples or a dict. Before writing this out
to disk at the end of a BLUE file it must be padded out to a
multiple of 512 bytes. If the keywords given are already a string
it is presumed they are already packed and the 'ext_size' field is
updated but the string itself is left alone.
If <structured> is true, any embedded Python dictionaries, lists
or tuples will pack their structure into the keywords with
them. See pack_keywords() for more info.
"""
packed = pack_keywords(hdr['ext_header'], _rep_tran[hdr['head_rep']],
structured=structured)
hdr['ext_header'] = packed
hdr['ext_size'] = len(packed)
评论列表
文章目录