From 6f5f41fe574ad35b11e024b7c10bb2950d0689b2 Mon Sep 17 00:00:00 2001 From: Florent Date: Fri, 10 Oct 2014 10:21:11 +0200 Subject: [PATCH] Use find object --- modules/creditcooperatif/module.py | 8 ++------ modules/creditcooperatif/perso/browser.py | 9 --------- modules/creditcooperatif/pro/browser.py | 9 --------- 3 files changed, 2 insertions(+), 24 deletions(-) diff --git a/modules/creditcooperatif/module.py b/modules/creditcooperatif/module.py index dcc68abc..90611f13 100644 --- a/modules/creditcooperatif/module.py +++ b/modules/creditcooperatif/module.py @@ -18,6 +18,7 @@ # along with weboob. If not, see . +from weboob.capabilities.base import find_object from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword, Value @@ -60,12 +61,7 @@ class CreditCooperatifModule(Module, CapBank): def get_account(self, _id): with self.browser: - account = self.browser.get_account(_id) - - if account: - return account - else: - raise AccountNotFound() + return find_object(self.browser.get_accounts_list(), id=_id, error=AccountNotFound) def iter_history(self, account): with self.browser: diff --git a/modules/creditcooperatif/perso/browser.py b/modules/creditcooperatif/perso/browser.py index 49d74cc1..6d590ad0 100644 --- a/modules/creditcooperatif/perso/browser.py +++ b/modules/creditcooperatif/perso/browser.py @@ -76,15 +76,6 @@ class CreditCooperatif(Browser): return self.page.get_list() - def get_account(self, id): - assert isinstance(id, basestring) - - for a in self.get_accounts_list(): - if a.id == id: - return a - - return None - def get_history(self, account): data = {'accountExternalNumber': account.id} self.location('/portail/particuliers/mescomptes/relevedesoperations.do', urllib.urlencode(data)) diff --git a/modules/creditcooperatif/pro/browser.py b/modules/creditcooperatif/pro/browser.py index 35ec276b..7ca54c80 100644 --- a/modules/creditcooperatif/pro/browser.py +++ b/modules/creditcooperatif/pro/browser.py @@ -76,15 +76,6 @@ class CreditCooperatif(Browser): return self.page.get_list() - def get_account(self, id): - assert isinstance(id, basestring) - - for a in self.get_accounts_list(): - if a.id == id: - return a - - return None - def _get_history(self, link): self.location(link)