def parse(self, ofx):
        try:
            for line in ofx.splitlines():
                if line.strip() == "":
                    break
                header, value = line.split(":")
                self.headers[header] = value
        except __HOLE__:
            pass
        except:
            raise
        finally:
            if "OFXHEADER" not in self.headers:
                self.headers["OFXHEADER"] = "100"
            if "VERSION" not in self.headers:
                self.headers["VERSION"] = "102"
            if "SECURITY" not in self.headers:
                self.headers["SECURITY"] = "NONE"
            if "OLDFILEUID" not in self.headers:
                self.headers["OLDFILEUID"] = "NONE"
            if "NEWFILEUID" not in self.headers:
                self.headers["NEWFILEUID"] = "NONE"

        try:
            tags = ofx.split("<")
            if len(tags) > 1:
                tags = ["<" + t.strip() for t in tags[1:]]

            heirarchy = []
            can_open = True

            for i, tag in enumerate(tags):
                gt = tag.index(">")
                if tag[1] != "/":
                    # Is an opening tag
                    if not can_open:
                        tags[i - 1] = tags[i - 1] + "</" + \
                            heirarchy.pop() + ">"
                        can_open = True
                    tag_name = tag[1:gt].split()[0]
                    heirarchy.append(tag_name)
                    if len(tag) > gt + 1:
                        can_open = False
                else:
                    # Is a closing tag
                    tag_name = tag[2:gt].split()[0]
                    if tag_name not in heirarchy:
                        # Close tag with no matching open, so delete it
                        tags[i] = tag[gt + 1:]
                    else:
                        # Close tag with matching open, but other open
                        # tags that need to be closed first
                        while(tag_name != heirarchy[-1]):
                            tags[i - 1] = tags[i - 1] + "</" + \
                                heirarchy.pop() + ">"
                        can_open = True
                        heirarchy.pop()

            self.xml = ET.fromstringlist(tags)
            self.load_from_xml(self, self.xml)
        except:
            raise InvalidOFXStructureException
dataset/ETHPy150Open jseutter/ofxparse/ofxparse/ofxutil.py/OfxUtil.parse