Use find object

This commit is contained in:
Florent 2014-10-10 10:21:11 +02:00
commit 6f5f41fe57
3 changed files with 2 additions and 24 deletions

View file

@ -18,6 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>. # along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.capabilities.base import find_object
from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.capabilities.bank import CapBank, AccountNotFound
from weboob.tools.backend import Module, BackendConfig from weboob.tools.backend import Module, BackendConfig
from weboob.tools.value import ValueBackendPassword, Value from weboob.tools.value import ValueBackendPassword, Value
@ -60,12 +61,7 @@ class CreditCooperatifModule(Module, CapBank):
def get_account(self, _id): def get_account(self, _id):
with self.browser: with self.browser:
account = self.browser.get_account(_id) return find_object(self.browser.get_accounts_list(), id=_id, error=AccountNotFound)
if account:
return account
else:
raise AccountNotFound()
def iter_history(self, account): def iter_history(self, account):
with self.browser: with self.browser:

View file

@ -76,15 +76,6 @@ class CreditCooperatif(Browser):
return self.page.get_list() 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): def get_history(self, account):
data = {'accountExternalNumber': account.id} data = {'accountExternalNumber': account.id}
self.location('/portail/particuliers/mescomptes/relevedesoperations.do', urllib.urlencode(data)) self.location('/portail/particuliers/mescomptes/relevedesoperations.do', urllib.urlencode(data))

View file

@ -76,15 +76,6 @@ class CreditCooperatif(Browser):
return self.page.get_list() 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): def _get_history(self, link):
self.location(link) self.location(link)