How to use the ofxparse.ofxutil.OfxData function in ofxparse

To help you get started, we’ve selected a few ofxparse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jseutter / ofxparse / ofxparse / ofxutil.py View on Github external
def add_tag(self, name):
        name = name.lower()
        if name not in self.nodes:
            self.nodes[name] = OfxData(name.upper())
            return self.nodes[name]
        elif not isinstance(self.nodes[name], list):
            self.nodes[name] = [self.nodes[name], OfxData(name.upper())]
        else:
            self.nodes[name].append(OfxData(name.upper()))
        return self.nodes[name][-1]
github jseutter / ofxparse / ofxparse / ofxutil.py View on Github external
def add_tag(self, name):
        name = name.lower()
        if name not in self.nodes:
            self.nodes[name] = OfxData(name.upper())
            return self.nodes[name]
        elif not isinstance(self.nodes[name], list):
            self.nodes[name] = [self.nodes[name], OfxData(name.upper())]
        else:
            self.nodes[name].append(OfxData(name.upper()))
        return self.nodes[name][-1]
github jseutter / ofxparse / ofxparse / ofxutil.py View on Github external
def find(self, name, item_list):
        for n, child in six.iteritems(self.nodes):
            if isinstance(child, OfxData):
                if child.tag.lower() == name:
                    item_list.append(child)
                child.find(name, item_list)
            else:
                for grandchild in child:
                    if grandchild.tag.lower() == name:
                        item_list.append(grandchild)
                    grandchild.find(name, item_list)
github jseutter / ofxparse / ofxparse / ofxutil.py View on Github external
def add_tag(self, name):
        name = name.lower()
        if name not in self.nodes:
            self.nodes[name] = OfxData(name.upper())
            return self.nodes[name]
        elif not isinstance(self.nodes[name], list):
            self.nodes[name] = [self.nodes[name], OfxData(name.upper())]
        else:
            self.nodes[name].append(OfxData(name.upper()))
        return self.nodes[name][-1]
github jseutter / ofxparse / ofxparse / ofxutil.py View on Github external
ret = [["<%s>" % self.tag, -1]]
            for _, child in six.iteritems(self.nodes):
                if isinstance(child, OfxData):
                    ret.extend(child.format())
                else:
                    for grandchild in child:
                        ret.extend(grandchild.format())
            ret.append(["" % self.tag, -1])

            for item in ret:
                item[1] += 1

            return ret


class OfxUtil(OfxData):
    def __init__(self, ofx_data=None):
        super(OfxUtil, self).__init__('OFX')
        self.headers = odict.OrderedDict()
        self.xml = ""
        if ofx_data:
            if isinstance(ofx_data, six.string_types) and not \
                    ofx_data.lower().endswith('.ofx'):
                self.parse(ofx_data)
            else:
                self.parse(open(ofx_data).read() if isinstance(
                    ofx_data, six.string_types) else ofx_data.read())

    def parse(self, ofx):
        try:
            for line in ofx.splitlines():
                if line.strip() == "":