def parse_block_header(fid):
"""
Parse the block header found in *fid*. Return a mapping containing
the header information.
"""
block_header = {}
for line in fid:
if line.startswith('#'):
break
toks = line.split()
key = '_'.join(toks[1:-1])[:-1]
value = toks[-1]
if key.endswith('date'):
value = datetime.strptime(value, '%Y,%j,%H:%M:%S')
block_header[key] = value
return block_header
评论列表
文章目录