code clean, split too long lines
This commit is contained in:
parent
3dd50f363d
commit
851b2d34ca
10 changed files with 132 additions and 108 deletions
|
|
@ -15,11 +15,13 @@
|
|||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
from weboob.capabilities.bank import ICapBank, AccountNotFound
|
||||
from weboob.tools.backend import BaseBackend
|
||||
from weboob.tools.value import ValuesDict, Value
|
||||
|
||||
from .browser import BPbrowser
|
||||
from .browser import BPBrowser
|
||||
|
||||
|
||||
class BPBackend(BaseBackend, ICapBank):
|
||||
NAME = 'bp'
|
||||
|
|
@ -30,7 +32,7 @@ class BPBackend(BaseBackend, ICapBank):
|
|||
DESCRIPTION = u'La banque postale, French bank'
|
||||
CONFIG = ValuesDict(Value('login', label='Account ID'),
|
||||
Value('password', label='Password', masked=True))
|
||||
BROWSER = BPbrowser
|
||||
BROWSER = BPBrowser
|
||||
|
||||
def create_default_browser(self):
|
||||
return self.create_browser(self.config['login'], self.config['password'])
|
||||
|
|
@ -57,4 +59,3 @@ class BPBackend(BaseBackend, ICapBank):
|
|||
#TODO: retourner le numero du virement
|
||||
#TODO: support the 'reason' parameter
|
||||
return self.browser.make_transfer(from_account, to_account, amount)
|
||||
|
||||
|
|
|
|||
|
|
@ -20,69 +20,74 @@ from datetime import datetime
|
|||
|
||||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword, BrowserBanned
|
||||
|
||||
from .pages import LoginPage, LoggedPage, CookiePage, AccountList, AccountHistory, BadLoginPage, AccountDesactivate, TransferChooseAccounts, CompleteTransfer, TransferConfirm, TransferSummary
|
||||
from .pages import LoginPage, LoggedPage, CookiePage, AccountList, AccountHistory, BadLoginPage, AccountDesactivate, \
|
||||
TransferChooseAccounts, CompleteTransfer, TransferConfirm, TransferSummary
|
||||
|
||||
from weboob.capabilities.bank import Transfer
|
||||
|
||||
__all__ = ['BPbrowser']
|
||||
|
||||
__all__ = ['BPBrowser']
|
||||
|
||||
|
||||
class BPbrowser(BaseBrowser):
|
||||
class BPBrowser(BaseBrowser):
|
||||
DOMAIN = 'voscomptesenligne.labanquepostale.fr'
|
||||
PROTOCOL = 'https'
|
||||
ENCODING = None # refer to the HTML encoding
|
||||
PAGES = { r'.*wsost/OstBrokerWeb/loginform.*': LoginPage,
|
||||
r'.*voscomptes/canalXHTML/identif\.ea.*': LoggedPage,
|
||||
r'.*voscomptes/canalXHTML/releve/syntheseAssurancesEtComptes\.ea': CookiePage,
|
||||
r'.*voscomptes/canalXHTML/releve/liste_comptes\.jsp': AccountList,
|
||||
r'.*canalXHTML/relevesCCP/.*': AccountHistory,
|
||||
r'.*canalXHTML/relevesEpargnes/.*': AccountHistory,
|
||||
r'.*ost/messages\.CVS\.html\?param=0x132120c8.*' : BadLoginPage,
|
||||
r'.*ost/messages\.CVS\.html\?param=0x132120cb.*' : AccountDesactivate,
|
||||
PAGES = {r'.*wsost/OstBrokerWeb/loginform.*': LoginPage,
|
||||
r'.*voscomptes/canalXHTML/identif\.ea.*': LoggedPage,
|
||||
r'.*voscomptes/canalXHTML/releve/syntheseAssurancesEtComptes\.ea': CookiePage,
|
||||
r'.*voscomptes/canalXHTML/releve/liste_comptes\.jsp': AccountList,
|
||||
r'.*canalXHTML/relevesCCP/.*': AccountHistory,
|
||||
r'.*canalXHTML/relevesEpargnes/.*': AccountHistory,
|
||||
r'.*ost/messages\.CVS\.html\?param=0x132120c8.*' : BadLoginPage,
|
||||
r'.*ost/messages\.CVS\.html\?param=0x132120cb.*' : AccountDesactivate,
|
||||
|
||||
r'.*/virementsafran/aiguillage/saisieComptes\.ea.*': TransferChooseAccounts,
|
||||
r'.*/virementsafran/aiguillage/2-saisieComptes\.ea.*' : CompleteTransfer,
|
||||
r'.*/virementsafran/virementnational/2-virementNational\.ea.*' : TransferConfirm,
|
||||
r'.*/virementsafran/virementnational/4-virementNational\.ea.*' : TransferSummary,
|
||||
}
|
||||
r'.*/virementsafran/aiguillage/saisieComptes\.ea.*': TransferChooseAccounts,
|
||||
r'.*/virementsafran/aiguillage/2-saisieComptes\.ea.*' : CompleteTransfer,
|
||||
r'.*/virementsafran/virementnational/2-virementNational\.ea.*' : TransferConfirm,
|
||||
r'.*/virementsafran/virementnational/4-virementNational\.ea.*' : TransferSummary,
|
||||
}
|
||||
|
||||
def home(self):
|
||||
self.location("https://voscomptesenligne.labanquepostale.fr/wsost/OstBrokerWeb/loginform?TAM_OP=login&ERROR_CODE=0x00000000&URL=%2Fvoscomptes%2FcanalXHTML%2Fidentif.ea%3Forigin%3Dparticuliers")
|
||||
self.location('https://voscomptesenligne.labanquepostale.fr/wsost/OstBrokerWeb/loginform?TAM_OP=login&'
|
||||
'ERROR_CODE=0x00000000&URL=%2Fvoscomptes%2FcanalXHTML%2Fidentif.ea%3Forigin%3Dparticuliers')
|
||||
|
||||
def is_logged(self):
|
||||
return not self.is_on_page(LoginPage)
|
||||
|
||||
def login(self):
|
||||
if not self.is_on_page(LoginPage):
|
||||
self.location('https://voscomptesenligne.labanquepostale.fr/wsost/OstBrokerWeb/loginform?TAM_OP=login&ERROR_CODE=0x00000000&URL=%2Fvoscomptes%2FcanalXHTML%2Fidentif.ea%3Forigin%3Dparticuliers', no_login=True)
|
||||
self.location('https://voscomptesenligne.labanquepostale.fr/wsost/OstBrokerWeb/loginform?TAM_OP=login&'
|
||||
'ERROR_CODE=0x00000000&URL=%2Fvoscomptes%2FcanalXHTML%2Fidentif.ea%3Forigin%3Dparticuliers',
|
||||
no_login=True)
|
||||
|
||||
self.page.login(self.username, self.password)
|
||||
|
||||
|
||||
if self.is_on_page(BadLoginPage):
|
||||
raise BrowserIncorrectPassword()
|
||||
if self.is_on_page(AccountDesactivate):
|
||||
raise BrowserBanned()
|
||||
|
||||
def get_accounts_list(self):
|
||||
self.location("https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/authentification/liste_contrat_atos.ea")
|
||||
self.location("https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/releve/liste_comptes.jsp")
|
||||
self.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/authentification/'
|
||||
'liste_contrat_atos.ea')
|
||||
self.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/releve/liste_comptes.jsp')
|
||||
return self.page.get_accounts_list()
|
||||
|
||||
def get_account(self, id):
|
||||
|
||||
if not self.is_on_page(AccountList):
|
||||
self.location("https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/authentification/liste_contrat_atos.ea")
|
||||
self.location("https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/releve/liste_comptes.jsp")
|
||||
self.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/authentification/'
|
||||
'liste_contrat_atos.ea')
|
||||
self.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/releve/liste_comptes.jsp')
|
||||
return self.page.get_account(id)
|
||||
|
||||
|
||||
def get_history(self, Account):
|
||||
self.location(Account.link_id)
|
||||
return self.page.get_history()
|
||||
|
||||
def make_transfer(self, from_account, to_account, amount):
|
||||
self.location("https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/virementsafran/aiguillage/saisieComptes.ea")
|
||||
self.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/virementsafran/aiguillage/'
|
||||
'saisieComptes.ea')
|
||||
self.page.set_accouts(from_account, to_account)
|
||||
|
||||
#TODO: Check
|
||||
|
|
|
|||
|
|
@ -15,11 +15,13 @@
|
|||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
from .login import LoginPage, LoggedPage, BadLoginPage, AccountDesactivate
|
||||
from .cookie import CookiePage
|
||||
from .accountlist import AccountList
|
||||
from .accounthistory import AccountHistory
|
||||
|
||||
from .transfer import TransferChooseAccounts, CompleteTransfer, TransferConfirm, TransferSummary
|
||||
|
||||
__all__ = ['LoginPage', 'LoggedPage', 'CookiePage', "AccountList", 'AccountHistory', 'BadLoginPage', 'AccountDesactivate', 'TransferChooseAccounts', 'CompleteTransfer', 'TransferConfirm', 'TransferSummary']
|
||||
|
||||
__all__ = ['LoginPage', 'LoggedPage', 'CookiePage', "AccountList", 'AccountHistory', 'BadLoginPage',
|
||||
'AccountDesactivate', 'TransferChooseAccounts', 'CompleteTransfer', 'TransferConfirm', 'TransferSummary']
|
||||
|
|
|
|||
|
|
@ -15,18 +15,22 @@
|
|||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
import re
|
||||
|
||||
from weboob.capabilities.bank import Operation
|
||||
|
||||
from weboob.tools.browser import BasePage
|
||||
|
||||
|
||||
__all__ = ['AccountHistory']
|
||||
|
||||
|
||||
def remove_html_tags(data):
|
||||
p = re.compile(r'<.*?>')
|
||||
return p.sub(' ', data)
|
||||
|
||||
|
||||
def remove_extra_spaces(data):
|
||||
p = re.compile(r'\s+')
|
||||
return p.sub(' ', data)
|
||||
|
|
@ -34,9 +38,10 @@ def remove_extra_spaces(data):
|
|||
|
||||
class AccountHistory(BasePage):
|
||||
def on_loaded(self):
|
||||
if self.document.docinfo.doctype == '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">':
|
||||
if self.document.docinfo.doctype == '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" '
|
||||
'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">':
|
||||
self.browser.follow_link(url_regex="releve", tag="a")
|
||||
|
||||
|
||||
def get_history(self):
|
||||
mvt_table = self.document.xpath("//table[@id='mouvements']", smart_strings=False)[0]
|
||||
mvt_ligne = mvt_table.xpath("./tbody/tr")
|
||||
|
|
@ -49,7 +54,6 @@ class AccountHistory(BasePage):
|
|||
tp = mvt.xpath("./td")[1]
|
||||
operation.label = remove_extra_spaces(remove_html_tags(self.browser.parser.tostring(tp)))
|
||||
|
||||
|
||||
r = re.compile(r'\d+')
|
||||
tp = mvt.xpath("./td/span")
|
||||
amount = None
|
||||
|
|
|
|||
|
|
@ -20,14 +20,15 @@ from weboob.capabilities.bank import Account, AccountNotFound
|
|||
|
||||
from weboob.tools.browser import BasePage
|
||||
|
||||
|
||||
__all__ = ['AccountList']
|
||||
|
||||
|
||||
class AccountList(BasePage):
|
||||
def on_loaded(self):
|
||||
self.Account_List = []
|
||||
self.account_list = []
|
||||
|
||||
def get_accounts_list(self):
|
||||
|
||||
#Parse CCP
|
||||
compte_table = self.document.xpath("//table[@id='comptes']", smart_strings=False)[0]
|
||||
compte_ligne = compte_table.xpath("./tbody/tr")
|
||||
|
|
@ -38,8 +39,8 @@ class AccountList(BasePage):
|
|||
account.label = tp.text
|
||||
account.link_id = tp.get("href")
|
||||
account.id = compte.xpath("./td")[1].text
|
||||
account.balance = float(''.join( compte.xpath("./td/span")[0].text.replace('.','').replace(',','.').split() ))
|
||||
self.Account_List.append(account)
|
||||
account.balance = float(''.join(compte.xpath("./td/span")[0].text.replace('.','').replace(',','.').split()))
|
||||
self.account_list.append(account)
|
||||
|
||||
#Parse epargne
|
||||
epargne_table = self.document.xpath("//table[@id='comptesEpargne']", smart_strings=False)[0]
|
||||
|
|
@ -51,16 +52,16 @@ class AccountList(BasePage):
|
|||
account.label = tp.text
|
||||
account.link_id = tp.get("href")
|
||||
account.id = epargne.xpath("./td")[1].text
|
||||
account.balance = float(''.join( epargne.xpath("./td/span")[0].text.replace('.','').replace(',','.').split() ) )
|
||||
self.Account_List.append(account)
|
||||
account.balance = float(''.join(epargne.xpath("./td/span")[0].text.replace('.','').replace(',','.').split()))
|
||||
self.account_list.append(account)
|
||||
|
||||
return self.Account_List
|
||||
return self.account_list
|
||||
|
||||
def get_account(self, id):
|
||||
if not self.Account_List:
|
||||
if not self.account_list:
|
||||
self.get_accounts_list()
|
||||
|
||||
for account in self.Account_List:
|
||||
if account.id == id:
|
||||
return account
|
||||
for account in self.account_list:
|
||||
if account.id == id:
|
||||
return account
|
||||
raise AccountNotFound('Unable to find account: %s' % id)
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@
|
|||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
|
||||
from weboob.tools.browser import BasePage
|
||||
|
||||
|
||||
__all__ = ['CookiePage']
|
||||
|
||||
|
||||
class CookiePage(BasePage):
|
||||
def on_loaded(self):
|
||||
pass
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
import hashlib
|
||||
|
||||
from weboob.tools.browser import BasePage
|
||||
|
|
@ -35,26 +36,32 @@ class LoginPage(BasePage):
|
|||
pass
|
||||
|
||||
def login(self, login, pwd):
|
||||
LOCAL_HASH = ['a02574d7bf67677d2a86b7bfc5e864fe', 'eb85e1cc45dd6bdb3cab65c002d7ac8a', '596e6fbd54d5b111fe5df8a4948e80a4', '9cdc989a4310554e7f5484d0d27a86ce', '0183943de6c0e331f3b9fc49c704ac6d', '291b9987225193ab1347301b241e2187', '163279f1a46082408613d12394e4042a', 'b0a9c740c4cada01eb691b4acda4daea', '3c4307ee92a1f3b571a3c542eafcb330', 'dbccecfa2206bfdb4ca891476404cc68']
|
||||
process = lambda i: md5(self.browser.retrieve(("https://voscomptesenligne.labanquepostale.fr/wsost/OstBrokerWeb/loginform?imgid=%d&0.25122230781963073" % i ))[0])
|
||||
Keypad = [ process(i) for i in range(10)]
|
||||
LOCAL_HASH = ['a02574d7bf67677d2a86b7bfc5e864fe', 'eb85e1cc45dd6bdb3cab65c002d7ac8a',
|
||||
'596e6fbd54d5b111fe5df8a4948e80a4', '9cdc989a4310554e7f5484d0d27a86ce',
|
||||
'0183943de6c0e331f3b9fc49c704ac6d', '291b9987225193ab1347301b241e2187',
|
||||
'163279f1a46082408613d12394e4042a', 'b0a9c740c4cada01eb691b4acda4daea',
|
||||
'3c4307ee92a1f3b571a3c542eafcb330', 'dbccecfa2206bfdb4ca891476404cc68',
|
||||
]
|
||||
process = lambda i: md5(self.browser.retrieve(('https://voscomptesenligne.labanquepostale.fr/wsost/OstBrokerWeb'
|
||||
'/loginform?imgid=%d&0.25122230781963073' % i))[0])
|
||||
keypad = [process(i) for i in range(10)]
|
||||
correspondance = [keypad.index(i) for i in LOCAL_HASH]
|
||||
newpassword = ''.join(str(correspondance[int(c)]) for c in pwd)
|
||||
|
||||
|
||||
|
||||
|
||||
correspondance = [ Keypad.index(i) for i in LOCAL_HASH]
|
||||
Newpassword = "".join([str(correspondance[int(c)]) for c in pwd])
|
||||
|
||||
self.browser.select_form(name="formAccesCompte")
|
||||
self.browser.select_form(name='formAccesCompte')
|
||||
self.browser.set_all_readonly(False)
|
||||
self.browser["password"] = Newpassword
|
||||
self.browser["username"] = login
|
||||
self.browser['password'] = newpassword
|
||||
self.browser['username'] = login
|
||||
self.browser.submit()
|
||||
|
||||
|
||||
class LoggedPage(BasePage):
|
||||
pass
|
||||
|
||||
|
||||
class BadLoginPage(BasePage):
|
||||
pass
|
||||
|
||||
|
||||
class AccountDesactivate(BasePage):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -16,17 +16,17 @@
|
|||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
import re
|
||||
|
||||
from weboob.capabilities.bank import TransferError
|
||||
from weboob.tools.browser import BasePage
|
||||
from weboob.tools.misc import to_unicode
|
||||
|
||||
import re
|
||||
|
||||
__all__ = ['TransferChooseAccounts', 'CompleteTransfer', 'TransferConfirm', 'TransferSummary']
|
||||
|
||||
|
||||
class TransferChooseAccounts(BasePage):
|
||||
|
||||
def set_accouts(self, from_account, to_account):
|
||||
self.browser.select_form(name="AiguillageForm")
|
||||
self.browser["idxCompteEmetteur"] = [from_account.id]
|
||||
|
|
@ -35,16 +35,17 @@ class TransferChooseAccounts(BasePage):
|
|||
|
||||
|
||||
class CompleteTransfer(BasePage):
|
||||
|
||||
def complete_transfer(self, amount):
|
||||
self.browser.select_form(name="VirementNationalForm")
|
||||
self.browser["montant"] = str(amount)
|
||||
self.browser.submit()
|
||||
|
||||
class TransferConfirm(BasePage):
|
||||
|
||||
class TransferConfirm(BasePage):
|
||||
def confirm(self):
|
||||
self.browser.location("https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/virementsafran/virementnational/4-virementNational.ea")
|
||||
self.browser.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/virementsafran/'
|
||||
'virementnational/4-virementNational.ea')
|
||||
|
||||
|
||||
class TransferSummary(BasePage):
|
||||
def get_transfer_id(self):
|
||||
|
|
@ -56,7 +57,6 @@ class TransferSummary(BasePage):
|
|||
except UnicodeDecodeError, error:
|
||||
text = error.object.strip()
|
||||
|
||||
|
||||
match = re.search("Votre virement N.+ ([0-9]+) ", text)
|
||||
if match:
|
||||
id_transfer = match.groups()[0]
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
from __future__ import with_statement
|
||||
|
||||
from weboob.tools.backend import BaseBackend
|
||||
|
|
@ -144,7 +145,8 @@ class DLFPBackend(BaseBackend, ICapMessages, ICapMessagesPost):
|
|||
yield m
|
||||
|
||||
def set_message_read(self, message):
|
||||
self.storage.set('seen', message.thread.id, 'comments', self.storage.get('seen', message.thread.id, 'comments', default=[]) + [message.id])
|
||||
self.storage.set('seen', message.thread.id, 'comments',
|
||||
self.storage.get('seen', message.thread.id, 'comments', default=[]) + [message.id])
|
||||
self.storage.save()
|
||||
|
||||
def post_message(self, message):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue