How to use the ofxparse.ofxutil.OfxUtil 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 __str__(self):
        ret = os.linesep.join(":".join(line) for line in
                              six.iteritems(self.headers)) + os.linesep * 2
        ret += super(OfxUtil, self).__str__()
        return ret
github jseutter / ofxparse / ofxparse / ofxutil.py View on Github external
def write(self, output_file):
        with open(output_file, 'wb') as f:
            f.write(str(self))

    def __str__(self):
        ret = os.linesep.join(":".join(line) for line in
                              six.iteritems(self.headers)) + os.linesep * 2
        ret += super(OfxUtil, self).__str__()
        return ret


if __name__ == "__main__":
    here = os.path.dirname(__file__)
    fixtures = os.path.join(here, '../tests/fixtures/')
    ofx = OfxUtil(fixtures + 'checking.ofx')
#    ofx = OfxUtil(fixtures + 'fidelity.ofx')

    # Manipulate OFX file via XML library
#    for transaction in ofx.xml.iter('STMTTRN'):
#        transaction.find('NAME').text = transaction.find('MEMO').text
#        transaction.remove(transaction.find('MEMO'))
#    ofx.reload_xml()

    # Manipulate OFX file via object tree built from XML
#    for transaction in ofx.bankmsgsrsv1.stmttrnrs.stmtrs.banktranlist.stmttrn:
#        transaction.name = transaction.memo
#        del transaction.memo
#        transaction.notes = "Acknowledged"
    # Modified sytnax for object tree data manipulation
    # I'm using the __getitem__ method like the xml.iter method from
    # ElementTree, as a recursive search