do not crash if there is no operations

This commit is contained in:
Romain Bignon 2013-10-10 09:53:53 +02:00
commit 5c5cb5da8e
2 changed files with 8 additions and 0 deletions

View file

@ -110,7 +110,12 @@ class BanquePopulaire(BaseBrowser):
def get_history(self, account):
if not self.is_on_page(AccountsPage):
account = self.get_account(account.id)
self.location('/cyber/internet/ContinueTask.do', urllib.urlencode(account._params))
self.token = self.page.get_token()
if self.page.no_operations():
return
# Sort by values dates (see comment in TransactionsPage.get_history)
self.select_form(predicate=lambda form: form.attrs.get('id', '') == 'myForm')

View file

@ -320,3 +320,6 @@ class TransactionsPage(BasePage):
t.parse(date, re.sub(r'[ ]+', ' ', raw), vdate)
t.set_amount(credit, debit)
yield t
def no_operations(self):
return len(self.document.xpath('//table[@id="tbl1"]//td[@colspan]')) > 0