From bf17be4bdeffbb4545aaec39fe72f7f28b5cea2d Mon Sep 17 00:00:00 2001 From: Quentin Defenouillere Date: Mon, 3 Dec 2018 15:02:51 +0100 Subject: [PATCH] [boursorama] Add default values for Loan dates and Decimals Some Loans do not have all the possible information, for example "Next payment Date" or "Maturity date" are missing and replaced by "-". I added default=NotAvailable to all possibly missing values to avoid crash. Closes: 29091@sibi --- modules/boursorama/pages.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/boursorama/pages.py b/modules/boursorama/pages.py index b4d5efbdbb..79d6c3e619 100644 --- a/modules/boursorama/pages.py +++ b/modules/boursorama/pages.py @@ -343,13 +343,13 @@ class get_loan(ItemElement): obj_label = CleanText('//h2[contains(@class, "page-title__account")]//div[@class="account-edit-label"]/span') obj_total_amount = CleanDecimal('//p[contains(text(), "Montant emprunt")]/span', replace_dots=True) obj_currency = CleanCurrency('//p[contains(text(), "Montant emprunt")]/span') - obj_duration = CleanDecimal('//p[contains(text(), "Nombre prévisionnel d\'échéances restantes")]/span') + obj_duration = CleanDecimal('//p[contains(text(), "Nombre prévisionnel d\'échéances restantes")]/span', default=NotAvailable) obj_rate = CleanDecimal('//p[contains(text(), "Taux nominal en vigueur du prêt")]/span') - obj_nb_payments_left = CleanDecimal('//p[contains(text(), "Nombre prévisionnel d\'échéances restantes")]/span') - obj_next_payment_amount = CleanDecimal('//p[contains(text(), "Montant de la prochaine échéance")]/span', replace_dots=True) + obj_nb_payments_left = CleanDecimal('//p[contains(text(), "Nombre prévisionnel d\'échéances restantes")]/span', default=NotAvailable) + obj_next_payment_amount = CleanDecimal('//p[contains(text(), "Montant de la prochaine échéance")]/span', replace_dots=True, default=NotAvailable) obj_nb_payments_total = CleanDecimal('//p[contains(text(), "Nombre d\'écheances totales") or contains(text(), "Nombre total d\'échéances")]/span') obj_subscription_date = Date(CleanText('//p[contains(text(), "Date de départ du prêt")]/span'), parse_func=parse_french_date) - obj_maturity_date = Date(CleanText('//p[contains(text(), "Date prévisionnelle d\'échéance finale")]/span'), parse_func=parse_french_date) + obj_maturity_date = Date(CleanText('//p[contains(text(), "Date prévisionnelle d\'échéance finale")]/span'), parse_func=parse_french_date, default=NotAvailable) def obj_balance(self): balance = CleanDecimal('//p[contains(text(), "Capital restant dû")]/span', replace_dots=True)(self) -- GitLab