From 3f2ccc8a685798b8cde3b94e1f33dbbf17a3de96 Mon Sep 17 00:00:00 2001 From: Vincent Ardisson Date: Mon, 9 Apr 2018 18:00:59 +0200 Subject: [PATCH] [barclays] don't cache history It's useless and less readable --- modules/barclays/browser.py | 46 ++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/modules/barclays/browser.py b/modules/barclays/browser.py index c9bff78826..cc83abb122 100644 --- a/modules/barclays/browser.py +++ b/modules/barclays/browser.py @@ -156,36 +156,36 @@ def iter_history(self, account): elif account.type == Account.TYPE_LOAN: return [] - if account.id not in self.cache['history']: - self._go_to_account(account) - - if account.type in (Account.TYPE_LIFE_INSURANCE, Account.TYPE_MARKET): - if not self._go_to_account_space('Mouvements', account): - self.logger.warning('cannot go to history page for %r', account) - return [] + self._go_to_account(account) - history_page = self.page + if account.type in (Account.TYPE_LIFE_INSURANCE, Account.TYPE_MARKET): + if not self._go_to_account_space('Mouvements', account): + self.logger.warning('cannot go to history page for %r', account) + return [] - if account.type != Account.TYPE_LIFE_INSURANCE: - for _ in range(100): # on new history page they take previous results too, so go to the last page before starts recover history - form = history_page.form_to_history_page() + history_page = self.page - if not form: - break + if account.type != Account.TYPE_LIFE_INSURANCE: + for _ in range(100): # on new history page they take previous results too, so go to the last page before starts recover history + form = history_page.form_to_history_page() - try: - history_page = self.account.open(data=form) - except ConnectionError: # Sometime accounts have too much history and website crash - # Need to relogin - self._relogin() + if not form: + break - break - else: - assert False, "Too many iterations" + try: + history_page = self.account.open(data=form) + except ConnectionError: # Sometime accounts have too much history and website crash + # Need to relogin + self._relogin() - self.cache['history'][account.id] = list(history_page.iter_history()) if history_page.has_history() else [] + break + else: + assert False, "Too many iterations" - return self.cache['history'][account.id] + if history_page.has_history(): + return list(history_page.iter_history()) + else: + return [] @need_login def iter_coming(self, account): -- GitLab