Used early outs to reduce indentation

This commit is contained in:
2023-08-29 07:58:23 +00:00
parent 6a948fc69f
commit b51df093dc

View File

@@ -170,43 +170,43 @@ class StarlingClient:
if count == 0: if count == 0:
# I don't think this should happen! # I don't think this should happen!
print('This holder has no accounts.') print('This holder has no accounts.')
return
if count == 1:
print('This holder has one account:')
else: else:
if count == 1: print(f'This holder has {count} accounts:')
print('This holder has one account:') for account in accounts:
else: balance = self.formatted_balance(account.accountUid)
print(f'This holder has {count} accounts:') print(f' {account.name}:')
for account in accounts: print(f' Balance: {balance}')
balance = self.formatted_balance(account.accountUid) print(f' Account type: {account.accountType}')
print(f' {account.name}:') print(f' Account UID: {account.accountUid}')
print(f' Balance: {balance}') print(f' Default category: {account.defaultCategory}')
print(f' Account type: {account.accountType}')
print(f' Account UID: {account.accountUid}')
print(f' Default category: {account.defaultCategory}')
def list_payees(self): def list_payees(self):
payees = self.payees().payees payees = self.payees().payees
count = len(payees) count = len(payees)
if count == 0: if count == 0:
print('There are no payees for this customer.') print('There are no payees for this account holder.')
return
if count == 1:
print('There is one payee for this account holder:')
else: else:
print(f'There are {count} payees for this account holder:')
for payee in payees:
sys.stdout.write(f' {payee.payeeName} ({payee.payeeType}) - ')
count = len(payee.accounts)
if count == 0:
print('no accounts.')
continue
if count == 1: if count == 1:
print('There is one payee for this customer:') print('one account:')
else: else:
print(f'There are {count} payees for this customer:') print(f'{count} accounts:')
for payee in payees: for account in payee.accounts:
sys.stdout.write(f' {payee.payeeName} ({payee.payeeType}) - ') sort_code = f'{account.bankIdentifier[0:2]}-{account.bankIdentifier[2:4]}-{account.bankIdentifier[4:6]}'
count = len(payee.accounts) account_number = account.accountIdentifier
if count == 0: print(f' {account.payeeAccountUid}: {sort_code} {account_number} {account.description}')
print('no accounts.')
else:
if count == 1:
print('one account:')
else:
print(f'{count} accounts:')
for account in payee.accounts:
sort_code = f'{account.bankIdentifier[0:2]}-{account.bankIdentifier[2:4]}-{account.bankIdentifier[4:6]}'
account_number = account.accountIdentifier
print(f' {account.payeeAccountUid}: {sort_code} {account_number} {account.description}')
def add_payee(self): def add_payee(self):
details = self.new_payee_form.complete() details = self.new_payee_form.complete()