From a5f282c9ba607d666c859f07edcee89258a5277e Mon Sep 17 00:00:00 2001 From: Vincent Ardisson Date: Fri, 27 Jan 2017 19:12:08 +0100 Subject: [PATCH] [axabanque] when accounts has no detailed investments, just return empty The site just reports the portfolio share, not even the amount. Return an empty list instead of too sparse data. --- modules/axabanque/browser.py | 4 ++++ modules/axabanque/pages/wealth.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/axabanque/browser.py b/modules/axabanque/browser.py index f8b8adbd92..fa5883ea5d 100644 --- a/modules/axabanque/browser.py +++ b/modules/axabanque/browser.py @@ -159,6 +159,10 @@ def iter_investment(self, account): invs = list(self.page.iter_investment()) elif account._acctype == "investment": investment_link = self.location(account._link).page.get_investment_link() + if investment_link is None: + self.logger.warning('no investment link for account %s, returning empty', account) + # fake data, don't cache it + return [] invs = list(self.location(investment_link).page.iter_investment()) self.cache['invs'][account.id] = invs return self.cache['invs'][account.id] diff --git a/modules/axabanque/pages/wealth.py b/modules/axabanque/pages/wealth.py index 93220172d9..03e8989ee5 100644 --- a/modules/axabanque/pages/wealth.py +++ b/modules/axabanque/pages/wealth.py @@ -94,7 +94,7 @@ def build_doc(self, content): return super(HistoryPage, self).build_doc(content) def get_investment_link(self): - return Attr('//article[has-class("card-distribution")]', 'data-url')(self.doc) + return Attr('//article[has-class("card-distribution")]', 'data-url', default=None)(self.doc) def get_pagination_link(self): return Attr('//div[has-class("default")][@data-current-page]', 'data-url')(self.doc) -- GitLab