From 1a8a0db712d5b37904e136ada20c1a9e618a8f0d Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Wed, 8 Oct 2014 16:24:49 +0200 Subject: [PATCH] WebNip.iter_backends takes a new optional parameter 'module' --- contrib/boobot.py | 2 +- weboob/core/ouiboube.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/contrib/boobot.py b/contrib/boobot.py index 4ee0f302..c1c6c790 100755 --- a/contrib/boobot.py +++ b/contrib/boobot.py @@ -173,7 +173,7 @@ class MyThread(Thread): def check_twitter(self): nb_tweets = 10 - for _, backend in self.weboob.load_backends(modules=['twitter']).iteritems(): + for backend in self.weboob.iter_backends(module='twitter'): for thread in list(itertools.islice(backend.iter_resources(None, ['search', 'weboob']), 0, nb_tweets)): diff --git a/weboob/core/ouiboube.py b/weboob/core/ouiboube.py index aac0d836..19ab7dcc 100644 --- a/weboob/core/ouiboube.py +++ b/weboob/core/ouiboube.py @@ -184,7 +184,7 @@ class WebNip(object): """ return len(self.backend_instances) - def iter_backends(self, caps=None): + def iter_backends(self, caps=None, module=None): """ Iter on each backends. @@ -192,10 +192,13 @@ class WebNip(object): :param caps: optional list of capabilities to select backends :type caps: tuple[:class:`weboob.capabilities.base.Capability`] + :param module: optional name of module + :type module: :class:`basestring` :rtype: iter[:class:`weboob.tools.backend.Module`] """ for _, backend in sorted(self.backend_instances.iteritems()): - if caps is None or backend.has_caps(caps): + if caps is None or backend.has_caps(caps) and \ + module is None or backend.NAME == module: with backend: yield backend