From 4cc2b14393b10f1c3f79304c2767f2c344422d5f Mon Sep 17 00:00:00 2001 From: Quentin Defenouillere Date: Mon, 22 Jul 2019 18:44:25 +0200 Subject: [PATCH] [cragr/regions] Return no transaction if we cannot find the ongoing_coming Some cards haven't been used for a while so we cannot fetch a date for the ongoing coming ; in these cases we return no transaction for history or coming other the Regexp() will crash. Closes: 12355@zendesk --- modules/cragr/regions/browser.py | 3 +++ modules/cragr/regions/pages.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/cragr/regions/browser.py b/modules/cragr/regions/browser.py index f217851fec..5c1e975fc1 100644 --- a/modules/cragr/regions/browser.py +++ b/modules/cragr/regions/browser.py @@ -530,6 +530,9 @@ def iter_history(self, account, coming=False): # we must skip the ongoing one but fetch the other ones # even if they are in the future. ongoing_coming = self.page.get_ongoing_coming() + if not ongoing_coming: + # This card has no available history or coming. + return card_transactions = [] latest_date = None diff --git a/modules/cragr/regions/pages.py b/modules/cragr/regions/pages.py index 5682463c98..95c0d3ed60 100644 --- a/modules/cragr/regions/pages.py +++ b/modules/cragr/regions/pages.py @@ -418,8 +418,10 @@ def get_ongoing_coming(self): # the coming is positive, it will become 'Opérations créditées' raw_date = Regexp( CleanText('//table[@class="ca-table"]//tr[1]//b[contains(text(), "Opérations débitées") or contains(text(), "Opérations créditées")]'), - r'le (.*) :' + r'le (.*) :', default=None )(self.doc) + if not raw_date: + return None return parse_french_date(raw_date).date() def get_card_transactions(self, latest_date, ongoing_coming): -- GitLab