Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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