Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def parseAcctinfors(cls, acctinfors_ofx, ofx):
all_accounts = []
for i in acctinfors_ofx.findAll('acctinfo'):
accounts = []
if i.find('invacctinfo'):
accounts += cls.parseInvstmtrs([i])
elif i.find('ccacctinfo'):
accounts += cls.parseStmtrs([i], AccountType.CreditCard)
elif i.find('bankacctinfo'):
accounts += cls.parseStmtrs([i], AccountType.Bank)
else:
continue
fi_ofx = ofx.find('fi')
if fi_ofx:
for account in all_accounts:
account.institution = cls.parseOrg(fi_ofx)
desc = i.find('desc')
if hasattr(desc, 'contents'):
for account in accounts:
account.desc = desc.contents[0].strip()
all_accounts += accounts
return all_accounts
account.warnings.append(
six.u("Empty acctid tag for %s") % invstmtrs_ofx)
if cls.fail_fast:
raise
brokerid_tag = invstmtrs_ofx.find('brokerid')
if hasattr(brokerid_tag, 'contents'):
try:
account.brokerid = brokerid_tag.contents[0].strip()
except IndexError:
account.warnings.append(
six.u("Empty brokerid tag for %s") % invstmtrs_ofx)
if cls.fail_fast:
raise
account.type = AccountType.Investment
if invstmtrs_ofx:
account.statement = cls.parseInvestmentStatement(
invstmtrs_ofx)
ret.append(account)
return ret
def parseAccountList(self, ofx):
"""
Parse an Ofx object into a list of account dictionaries.
"""
ret = []
for account in ofx.accounts:
if account.type == AccountType.Bank:
ret.append({
'routing_number': account.routing_number,
'account_number': account.account_id,
'account_type': 'bank',
'bank_account_type': account.account_type,
})
else:
ret.append({
'account_number': account.account_id,
'account_type': 'creditcard',
})
return ret
def parseAcctinfors(cls, acctinfors_ofx, ofx):
all_accounts = []
for i in acctinfors_ofx.findAll('acctinfo'):
accounts = []
if i.find('invacctinfo'):
accounts += cls.parseInvstmtrs([i])
elif i.find('ccacctinfo'):
accounts += cls.parseStmtrs([i], AccountType.CreditCard)
elif i.find('bankacctinfo'):
accounts += cls.parseStmtrs([i], AccountType.Bank)
else:
continue
fi_ofx = ofx.find('fi')
if fi_ofx:
for account in all_accounts:
account.institution = cls.parseOrg(fi_ofx)
desc = i.find('desc')
if hasattr(desc, 'contents'):
for account in accounts:
account.desc = desc.contents[0].strip()
all_accounts += accounts
return all_accounts
def __init__(self):
self.curdef = None
self.statement = None
self.account_id = ''
self.routing_number = ''
self.branch_id = ''
self.account_type = ''
self.institution = None
self.type = AccountType.Unknown
# Used for error tracking
self.warnings = []