From c2bc351e4e677fd850f4a155ace46bf68da8ca7f Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Wed, 10 Jun 2015 21:37:58 +0200 Subject: [PATCH] Revert "Refactor" This reverts commit a6e3064cfc97db67f590ef34cd32b02c6cce9828. --- modules/cragr/web/pages.py | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/modules/cragr/web/pages.py b/modules/cragr/web/pages.py index ca64cb5f..9b76eada 100644 --- a/modules/cragr/web/pages.py +++ b/modules/cragr/web/pages.py @@ -94,6 +94,7 @@ class _AccountsPage(BasePage): } def get_list(self): + iban = None for tr in self.document.xpath('//table[@class="ca-table"]/tr'): if not tr.attrib.get('class', '').startswith('colcelligne'): continue @@ -115,7 +116,22 @@ class _AccountsPage(BasePage): account.currency = account.get_currency(self.parser.tocleanstring(cols[self.COL_CURRENCY])) account._link = None - self.set_link(account, cols) + a = cols[0].find('a') + if a is not None: + account._link = a.attrib['href'].replace(' ', '%20') + page = self.browser.get_page(self.browser.openurl(account._link)) + url = page.get_iban_url() + if url: + page = self.browser.get_page(self.browser.openurl(url)) + iban = account.iban = page.get_iban() + elif iban: + # In case there is no available IBAN on this account (for + # example saving account), calculate it from the previous + # IBAN. + bankcode = iban[4:9] + counter = iban[9:14] + key = 97 - ((int(bankcode) * 89 + int(counter) * 15 + int(account.id) * 3) % 97) + account.iban = iban[:4] + bankcode + counter + account.id + str(key) yield account @@ -237,25 +253,7 @@ class CardsPage(BasePage): class AccountsPage(_AccountsPage): - - def set_link(self, account, cols): - iban = None - a = cols[0].find('a') - if a is not None: - account._link = a.attrib['href'].replace(' ', '%20') - page = self.browser.get_page(self.browser.openurl(account._link)) - url = page.get_iban_url() - if url: - page = self.browser.get_page(self.browser.openurl(url)) - iban = account.iban = page.get_iban() - elif iban: - # In case there is no available IBAN on this account (for - # example saving account), calculate it from the previous - # IBAN. - bankcode = iban[4:9] - counter = iban[9:14] - key = 97 - ((int(bankcode) * 89 + int(counter) * 15 + int(account.id) * 3) % 97) - account.iban = iban[:4] + bankcode + counter + account.id + str(key) + pass class SavingsPage(_AccountsPage):