From 35688f58c96037a934b156761b1d53594ca3aee3 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Sat, 10 Mar 2012 09:03:26 +0100 Subject: [PATCH] Account.link_id becomes a private attribute --- modules/bnporc/backend.py | 4 ++-- modules/bnporc/browser.py | 5 +++++ modules/bnporc/pages/accounts_list.py | 2 +- modules/bnporc/pages/login.py | 7 ++++--- modules/boursorama/browser.py | 6 +++--- modules/boursorama/pages/accounts_list.py | 2 +- modules/bp/browser.py | 2 +- modules/bp/pages/accountlist.py | 2 +- modules/cragr/browser.py | 6 +++--- modules/cragr/pages/accounts_list.py | 7 ++++--- modules/creditmutuel/browser.py | 4 ++-- modules/creditmutuel/pages.py | 4 ++-- modules/hsbc/backend.py | 2 +- modules/hsbc/pages/accounts.py | 4 ++-- modules/lcl/browser.py | 4 ++-- modules/lcl/pages.py | 2 +- modules/societegenerale/browser.py | 2 +- modules/societegenerale/pages/accounts_list.py | 2 +- 18 files changed, 37 insertions(+), 30 deletions(-) diff --git a/modules/bnporc/backend.py b/modules/bnporc/backend.py index 0cc0034f..722985ee 100644 --- a/modules/bnporc/backend.py +++ b/modules/bnporc/backend.py @@ -76,11 +76,11 @@ class BNPorcBackend(BaseBackend, ICapBank): def iter_history(self, account): with self.browser: - return self.browser.iter_history(account.link_id) + return self.browser.iter_history(account._link_id) def iter_operations(self, account): with self.browser: - return self.browser.iter_coming_operations(account.link_id) + return self.browser.iter_coming_operations(account._link_id) def iter_transfer_recipients(self, ignored): for account in self.browser.get_transfer_accounts().itervalues(): diff --git a/modules/bnporc/browser.py b/modules/bnporc/browser.py index 04c599d0..31b13e0a 100644 --- a/modules/bnporc/browser.py +++ b/modules/bnporc/browser.py @@ -76,6 +76,8 @@ class BNPorc(BaseBrowser): if self.is_on_page(LoginPage): raise BrowserIncorrectPassword() + #self.readurl('/SAF_SOA?Action=6') + def change_password(self, new_password): assert new_password.isdigit() and len(new_password) == 6 @@ -85,6 +87,9 @@ class BNPorc(BaseBrowser): self.location(buf) assert self.is_on_page(ChangePasswordPage) + #self.readurl('/banque/portail/particulier/bandeau') + #self.readurl('/common/vide.htm') + self.page.change_password(self.password, new_password) if not self.is_on_page(ConfirmPage) or self.page.get_error() is not None: diff --git a/modules/bnporc/pages/accounts_list.py b/modules/bnporc/pages/accounts_list.py index d714bae6..c84c9fa6 100644 --- a/modules/bnporc/pages/accounts_list.py +++ b/modules/bnporc/pages/accounts_list.py @@ -38,7 +38,7 @@ class AccountsList(BasePage): if tr.find('td') is not None and tr.find('td').attrib.get('class', '') == 'typeTitulaire': account = Account() account.id = tr.xpath('.//td[@class="libelleCompte"]/input')[0].attrib['id'][len('libelleCompte'):] - account.link_id = account.id + account._link_id = account.id if len(str(account.id)) == 23: account.id = str(account.id)[5:21] diff --git a/modules/bnporc/pages/login.py b/modules/bnporc/pages/login.py index ce5cc356..7d91390d 100644 --- a/modules/bnporc/pages/login.py +++ b/modules/bnporc/pages/login.py @@ -18,6 +18,7 @@ # along with weboob. If not, see . +import time import re from weboob.tools.mech import ClientForm import urllib @@ -41,13 +42,13 @@ class BNPVirtKeyboard(MappedVirtKeyboard): '9':'828cf0faf86ac78e7f43208907620527' } - url="/NSImgGrille" + url="/NSImgGrille?timestamp=%d" color=27 def __init__(self,basepage): img=basepage.document.find("//img[@usemap='#MapGril']") - MappedVirtKeyboard.__init__(self,basepage.browser.openurl(self.url),basepage.document,img,self.color) + MappedVirtKeyboard.__init__(self,basepage.browser.openurl(self.url % time.time()),basepage.document,img,self.color) if basepage.browser.responses_dirname is None: basepage.browser.responses_dirname = \ tempfile.mkdtemp(prefix='weboob_session_') @@ -135,7 +136,7 @@ class ChangePasswordPage(BasePage): code_current=vk.get_string_code(current) code_new=vk.get_string_code(new) - data = (('ch1', code_current.replace('4', '3')), + data = (('ch1', code_current), ('ch2', code_new), ('radiobutton3', 'radiobutton'), ('ch3', code_new), diff --git a/modules/boursorama/browser.py b/modules/boursorama/browser.py index 61380134..30e4f66d 100644 --- a/modules/boursorama/browser.py +++ b/modules/boursorama/browser.py @@ -81,15 +81,15 @@ class Boursorama(BaseBrowser): return None def get_history(self, account): - self.location(account.link_id) + self.location(account._link_id) operations = self.page.get_operations() # load last month as well target = date.today() - relativedelta( months = 1 ) - self.location(account.link_id + ("&month=%d&year=%d" % (target.month, target.year))) + self.location(account._link_id + ("&month=%d&year=%d" % (target.month, target.year))) operations += self.page.get_operations() # and the month before, just in case you're greedy target = date.today() - relativedelta( months = 2 ) - self.location(account.link_id + ("&month=%d&year=%d" % (target.month, target.year))) + self.location(account._link_id + ("&month=%d&year=%d" % (target.month, target.year))) operations += self.page.get_operations() for index, op in enumerate(operations): op.id = index diff --git a/modules/boursorama/pages/accounts_list.py b/modules/boursorama/pages/accounts_list.py index 30acadc3..9aa3e9dd 100644 --- a/modules/boursorama/pages/accounts_list.py +++ b/modules/boursorama/pages/accounts_list.py @@ -40,7 +40,7 @@ class AccountsList(BasePage): elif td.attrib.get('class', '') == 'account-name': a = td.find('a') account.label = a.text - account.link_id = a.get('href', '') + account._link_id = a.get('href', '') elif td.attrib.get('class', '') == 'account-number': id = td.text diff --git a/modules/bp/browser.py b/modules/bp/browser.py index 5b968a6a..fc42cc99 100644 --- a/modules/bp/browser.py +++ b/modules/bp/browser.py @@ -90,7 +90,7 @@ class BPBrowser(BaseBrowser): return self.page.get_account(id) def get_history(self, Account): - self.location(Account.link_id) + self.location(Account._link_id) return self.page.get_history() def make_transfer(self, from_account, to_account, amount): diff --git a/modules/bp/pages/accountlist.py b/modules/bp/pages/accountlist.py index b6031ddb..18e92cf0 100644 --- a/modules/bp/pages/accountlist.py +++ b/modules/bp/pages/accountlist.py @@ -48,7 +48,7 @@ class AccountList(BasePage): account = Account() tmp = line.xpath("./td//a")[0] account.label = tmp.text - account.link_id = tmp.get("href") + account._link_id = tmp.get("href") tmp = line.xpath("./td/span/strong") if len(tmp) >= 2: diff --git a/modules/cragr/browser.py b/modules/cragr/browser.py index 2b0c0a68..f8427fe8 100644 --- a/modules/cragr/browser.py +++ b/modules/cragr/browser.py @@ -132,9 +132,9 @@ class Cragr(BaseBrowser): def get_history(self, account): # some accounts may exist without a link to any history page - if account.link_id is None: + if account._link_id is None: return - history_url = account.link_id + history_url = account._link_id operations_count = 0 # 1st, go on the account page @@ -258,5 +258,5 @@ class Cragr(BaseBrowser): #def get_coming_operations(self, account): # if not self.is_on_page(AccountComing) or self.page.account.id != account.id: - # self.location('/NS_AVEEC?ch4=%s' % account.link_id) + # self.location('/NS_AVEEC?ch4=%s' % account._link_id) # return self.page.get_operations() diff --git a/modules/cragr/pages/accounts_list.py b/modules/cragr/pages/accounts_list.py index 48c6329f..d40bae13 100644 --- a/modules/cragr/pages/accounts_list.py +++ b/modules/cragr/pages/accounts_list.py @@ -45,11 +45,12 @@ class AccountsList(CragrBasePage): for div in self.document.getiterator('div'): if div.attrib.get('class', '') == 'dv' and div.getchildren()[0].tag in ('a', 'br'): account = Account() + account._link_id = None if div.getchildren()[0].tag == 'a': # This is at least present on CA Nord-Est # Note: we do not know yet how history-less accounts are displayed by this layout account.label = ' '.join(div.find('a').text.split()[:-1]) - account.link_id = div.find('a').get('href', '') + account._link_id = div.find('a').get('href', '') account.id = div.find('a').text.split()[-1] s = div.find('div').find('b').find('span').text else: @@ -57,12 +58,12 @@ class AccountsList(CragrBasePage): first_link = div.find('a') if first_link is not None: account.label = first_link.text.strip() - account.link_id = first_link.get('href', '') + account._link_id = first_link.get('href', '') s = div.find('div').find('b').text else: # there is no link to any history page for accounts like "PEA" or "TITRES" account.label = div.findall('br')[0].tail.strip() - account.link_id = None + account._link_id = None s = div.xpath('following-sibling::div//b')[0].text account.id = div.findall('br')[1].tail.strip() account.balance = clean_amount(s) diff --git a/modules/creditmutuel/browser.py b/modules/creditmutuel/browser.py index 6a77c6c5..694f2b29 100644 --- a/modules/creditmutuel/browser.py +++ b/modules/creditmutuel/browser.py @@ -93,7 +93,7 @@ class CreditMutuelBrowser(BaseBrowser): self.currentSubBank = subbank def get_history(self, account): - page_url = account.link_id + page_url = account._link_id #operations_count = 0 l_ret = [] while (page_url): @@ -170,5 +170,5 @@ class CreditMutuelBrowser(BaseBrowser): #def get_coming_operations(self, account): # if not self.is_on_page(AccountComing) or self.page.account.id != account.id: - # self.location('/NS_AVEEC?ch4=%s' % account.link_id) + # self.location('/NS_AVEEC?ch4=%s' % account._link_id) # return self.page.get_operations() diff --git a/modules/creditmutuel/pages.py b/modules/creditmutuel/pages.py index cb81aaaf..b952f9d3 100644 --- a/modules/creditmutuel/pages.py +++ b/modules/creditmutuel/pages.py @@ -54,8 +54,8 @@ class AccountsPage(BasePage): if first_td.attrib.get('class', '') == 'i g' or first_td.attrib.get('class', '') == 'p g': account = Account() account.label = u"%s"%first_td.find('a').text.strip() - account.link_id = first_td.find('a').get('href', '') - if account.link_id.startswith('POR_SyntheseLst'): + account._link_id = first_td.find('a').get('href', '') + if account._link_id.startswith('POR_SyntheseLst'): continue account.id = first_td.find('a').text.split(' ')[0]+first_td.find('a').text.split(' ')[1] diff --git a/modules/hsbc/backend.py b/modules/hsbc/backend.py index f32f9655..567daddf 100644 --- a/modules/hsbc/backend.py +++ b/modules/hsbc/backend.py @@ -57,5 +57,5 @@ class HSBCBackend(BaseBackend, ICapBank): def iter_history(self, account): with self.browser: - for history in self.browser.get_history(account.link_id): + for history in self.browser.get_history(account._link_id): yield history diff --git a/modules/hsbc/pages/accounts.py b/modules/hsbc/pages/accounts.py index 252f88bf..8f93a1a0 100644 --- a/modules/hsbc/pages/accounts.py +++ b/modules/hsbc/pages/accounts.py @@ -41,9 +41,9 @@ class AccountsListPage(BasePage): a = tds[0].findall('a')[-1] account.label = a.text.strip() - account.link_id = a.attrib['href'] + account._link_id = a.attrib['href'] - if not 'CPT_IdPrestation' in account.link_id: + if not 'CPT_IdPrestation' in account._link_id: continue tag = tds[2].find('font') diff --git a/modules/lcl/browser.py b/modules/lcl/browser.py index cef1a61f..b46a2aeb 100644 --- a/modules/lcl/browser.py +++ b/modules/lcl/browser.py @@ -84,10 +84,10 @@ class LCLBrowser(BaseBrowser): def get_history(self,account): if not self.is_on_page(AccountHistoryPage) : - self.location('%s://%s%s' % (self.PROTOCOL, self.DOMAIN, account.link_id)) + self.location('%s://%s%s' % (self.PROTOCOL, self.DOMAIN, account._link_id)) return self.page.get_operations(account) #def get_coming_operations(self, account): # if not self.is_on_page(AccountComing) or self.page.account.id != account.id: - # self.location('/NS_AVEEC?ch4=%s' % account.link_id) + # self.location('/NS_AVEEC?ch4=%s' % account._link_id) # return self.page.get_operations() diff --git a/modules/lcl/pages.py b/modules/lcl/pages.py index 237ac452..e5685321 100644 --- a/modules/lcl/pages.py +++ b/modules/lcl/pages.py @@ -127,7 +127,7 @@ class AccountsPage(BasePage): link=a.attrib.get('href') if link is not None and link.startswith("/outil/UWLM/ListeMouvements"): account = Account() - account.link_id=link+"&mode=45" + account._link_id=link+"&mode=45" parameters=link.split("?").pop().split("&") for parameter in parameters: list=parameter.split("=") diff --git a/modules/societegenerale/browser.py b/modules/societegenerale/browser.py index 3a1860cf..8cac7f3d 100644 --- a/modules/societegenerale/browser.py +++ b/modules/societegenerale/browser.py @@ -83,7 +83,7 @@ class SocieteGenerale(BaseBrowser): raise NotImplementedError() #if not self.is_on_page(AccountHistory) or self.page.account.id != account.id: - # self.location(account.link_id) + # self.location(account._link_id) #return self.page.get_operations() def transfer(self, from_id, to_id, amount, reason=None): diff --git a/modules/societegenerale/pages/accounts_list.py b/modules/societegenerale/pages/accounts_list.py index 652f69dc..91eba3ca 100644 --- a/modules/societegenerale/pages/accounts_list.py +++ b/modules/societegenerale/pages/accounts_list.py @@ -38,7 +38,7 @@ class AccountsList(BasePage): if td.attrib.get('headers', '') == 'TypeCompte': a = td.find('a') account.label = a.find("span").text - account.link_id = a.get('href', '') + account._link_id = a.get('href', '') elif td.attrib.get('headers', '') == 'NumeroCompte': id = td.text