Remove backend for do() calls

This commit is contained in:
Florent 2014-10-09 11:04:09 +02:00
commit 628c63f899
33 changed files with 112 additions and 113 deletions

View file

@ -193,20 +193,20 @@ class MyThread(Thread):
backend.set_message_read(backend.fill_thread(thread, ['root']).root)
def check_dlfp(self):
for backend, msg in self.weboob.do('iter_unread_messages', backends=['dlfp']):
for msg in self.weboob.do('iter_unread_messages', backends=['dlfp']):
word = self.find_keywords(msg.content)
if word is not None:
url = msg.signature[msg.signature.find('https://linuxfr'):]
self.bot.send_message('[DLFP] %s talks about %s: %s' % (
msg.sender, word, url))
backend.set_message_read(msg)
self.weboob[msg.backend].set_message_read(msg)
def check_board(self):
def iter_messages(backend):
with backend.browser:
return backend.browser.iter_new_board_messages()
for backend, msg in self.weboob.do(iter_messages, backends=['dlfp']):
for msg in self.weboob.do(iter_messages, backends=['dlfp']):
word = self.find_keywords(msg.message)
if word is not None and msg.login != 'moules':
message = msg.message.replace(word, '\002%s\002' % word)

View file

@ -144,7 +144,7 @@ class BoobankMuninPlugin(object):
accounts = []
if self.monitored_accounts is not None:
d = {}
for backend, account in self.weboob.do('iter_accounts'):
for account in self.weboob.do('iter_accounts'):
if self.monitored(account):
d['%s@%s' % (account.id, account.backend)] = account
@ -154,7 +154,7 @@ class BoobankMuninPlugin(object):
except KeyError:
pass
else:
accounts = reversed([a for b, a in self.weboob.do('iter_accounts')])
accounts = reversed([a for a in self.weboob.do('iter_accounts')])
first = True
for account in accounts:
@ -191,7 +191,7 @@ class BoobankMuninPlugin(object):
self.new_cache('boobank-munin')
self.weboob.load_backends(CapBank)
try:
for backend, account in self.weboob.do('iter_accounts'):
for account in self.weboob.do('iter_accounts'):
if self.monitored(account):
balance = account.balance
if account.coming and self.add_coming:

View file

@ -224,9 +224,9 @@ class GenericMuninPlugin(object):
results = []
for result in self.weboob.do(self.object_list):
results.append(result)
for backend, result in results:
for result in results:
try:
for i in self.weboob.do(self.do[0], result.id, backends=backend):
for i in self.weboob.do(self.do[0], result.id, backends=result.backend):
yield i
# Do not crash if one module does not implement the feature
except CallErrors:
@ -284,7 +284,7 @@ class GenericMuninPlugin(object):
objects = []
if self.tomonitore or self.exclude:
d = {}
for backend, result in self.build_do():
for result in self.build_do():
if self.monitored(result):
d[self.result2weboobid(result)] = result
@ -329,7 +329,7 @@ class GenericMuninPlugin(object):
self.new_cache(self.name)
self.weboob.load_backends(self.capa)
try:
for backend, result in self.build_do():
for result in self.build_do():
if self.monitored(result):
value = self.get_value(result)
if value is not NotAvailable:

View file

@ -20,7 +20,7 @@ class Videoobmc(Weboobmc):
fields = ['id', 'title', 'date', 'description', 'author', 'duration', 'thumbnail', 'url']
try:
for _backend, video in self.weboob.do(self._do_complete, self.count, fields, 'search_videos', **kwargs):
for video in self.weboob.do(self._do_complete, self.count, fields, 'search_videos', **kwargs):
yield video
except Exception as e:
print(e)
@ -42,7 +42,7 @@ class Videoobmc(Weboobmc):
def separate_collections_and_videos(self, objs):
videos = []
categories = []
for backend, obj in objs:
for obj in objs:
if isinstance(obj, Collection):
categories.append(obj)
else:
@ -50,5 +50,5 @@ class Videoobmc(Weboobmc):
return categories, videos
def download(self, _id, dest, backend):
for backend, _video in self.weboob.do('get_video', _id, backends=backend):
for _video in self.weboob.do('get_video', _id, backends=backend):
self.download_obj(_video, dest)