def _parse (self):
feedparser = FeedParser (Message)<EOL>binarychunks = {}<EOL>sizeinfo = None<EOL>headxml = None<EOL>self.fp.seek (<NUM_LIT:0>, <NUM_LIT:0>)<EOL>while True:<EOL><INDENT>data = self.fp.readline ()<EOL>if not data:<EOL><INDENT>break<EOL><DEDENT>feedparser.feed (data)<EOL>skip = (data == '<STR_LIT:\n>' and<EOL>len (feedparser._msgstack) == <NUM_LIT:3> and<EOL>feedparser._msgstack[-<NUM_LIT:1>].get_content_type () in ('<STR_LIT>',<EOL>'<STR_LIT>'))<EOL>if skip:<EOL><INDENT>msg = feedparser._msgstack[-<NUM_LIT:1>]<EOL>ident = msg['<STR_LIT>']<EOL>assert ident.endswith ('<STR_LIT>'), '<STR_LIT>'<EOL>binarychunks[ident] = self.fp.tell ()<EOL>if sizeinfo is None:<EOL><INDENT>headxml, sizeinfo, tagpfx = _extract_size_info (feedparser)<EOL><DEDENT>kind = ident.split ('<STR_LIT:/>')[-<NUM_LIT:1>]<EOL>assert kind in sizeinfo, '<STR_LIT>' % kind<EOL>self.fp.seek (sizeinfo[kind] + <NUM_LIT:1>, <NUM_LIT:1>) <EOL>sample = self.fp.read (<NUM_LIT:16>)<EOL>assert sample.startswith ('<STR_LIT>'), '<STR_LIT>' % sample<EOL>self.fp.seek (-<NUM_LIT:16>, <NUM_LIT:1>) <EOL><DEDENT>if any([k.split('<STR_LIT:/>')[<NUM_LIT:3>] == '<STR_LIT:3>' for k in binarychunks.iterkeys()]):<EOL><INDENT>break<EOL><DEDENT><DEDENT>if headxml is None:<EOL><INDENT>raise RuntimeError ('<STR_LIT>')<EOL><DEDENT>self.mimemsg = feedparser.close ()<EOL>self.headxml = headxml<EOL>self.sizeinfo = sizeinfo<EOL>self.binarychunks = binarychunks<EOL>headsize, intsize = self.calc_intsize()<EOL><INDENT>self.n_integrations = len (self.mimemsg.get_payload ()) - <NUM_LIT:1><EOL><DEDENT>self.n_integrations = os.stat(self.fp.name).st_size/intsize<EOL>self.n_antennas = int (headxml.find (tagpfx + nanttag).text)<EOL>self.n_baselines = (self.n_antennas * (self.n_antennas - <NUM_LIT:1>)) // <NUM_LIT:2><EOL>ds = headxml.find (tagpfx + dstag)<EOL>nbb = <NUM_LIT:0><EOL>nspw = <NUM_LIT:0><EOL>nchan = <NUM_LIT:0><EOL>crosspolstr = None<EOL>for bb in ds.findall (tagpfx + basebandtag):<EOL><INDENT>nbb += <NUM_LIT:1><EOL>for spw in bb.getchildren ():<EOL><INDENT>nspw += <NUM_LIT:1><EOL>nchan += int (spw.get ('<STR_LIT>'))<EOL>if crosspolstr is None:<EOL><INDENT>crosspolstr = spw.get ('<STR_LIT>')<EOL><DEDENT>elif spw.get ('<STR_LIT>') != crosspolstr:<EOL><INDENT>raise Exception ('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>self.n_basebands = nbb<EOL>self.n_spws = nspw<EOL>self.n_channels = nchan<EOL>self.crosspols = crosspolstr.split ()<EOL>self.n_pols = len(self.crosspols)<EOL>if os.path.exists(os.path.dirname(self.pklname)) and self.pklname and (not os.path.exists(self.pklname)):<EOL><INDENT>logger.info('<STR_LIT>' % (self.pklname))<EOL>with open(self.pklname,'<STR_LIT:wb>') as pkl:<EOL><INDENT>pickle.dump( (self.mimemsg, self.headxml, self.sizeinfo, self.binarychunks, self.n_integrations, self.n_antennas, self.n_baselines, self.n_basebands, self.n_spws, self.n_channels, self.crosspols), pkl)<EOL><DEDENT><DEDENT>return self<EOL>
Parse the BDF mime structure and record the locations of the binary
        blobs. Sets up various data fields in the BDFData object.