From 31af9646969743b492b9067ff0c290d7ccc49aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Rigo?= Date: Sat, 1 Mar 2014 18:43:20 +0100 Subject: [PATCH] Handle card history MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaƫl Rigo Signed-off-by: Romain Bignon --- modules/boursorama/browser.py | 5 +++-- modules/boursorama/pages/__init__.py | 2 ++ modules/boursorama/pages/accounts_list.py | 12 +++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/modules/boursorama/browser.py b/modules/boursorama/browser.py index 2902a07c..60a547ea 100644 --- a/modules/boursorama/browser.py +++ b/modules/boursorama/browser.py @@ -22,7 +22,7 @@ from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword -from .pages import LoginPage, AccountsList, AccountHistory, UpdateInfoPage, AuthenticationPage +from .pages import LoginPage, AccountsList, AccountHistory, CardHistory, UpdateInfoPage, AuthenticationPage __all__ = ['Boursorama'] @@ -42,6 +42,7 @@ class Boursorama(BaseBrowser): '.*connexion.phtml.*': LoginPage, '.*/comptes/synthese.phtml': AccountsList, '.*/comptes/banque/detail/mouvements.phtml.*': AccountHistory, + '.*/comptes/banque/cartes/mouvements.phtml.*': CardHistory, '.*/comptes/epargne/mouvements.phtml.*': AccountHistory, '.*/date_anniversaire.phtml.*': UpdateInfoPage, } @@ -121,7 +122,7 @@ class Boursorama(BaseBrowser): while link is not None: self.location(link) - if not self.is_on_page(AccountHistory): + if not self.is_on_page(AccountHistory) and not self.is_on_page(CardHistory): raise NotImplementedError() for tr in self.page.get_operations(): diff --git a/modules/boursorama/pages/__init__.py b/modules/boursorama/pages/__init__.py index 57be314e..3fc78d14 100644 --- a/modules/boursorama/pages/__init__.py +++ b/modules/boursorama/pages/__init__.py @@ -20,6 +20,7 @@ from .account_history import AccountHistory +from .card_history import CardHistory from .accounts_list import AccountsList from .login import LoginPage, UpdateInfoPage @@ -31,6 +32,7 @@ class AccountPrelevement(AccountsList): __all__ = ['LoginPage', 'AccountsList', 'AccountHistory', + 'CardHistory', 'UpdateInfoPage', 'AuthenticationPage', ] diff --git a/modules/boursorama/pages/accounts_list.py b/modules/boursorama/pages/accounts_list.py index abab9f05..8ecbee25 100644 --- a/modules/boursorama/pages/accounts_list.py +++ b/modules/boursorama/pages/accounts_list.py @@ -39,7 +39,17 @@ class AccountsList(BasePage): account._link_id = None for td in tr.getiterator('td'): if td.attrib.get('class', '') == 'account-cb': - break + try: + a = td.xpath('./*/a[@class="gras"]')[0] + except IndexError: + # ignore account + break + account.type = Account.TYPE_CARD + account.label = self.parser.tocleanstring(a) + try: + account._link_id = td.xpath('.//a')[0].attrib['href'] + except KeyError: + pass elif td.attrib.get('class', '') == 'account-name': try: