def parse(self, source): if not hasattr(source, 'read'): source = open(source) source = source.read() # Validate and strip the OFX header source = OFXHeader.strip(source) # Then parse tag soup into tree of Elements parser = TreeBuilder(element_factory=self.element_factory) parser.feed(source) self._root = parser.close()
def parse(self, source): if not hasattr(source, 'read'): source = open(source) with source as s: source = s.read() # Validate and strip the OFX header source = OFXHeader.strip(source) # Then parse tag soup into tree of Elements parser = TreeBuilder(element_factory=self.element_factory) parser.feed(source) self._root = parser.close()
def _stripHeader(source): """ Validate and strip the OFX header """ return OFXHeader.strip(source)