WebNip.iter_backends takes a new optional parameter 'module'
This commit is contained in:
parent
f5e5584004
commit
1a8a0db712
2 changed files with 6 additions and 3 deletions
|
|
@ -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)):
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue