use StateBrowser, s/BrowserToBeContinued/BrowserQuestion/ and coding style fixes
This commit is contained in:
parent
248830752d
commit
2afd27b4a4
5 changed files with 64 additions and 77 deletions
|
|
@ -23,7 +23,7 @@
|
|||
import re
|
||||
from collections import defaultdict
|
||||
|
||||
from weboob.deprecated.browser import Browser, BrowserIncorrectPassword
|
||||
from weboob.deprecated.browser import StateBrowser, BrowserIncorrectPassword
|
||||
from weboob.capabilities.bank import Account
|
||||
|
||||
from .pages import (LoginPage, AccountsList, AccountHistory, CardHistory, UpdateInfoPage,
|
||||
|
|
@ -37,33 +37,31 @@ class BrowserIncorrectAuthenticationCode(BrowserIncorrectPassword):
|
|||
pass
|
||||
|
||||
|
||||
class Boursorama(Browser):
|
||||
class Boursorama(StateBrowser):
|
||||
DOMAIN = 'www.boursorama.com'
|
||||
PROTOCOL = 'https'
|
||||
CERTHASH = ['6bdf8b6dd177bd417ddcb1cfb818ede153288e44115eb269f2ddd458c8461039',
|
||||
'b290ef629c88f0508e9cc6305421c173bd4291175e3ddedbee05ee666b34c20e']
|
||||
ENCODING = None # refer to the HTML encoding
|
||||
PAGES = {
|
||||
'.*/connexion/securisation.*': AuthenticationPage,
|
||||
'.*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,
|
||||
'.*/detail.phtml.*': AccountInvestment,
|
||||
'.*/opcvm.phtml.*': InvestmentDetail
|
||||
PAGES = {r'.*/connexion/securisation.*': AuthenticationPage,
|
||||
r'.*connexion.phtml.*': LoginPage,
|
||||
r'.*/comptes/synthese.phtml': AccountsList,
|
||||
r'.*/comptes/banque/detail/mouvements.phtml.*': AccountHistory,
|
||||
r'.*/comptes/banque/cartes/mouvements.phtml.*': CardHistory,
|
||||
r'.*/comptes/epargne/mouvements.phtml.*': AccountHistory,
|
||||
r'.*/date_anniversaire.phtml.*': UpdateInfoPage,
|
||||
r'.*/detail.phtml.*': AccountInvestment,
|
||||
r'.*/opcvm.phtml.*': InvestmentDetail
|
||||
}
|
||||
|
||||
__states__ = []
|
||||
__states__ = ('auth_token',)
|
||||
|
||||
def __init__(self, config=None, *args, **kwargs):
|
||||
self.config = config
|
||||
self.auth_token = None
|
||||
kwargs['get_home'] = False
|
||||
kwargs['username'] = self.config['login'].get()
|
||||
kwargs['password'] = self.config['password'].get()
|
||||
Browser.__init__(self, *args, **kwargs)
|
||||
StateBrowser.__init__(self, *args, **kwargs)
|
||||
|
||||
def home(self):
|
||||
if not self.is_logged():
|
||||
|
|
@ -77,10 +75,7 @@ class Boursorama(Browser):
|
|||
def handle_authentication(self):
|
||||
if self.is_on_page(AuthenticationPage):
|
||||
if self.config['enable_twofactors'].get():
|
||||
if not self.config['pin_code'].get() or not self.auth_token:
|
||||
self.page.send_sms()
|
||||
else:
|
||||
self.page.authenticate()
|
||||
self.page.send_sms()
|
||||
else:
|
||||
raise BrowserIncorrectAuthenticationCode(
|
||||
"""Boursorama - activate the two factor authentication in boursorama config."""
|
||||
|
|
@ -92,8 +87,8 @@ class Boursorama(Browser):
|
|||
assert isinstance(self.config['enable_twofactors'].get(), bool)
|
||||
assert self.password.isdigit()
|
||||
|
||||
if self.is_on_page(AuthenticationPage):
|
||||
self.handle_authentication()
|
||||
if self.auth_token and self.config['pin_code'].get():
|
||||
AuthenticationPage.authenticate(self)
|
||||
else:
|
||||
if not self.is_on_page(LoginPage):
|
||||
self.location('https://' + self.DOMAIN + '/connexion.phtml', no_login=True)
|
||||
|
|
@ -112,7 +107,7 @@ class Boursorama(Browser):
|
|||
#if the login was correct but authentication code failed,
|
||||
#we need to verify if bourso redirect us to login page or authentication page
|
||||
if self.is_on_page(LoginPage):
|
||||
raise BrowserIncorrectAuthenticationCode()
|
||||
raise BrowserIncorrectAuthenticationCode('Invalid PIN code')
|
||||
|
||||
def get_accounts_list(self):
|
||||
if self.is_on_page(AuthenticationPage):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue