Index is back for some accounts...

This commit is contained in:
Florent 2014-09-04 23:36:48 +02:00
commit 3076579747
2 changed files with 11 additions and 2 deletions

View file

@ -131,19 +131,25 @@ class IngBrowser(LoginBrowser):
if account.type == Account.TYPE_CHECKING: if account.type == Account.TYPE_CHECKING:
history_function = AccountsList.get_transactions_cc history_function = AccountsList.get_transactions_cc
index = -1 # disable the index. It works without it on CC
else: else:
history_function = AccountsList.get_transactions_others history_function = AccountsList.get_transactions_others
index = 0
hashlist = [] hashlist = []
while True: while True:
for transaction in history_function(self.page): i = index
for transaction in history_function(self.page, index=index):
transaction.id = hashlib.md5(transaction._hash).hexdigest() transaction.id = hashlib.md5(transaction._hash).hexdigest()
while transaction.id in hashlist: while transaction.id in hashlist:
transaction.id = hashlib.md5(transaction.id + "1").hexdigest() transaction.id = hashlib.md5(transaction.id + "1").hexdigest()
hashlist.append(transaction.id) hashlist.append(transaction.id)
i += 1
yield transaction yield transaction
# if there is no more transactions, it is useless to continue # if there is no more transactions, it is useless to continue
if self.page.islast(): if self.page.islast() or i == index:
return return
if index >= 0:
index = i
data = {"AJAX:EVENTS_COUNT": 1, data = {"AJAX:EVENTS_COUNT": 1,
"AJAXREQUEST": "_viewRoot", "AJAXREQUEST": "_viewRoot",
"autoScroll": "", "autoScroll": "",

View file

@ -149,6 +149,9 @@ class AccountsList(LoggedPage, HTMLPage):
def condition(self): def condition(self):
if self.el.find('.//td[@class="date"]') is None: if self.el.find('.//td[@class="date"]') is None:
return False return False
if self.env['index'] > 0 and self.page.i < self.env['index']:
self.page.i += 1
return False
return True return True
@method @method