From b51df093dc1d77126b3a9111327cd6faeb377975 Mon Sep 17 00:00:00 2001 From: Mark Sheppard Date: Tue, 29 Aug 2023 07:58:23 +0000 Subject: [PATCH] Used early outs to reduce indentation --- starling | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/starling b/starling index 0c892f7..65c865b 100755 --- a/starling +++ b/starling @@ -170,43 +170,43 @@ class StarlingClient: if count == 0: # I don't think this should happen! print('This holder has no accounts.') + return + if count == 1: + print('This holder has one account:') else: - if count == 1: - print('This holder has one account:') - else: - print(f'This holder has {count} accounts:') - for account in accounts: - balance = self.formatted_balance(account.accountUid) - print(f' {account.name}:') - print(f' Balance: {balance}') - print(f' Account type: {account.accountType}') - print(f' Account UID: {account.accountUid}') - print(f' Default category: {account.defaultCategory}') + print(f'This holder has {count} accounts:') + for account in accounts: + balance = self.formatted_balance(account.accountUid) + print(f' {account.name}:') + print(f' Balance: {balance}') + print(f' Account type: {account.accountType}') + print(f' Account UID: {account.accountUid}') + print(f' Default category: {account.defaultCategory}') def list_payees(self): payees = self.payees().payees count = len(payees) 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: + 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: - print('There is one payee for this customer:') + print('one account:') else: - print(f'There are {count} payees for this customer:') - for payee in payees: - sys.stdout.write(f' {payee.payeeName} ({payee.payeeType}) - ') - count = len(payee.accounts) - if count == 0: - 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}') + 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): details = self.new_payee_form.complete()