Commit a4dd1763 authored by Christophe Benz's avatar Christophe Benz Committed by Christophe Benz

use iterator instead of get_backends

parent bfdc3e01
......@@ -55,15 +55,12 @@ class Weboob:
module = self.modules_loader[modname]
self.backends[instname] = module.create_backend(self)
def get_backends(self, caps=None):
def iter_backends(self, caps=None):
if caps is None:
return self.backends
d = {}
for name, backend in self.backends.iteritems():
if backend.has_caps(caps):
d[name] = backend
return d
return self.backends.iteritems()
else:
return dict((name, backend) for name, backend in self.backends.iteritems()
if backend.has_caps(caps)).iteritems()
def schedule(self, interval, function, *args):
self.scheduler.enter(interval, 1, function, args)
......
......@@ -57,9 +57,8 @@ class Application(BaseApplication):
self.weboob.loop()
def process(self):
backends = self.weboob.get_backends()
for name, b in backends.iteritems():
for message in b.iter_new_messages():
for name, backend in self.weboob.iter_backends():
for message in backend.iter_new_messages():
self.send_email(name, message)
def send_email(self, backend_name, mail):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment