Logo Search packages:      
Sourcecode: python-biopython version File versions

def Martel::Parser::RecordParser::parseFile (   self,
  fileobj 
)

parse using the input file object

XXX will be removed with the switch to Python 2.0, where parse()
takes an 'InputSource'

Definition at line 415 of file Parser.py.

00415                                 :
        """parse using the input file object

        XXX will be removed with the switch to Python 2.0, where parse()
        takes an 'InputSource'
        """
        self._cont_handler.startDocument()
        
        try:
            reader = self.make_reader( *(fileobj,) + self.reader_args)
        except (KeyboardInterrupt, SystemExit):
            raise
        except:
            # something unexpected happened
            # so call it a fatal error and stop
            outfile = StringIO()
            traceback.print_exc(file=outfile)
            self._err_handler.fatalError(ParserRecordException(
                outfile.getvalue(), sys.exc_info()[1]))
            self._cont_handler.endDocument()
            return

        if self.want_groupref_names:
            _match_group.clear()

        self._cont_handler.startElement(self.format_name, self.attrs)
        filepos = 0  # can get mixed up with DOS style "\r\n"
        while 1:
            try:
                record = reader.next()  
            except (KeyboardInterrupt, SystemExit):
                raise
            except:
                # something unexpected happened (couldn't find a record?)
                # so call it a fatal error and stop
                outfile = StringIO()
                traceback.print_exc(file=outfile)
                self._err_handler.fatalError(ParserRecordException(
                    outfile.getvalue(), sys.exc_info()[1]))
                self._cont_handler.endDocument()
                return
            
            if record is None:
                break
            result = _parse_elements(record, self.tagtable, self._cont_handler,
                                     self.debug_level, self.attrlookup)

            if result is None:
                # Successfully read the record
                pass
            elif isinstance(result, _exceptions.SAXException):
                # Wrong format or a SAX problem, but this is recoverable
                result += filepos
                self._err_handler.error(result)
            else:
                # Did not reach end of string, but this is recoverable
                pos = filepos + result
                self._err_handler.error(ParserPositionException(pos))

            filepos = filepos + len(record)

        self._cont_handler.endElement(self.format_name)
        self._cont_handler.endDocument()

    def parse(self, source):


Generated by  Doxygen 1.6.0   Back to index