From dafe3c7c4528b77cf90d8ba1df895a3eb259a1a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Sobucki?= <168-ssobucki@users.noreply.gitlab.budget-insight.com> Date: Fri, 29 Jan 2021 14:31:39 +0100 Subject: [PATCH] [boursorama] add condition to avoid an unnecessary request Finding ownership for accounts only makes sense if there are ownerless accounts. I added a condition to make sure we are not sending the request to find potential owners if there are no ownerless accounts. --- modules/boursorama/browser.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/modules/boursorama/browser.py b/modules/boursorama/browser.py index 7907c5b35a..793ad7f2d3 100644 --- a/modules/boursorama/browser.py +++ b/modules/boursorama/browser.py @@ -320,16 +320,17 @@ def do_login(self): def ownership_guesser(self, accounts_list): ownerless_accounts = [account for account in accounts_list if empty(account.ownership)] - # On Boursorama website, all mandatory accounts have the real owner name in their label, and - # children names are findable in the PSU profile. - self.profile_children.go() - children_names = self.page.get_children_firstnames() - - for ownerless_account in ownerless_accounts: - for child_name in children_names: - if child_name in ownerless_account.label: - ownerless_account.ownership = AccountOwnership.ATTORNEY - break + if ownerless_accounts: + # On Boursorama website, all mandatory accounts have the real owner name in their label, and + # children names are findable in the PSU profile. + self.profile_children.go() + children_names = self.page.get_children_firstnames() + + for ownerless_account in ownerless_accounts: + for child_name in children_names: + if child_name in ownerless_account.label: + ownerless_account.ownership = AccountOwnership.ATTORNEY + break # If there are two deferred card for with the same parent account, we assume that's the parent checking # account is a 'CO_OWNER' account -- GitLab