works with any subbank

This commit is contained in:
Romain Bignon 2012-05-15 14:09:42 +02:00
commit 95af3239f1

View file

@ -18,6 +18,8 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>. # along with weboob. If not, see <http://www.gnu.org/licenses/>.
from urlparse import urlparse
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
from weboob.capabilities.bank import Transfer, TransferError from weboob.capabilities.bank import Transfer, TransferError
from datetime import datetime from datetime import datetime
@ -36,20 +38,17 @@ class CICBrowser(BaseBrowser):
USER_AGENT = BaseBrowser.USER_AGENTS['wget'] USER_AGENT = BaseBrowser.USER_AGENTS['wget']
PAGES = {'https://www.cic.fr/.*/fr/banques/particuliers/index.html': LoginPage, PAGES = {'https://www.cic.fr/.*/fr/banques/particuliers/index.html': LoginPage,
'https://www.cic.fr/.*/fr/identification/default.cgi': LoginErrorPage, 'https://www.cic.fr/.*/fr/identification/default.cgi': LoginErrorPage,
'https://www.cic.fr/.*/fr/banque/situation_financiere.cgi': AccountsPage, 'https://www.cic.fr/.*/fr/banque/situation_financiere.cgi': AccountsPage,
'https://www.cic.fr/.*/fr/banque/espace_personnel.aspx': UserSpacePage, 'https://www.cic.fr/.*/fr/banque/espace_personnel.aspx': UserSpacePage,
'https://www.cic.fr/.*/fr/banque/mouvements.cgi.*': OperationsPage, 'https://www.cic.fr/.*/fr/banque/mouvements.cgi.*': OperationsPage,
'https://www.cic.fr/.*/fr/banque/nr/nr_devbooster.aspx.*': OperationsPage, 'https://www.cic.fr/.*/fr/banque/nr/nr_devbooster.aspx.*': OperationsPage,
'https://www.cic.fr/.*/fr/banque/operations_carte\.cgi.*': OperationsPage, 'https://www.cic.fr/.*/fr/banque/operations_carte\.cgi.*': OperationsPage,
'https://www.cic.fr/.*/fr/banque/CR/arrivee\.asp.*': NoOperationsPage, 'https://www.cic.fr/.*/fr/banque/CR/arrivee\.asp.*': NoOperationsPage,
'https://www.cic.fr/.*/fr/banque/BAD.*': InfoPage, 'https://www.cic.fr/.*/fr/banque/BAD.*': InfoPage,
'https://www.cic.fr/.*/fr/banque/.*Vir.*': TransfertPage 'https://www.cic.fr/.*/fr/banque/.*Vir.*': TransfertPage
} }
def __init__(self, *args, **kwargs): currentSubBank = None
BaseBrowser.__init__(self, *args, **kwargs)
#self.SUB_BANKS = ['cmdv','cmcee','cmse', 'cmidf', 'cmsmb', 'cmma', 'cmmabn', 'cmc', 'cmlaco', 'cmnormandie', 'cmm']
#self.currentSubBank = None
def is_logged(self): def is_logged(self):
return self.page and not self.is_on_page(LoginPage) and not self.is_on_page(LoginErrorPage) return self.page and not self.is_on_page(LoginPage) and not self.is_on_page(LoginErrorPage)
@ -69,7 +68,6 @@ class CICBrowser(BaseBrowser):
if not self.is_logged() or self.is_on_page(LoginErrorPage): if not self.is_logged() or self.is_on_page(LoginErrorPage):
raise BrowserIncorrectPassword() raise BrowserIncorrectPassword()
self.SUB_BANKS = ['cmdv', 'cmcee', 'cmse', 'cmidf', 'cmsmb', 'cmma', 'cmmabn', 'cmc', 'cmlaco', 'cmnormandie', 'cmm', 'sb']
self.getCurrentSubBank() self.getCurrentSubBank()
def get_accounts_list(self): def get_accounts_list(self):
@ -89,11 +87,8 @@ class CICBrowser(BaseBrowser):
def getCurrentSubBank(self): def getCurrentSubBank(self):
# the account list and history urls depend on the sub bank of the user # the account list and history urls depend on the sub bank of the user
current_url = self.geturl() url = urlparse(self.geturl())
current_url_parts = current_url.split('/') self.currentSubBank = url.path.lstrip('/').split('/')[0]
for subbank in self.SUB_BANKS:
if subbank in current_url_parts:
self.currentSubBank = subbank
def get_history(self, account): def get_history(self, account):
page_url = account._link_id page_url = account._link_id