Remove condition from core
This commit is contained in:
parent
29567cffa4
commit
9a0f9d0fc9
4 changed files with 11 additions and 26 deletions
|
|
@ -28,7 +28,7 @@ from weboob.tools.misc import get_backtrace
|
|||
from weboob.tools.log import getLogger
|
||||
|
||||
|
||||
__all__ = ['BackendsCall', 'CallErrors', 'IResultsCondition', 'ResultsConditionError']
|
||||
__all__ = ['BackendsCall', 'CallErrors']
|
||||
|
||||
|
||||
class CallErrors(Exception):
|
||||
|
|
@ -44,22 +44,11 @@ class CallErrors(Exception):
|
|||
return self.errors.__iter__()
|
||||
|
||||
|
||||
class IResultsCondition(object):
|
||||
def is_valid(self, obj):
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
class ResultsConditionError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class BackendsCall(object):
|
||||
def __init__(self, backends, condition, function, *args, **kwargs):
|
||||
def __init__(self, backends, function, *args, **kwargs):
|
||||
"""
|
||||
:param backends: List of backends to call
|
||||
:type backends: list[:class:`BaseBackend`]
|
||||
:param condition: Condition applied on results (can be None)
|
||||
:type condition: :class:`IResultsCondition`
|
||||
:param function: backends' method name, or callable object.
|
||||
:type function: :class:`str` or :class:`callable`
|
||||
"""
|
||||
|
|
@ -68,8 +57,6 @@ class BackendsCall(object):
|
|||
self.backends = {}
|
||||
for backend in backends:
|
||||
self.backends[backend.name] = False
|
||||
# Condition
|
||||
self.condition = condition
|
||||
# Global mutex on object
|
||||
self.mutex = RLock()
|
||||
# Event set when every backends have give their data
|
||||
|
|
|
|||
|
|
@ -318,8 +318,6 @@ class Weboob(object):
|
|||
:type backends: list[:class:`str`]
|
||||
:param caps: iterate on backends which implement this caps
|
||||
:type caps: list[:class:`weboob.capabilities.base.IBaseCap`]
|
||||
:param condition: a condition to validate results
|
||||
:type condition: :class:`weboob.core.bcall.IResultsCondition`
|
||||
:rtype: A :class:`weboob.core.bcall.BackendsCall` object (iterable)
|
||||
"""
|
||||
backends = self.backend_instances.values()
|
||||
|
|
@ -349,13 +347,12 @@ class Weboob(object):
|
|||
if 'caps' in kwargs:
|
||||
caps = kwargs.pop('caps')
|
||||
backends = [backend for backend in backends if backend.has_caps(caps)]
|
||||
condition = kwargs.pop('condition', None)
|
||||
|
||||
# The return value MUST BE the BackendsCall instance. Please never iterate
|
||||
# here on this object, because caller might want to use other methods, like
|
||||
# wait() on callback_thread().
|
||||
# Thanks a lot.
|
||||
return BackendsCall(backends, condition, function, *args, **kwargs)
|
||||
return BackendsCall(backends, function, *args, **kwargs)
|
||||
|
||||
def schedule(self, interval, function, *args):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue