From e1535b691eaaada3befc937bac51ce3630fec193 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Sat, 9 Sep 2017 18:18:04 +0200 Subject: [PATCH] captcha: little coding style improvement --- modules/amazon/browser.py | 2 +- modules/edf/par/browser.py | 2 +- weboob/exceptions.py | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/amazon/browser.py b/modules/amazon/browser.py index b2b59de1b9..8cd3482fb9 100644 --- a/modules/amazon/browser.py +++ b/modules/amazon/browser.py @@ -133,7 +133,7 @@ def do_login(self): if not has_captcha: raise BrowserIncorrectPassword() else: - raise CaptchaQuestion(image_url=has_captcha, type="image_captcha") + raise CaptchaQuestion('image_captcha', image_url=has_captcha) def location(self, *args, **kwargs): """ diff --git a/modules/edf/par/browser.py b/modules/edf/par/browser.py index 3f32642e2a..3a67a6b9eb 100644 --- a/modules/edf/par/browser.py +++ b/modules/edf/par/browser.py @@ -67,7 +67,7 @@ def do_login(self): if self.page.has_captcha_request(): website_key = self.page.get_recaptcha_key() # google recaptcha plubic key website_url = "https://particulier.edf.fr/fr/accueil.html" - raise CaptchaQuestion(website_key=website_key, website_url=website_url, type="g_recaptcha") + raise CaptchaQuestion('g_recaptcha', website_key=website_key, website_url=website_url) else: raise BrowserIncorrectPassword() else: diff --git a/weboob/exceptions.py b/weboob/exceptions.py index 199d7915ce..d88ec18b40 100644 --- a/weboob/exceptions.py +++ b/weboob/exceptions.py @@ -46,12 +46,11 @@ class CaptchaQuestion(Exception): """ Handles captcha """ - def __init__(self, website_key=None, website_url=None, image_url=None, type=None): + def __init__(self, type=None, **kwargs): super(CaptchaQuestion, self).__init__("The site requires solving a captcha") - self.website_key = website_key - self.website_url = website_url self.type = type - self.image_url = image_url + for key, value in kwargs.items(): + setattr(self, key, value) class BrowserHTTPNotFound(BrowserUnavailable): -- GitLab