Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
response = client.Transactions.get(access_token,
fromto['start'], fromto['end'],
account_ids=[account_id])
txn_batch = len(response['transactions'])
txn_total = response['total_transactions']
txn_sofar = txn_batch
output_to_file = True if output['dir'] else False
output_file = '%s/%s' % (output['dir'], util.output_filename(account_name, fromto, output['format']))
output_handle = output_to_file and open(output_file, 'w') or sys.stdout
try:
w = transaction_writer.TransactionWriter.instance(output['format'], output_handle)
w.begin(account)
debug("txn cnt: %d, txn total: %d" % (txn_batch, txn_total))
while txn_batch > 0 and txn_batch <= txn_total:
for t in response['transactions']:
if ignore_pending and t['pending']:
info('skipping pending transaction for [%s: %s]' % (t['date'], t['name']))
continue
info('writing record for [%s: %s]' % (t['date'], t['name']))
debug('%s' % t)
w.write_record(t)
response = client.Transactions.get(access_token,
start_date=fromto['start'], end_date=fromto['end'],
offset=txn_sofar, account_ids=[account_id] )