def _read_header(self, pltfile):
nheader = struct.calcsize(self._headerfmt)<EOL>names = [r.key for r in self._header_struct]<EOL>binheader = pltfile.read(nheader)<EOL>def decode_header(bsaflag='<STR_LIT:@>'):<EOL><INDENT>h = dict(zip(names, struct.unpack(bsaflag+self._headerfmt, binheader)))<EOL>h['<STR_LIT>'] = bsaflag<EOL>return h<EOL><DEDENT>for flag in '<STR_LIT>':<EOL><INDENT>header = decode_header(flag)<EOL>if header['<STR_LIT>'] == <NUM_LIT:3>:<EOL><INDENT>break   <EOL><DEDENT>header = None<EOL><DEDENT>if header is None:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>for rec in self._header_struct:<EOL><INDENT>if not rec.is_legal_dict(header):<EOL><INDENT>warnings.warn("<STR_LIT>" % (rec.key, header[rec.key]))<EOL><DEDENT><DEDENT>return header<EOL>
Read header bytes, try all possibilities for byte order/size/alignment.