def get_nubank_account(self): try: logging.info('Searching for Nubank account') return next(acc for acc in self.client.budget.be_accounts if acc.account_name == 'Nubank') except StopIteration: logging.info('Nubank account not found, creating a new one') account = Account() account.account_name = 'Nubank' self.client.budget.be_accounts.append(account) self.delta += 1 return account
def get_account(self, account_name): try: logging.info('Searching for ' + account_name + ' account') return next(acc for acc in self.client.budget.be_accounts if acc.account_name == account_name) except StopIteration: logging.info(account_name + ' account not found, creating a new one') account = Account() account.account_name = account_name self.client.budget.be_accounts.append(account) self.delta += 1 return account