Commit 349815fb authored by Romain Bignon's avatar Romain Bignon

backport modules fixes from master

parent b15a1568
Pipeline #2244 canceled with stages
import weboob.browser.filters.standard as OLD
# can't import *, __all__ is incomplete...
for attr in dir(OLD):
globals()[attr] = getattr(OLD, attr)
try:
__all__ = OLD.__all__
except AttributeError:
pass
class Coalesce(MultiFilter):
"""
Returns the first value that is not falsy,
or default if all values are falsy.
"""
@debug()
def filter(self, values):
for value in values:
if value:
return value
return self.default_or_raise(FilterError('All falsy and no default.'))
class MapIn(Filter):
"""
Map the pattern of a selected value to another value using a dict.
"""
def __init__(self, selector, map_dict, default=_NO_DEFAULT):
"""
:param selector: key from `map_dict` to use
"""
super(MapIn, self).__init__(selector, default=default)
self.map_dict = map_dict
@debug()
def filter(self, txt):
"""
:raises: :class:`ItemNotFound` if key pattern does not exist in dict
"""
for key in self.map_dict:
if key in txt:
return self.map_dict[key]
return self.default_or_raise(ItemNotFound('Unable to handle %r on %r' % (txt, self.map_dict)))
......@@ -23,7 +23,7 @@ from weboob.capabilities.base import NotAvailable
from weboob.capabilities.image import BaseImage, Thumbnail
from weboob.browser.pages import HTMLPage, pagination
from weboob.browser.elements import ItemElement, ListElement, method
from weboob.browser.filters.standard import CleanText, Regexp, Env, CleanDecimal, Eval
from .compat.weboob_browser_filters_standard import CleanText, Regexp, Env, CleanDecimal, Eval
from weboob.browser.filters.json import Dict, NotFound
from datetime import datetime, date, time
from dateutil.parser import parse as parse_date
......
import weboob.browser.filters.standard as OLD
# can't import *, __all__ is incomplete...
for attr in dir(OLD):
globals()[attr] = getattr(OLD, attr)
try:
__all__ = OLD.__all__
except AttributeError:
pass
class Coalesce(MultiFilter):
"""
Returns the first value that is not falsy,
or default if all values are falsy.
"""
@debug()
def filter(self, values):
for value in values:
if value:
return value
return self.default_or_raise(FilterError('All falsy and no default.'))
class MapIn(Filter):
"""
Map the pattern of a selected value to another value using a dict.
"""
def __init__(self, selector, map_dict, default=_NO_DEFAULT):
"""
:param selector: key from `map_dict` to use
"""
super(MapIn, self).__init__(selector, default=default)
self.map_dict = map_dict
@debug()
def filter(self, txt):
"""
:raises: :class:`ItemNotFound` if key pattern does not exist in dict
"""
for key in self.map_dict:
if key in txt:
return self.map_dict[key]
return self.default_or_raise(ItemNotFound('Unable to handle %r on %r' % (txt, self.map_dict)))
......@@ -21,7 +21,7 @@ import requests
from weboob.browser.pages import HTMLPage, pagination, JsonPage
from weboob.browser.elements import ItemElement, method, DictElement
from weboob.browser.filters.standard import CleanText, Regexp, Date
from .compat.weboob_browser_filters_standard import CleanText, Regexp, Date
from weboob.browser.filters.html import CleanHTML
from weboob.browser.filters.json import Dict
......
import weboob.browser.filters.standard as OLD
# can't import *, __all__ is incomplete...
for attr in dir(OLD):
globals()[attr] = getattr(OLD, attr)
try:
__all__ = OLD.__all__
except AttributeError:
pass
class Coalesce(MultiFilter):
"""
Returns the first value that is not falsy,
or default if all values are falsy.
"""
@debug()
def filter(self, values):
for value in values:
if value:
return value
return self.default_or_raise(FilterError('All falsy and no default.'))
class MapIn(Filter):
"""
Map the pattern of a selected value to another value using a dict.
"""
def __init__(self, selector, map_dict, default=_NO_DEFAULT):
"""
:param selector: key from `map_dict` to use
"""
super(MapIn, self).__init__(selector, default=default)
self.map_dict = map_dict
@debug()
def filter(self, txt):
"""
:raises: :class:`ItemNotFound` if key pattern does not exist in dict
"""
for key in self.map_dict:
if key in txt:
return self.map_dict[key]
return self.default_or_raise(ItemNotFound('Unable to handle %r on %r' % (txt, self.map_dict)))
......@@ -24,7 +24,7 @@ from random import randint
import requests
from weboob.browser.elements import ListElement, ItemElement, method
from weboob.browser.filters.standard import CleanText, Regexp, CleanDecimal, Date, Async, BrowserURL
from .compat.weboob_browser_filters_standard import CleanText, Regexp, CleanDecimal, Date, Async, BrowserURL
from weboob.browser.pages import HTMLPage, LoggedPage, pagination
from weboob.capabilities.bank import Account, Investment, Transaction
from weboob.capabilities.base import NotAvailable
......
import weboob.browser.filters.standard as OLD
# can't import *, __all__ is incomplete...
for attr in dir(OLD):
globals()[attr] = getattr(OLD, attr)
try:
__all__ = OLD.__all__
except AttributeError:
pass
class Coalesce(MultiFilter):
"""
Returns the first value that is not falsy,
or default if all values are falsy.
"""
@debug()
def filter(self, values):
for value in values:
if value:
return value
return self.default_or_raise(FilterError('All falsy and no default.'))
class MapIn(Filter):
"""
Map the pattern of a selected value to another value using a dict.
"""
def __init__(self, selector, map_dict, default=_NO_DEFAULT):
"""
:param selector: key from `map_dict` to use
"""
super(MapIn, self).__init__(selector, default=default)
self.map_dict = map_dict
@debug()
def filter(self, txt):
"""
:raises: :class:`ItemNotFound` if key pattern does not exist in dict
"""
for key in self.map_dict:
if key in txt:
return self.map_dict[key]
return self.default_or_raise(ItemNotFound('Unable to handle %r on %r' % (txt, self.map_dict)))
......@@ -20,7 +20,7 @@
from weboob.browser.pages import HTMLPage
from weboob.browser.elements import ItemElement, ListElement, method
from weboob.browser.filters.standard import CleanText, Date, Regexp, Filter, Env, Format, Decode, Time, Type
from .compat.weboob_browser_filters_standard import CleanText, Date, Regexp, Filter, Env, Format, Decode, Time, Type
from weboob.browser.filters.html import CleanHTML, XPath
from weboob.browser.filters.json import Dict
......
import weboob.browser.filters.standard as OLD
# can't import *, __all__ is incomplete...
for attr in dir(OLD):
globals()[attr] = getattr(OLD, attr)
try:
__all__ = OLD.__all__
except AttributeError:
pass
class Coalesce(MultiFilter):
"""
Returns the first value that is not falsy,
or default if all values are falsy.
"""
@debug()
def filter(self, values):
for value in values:
if value:
return value
return self.default_or_raise(FilterError('All falsy and no default.'))
class MapIn(Filter):
"""
Map the pattern of a selected value to another value using a dict.
"""
def __init__(self, selector, map_dict, default=_NO_DEFAULT):
"""
:param selector: key from `map_dict` to use
"""
super(MapIn, self).__init__(selector, default=default)
self.map_dict = map_dict
@debug()
def filter(self, txt):
"""
:raises: :class:`ItemNotFound` if key pattern does not exist in dict
"""
for key in self.map_dict:
if key in txt:
return self.map_dict[key]
return self.default_or_raise(ItemNotFound('Unable to handle %r on %r' % (txt, self.map_dict)))
......@@ -24,7 +24,7 @@ from datetime import time, datetime, date
from weboob.browser.pages import HTMLPage, pagination
from weboob.browser.elements import ItemElement, ListElement, method
from weboob.browser.filters.standard import Regexp, CleanText, DateTime, Env, Format, BrowserURL
from .compat.weboob_browser_filters_standard import Regexp, CleanText, DateTime, Env, Format, BrowserURL
from weboob.browser.filters.html import Link, XPath, CleanHTML
from weboob.tools.date import parse_french_date
......
import weboob.browser.filters.standard as OLD
# can't import *, __all__ is incomplete...
for attr in dir(OLD):
globals()[attr] = getattr(OLD, attr)
try:
__all__ = OLD.__all__
except AttributeError:
pass
class Coalesce(MultiFilter):
"""
Returns the first value that is not falsy,
or default if all values are falsy.
"""
@debug()
def filter(self, values):
for value in values:
if value:
return value
return self.default_or_raise(FilterError('All falsy and no default.'))
class MapIn(Filter):
"""
Map the pattern of a selected value to another value using a dict.
"""
def __init__(self, selector, map_dict, default=_NO_DEFAULT):
"""
:param selector: key from `map_dict` to use
"""
super(MapIn, self).__init__(selector, default=default)
self.map_dict = map_dict
@debug()
def filter(self, txt):
"""
:raises: :class:`ItemNotFound` if key pattern does not exist in dict
"""
for key in self.map_dict:
if key in txt:
return self.map_dict[key]
return self.default_or_raise(ItemNotFound('Unable to handle %r on %r' % (txt, self.map_dict)))
......@@ -23,7 +23,7 @@ from weboob.browser.elements import ItemElement, DictElement, method
from weboob.capabilities.recipe import Recipe, Comment
from weboob.capabilities.base import NotAvailable
from weboob.capabilities.image import BaseImage, Thumbnail
from weboob.browser.filters.standard import Env, Format, Join, Eval
from .compat.weboob_browser_filters_standard import Env, Format, Join, Eval
from weboob.browser.filters.json import Dict
......
......@@ -175,7 +175,7 @@ class AmazonBrowser(LoginBrowser, StatesMixin):
self.handle_captcha(captcha)
else:
msg = self.page.get_error_message()
assert self.WRONGPASS_MESSAGE in msg, msg
assert any(wrongpass_message in msg for wrongpass_message in self.WRONGPASS_MESSAGES), msg
raise BrowserIncorrectPassword(msg)
def is_login(self):
......
import weboob.browser.filters.standard as OLD
# can't import *, __all__ is incomplete...
for attr in dir(OLD):
globals()[attr] = getattr(OLD, attr)
try:
__all__ = OLD.__all__
except AttributeError:
pass
class Coalesce(MultiFilter):
"""
Returns the first value that is not falsy,
or default if all values are falsy.
"""
@debug()
def filter(self, values):
for value in values:
if value:
return value
return self.default_or_raise(FilterError('All falsy and no default.'))
class MapIn(Filter):
"""
Map the pattern of a selected value to another value using a dict.
"""
def __init__(self, selector, map_dict, default=_NO_DEFAULT):
"""
:param selector: key from `map_dict` to use
"""
super(MapIn, self).__init__(selector, default=default)
self.map_dict = map_dict
@debug()
def filter(self, txt):
"""
:raises: :class:`ItemNotFound` if key pattern does not exist in dict
"""
for key in self.map_dict:
if key in txt:
return self.map_dict[key]
return self.default_or_raise(ItemNotFound('Unable to handle %r on %r' % (txt, self.map_dict)))
......@@ -22,7 +22,7 @@ from __future__ import unicode_literals