Revert "Refactor"

This reverts commit a6e3064cfc.
This commit is contained in:
Romain Bignon 2015-06-10 21:37:58 +02:00
commit c2bc351e4e

View file

@ -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):