port to the new format API (blame cbenz who has broken three frontends once)

This commit is contained in:
Romain Bignon 2010-06-21 11:06:34 +02:00
commit 7158d9c97b
3 changed files with 38 additions and 44 deletions

View file

@ -42,7 +42,7 @@ class Boobank(ConsoleApplication):
def command_list(self): def command_list(self):
try: try:
for backend, account in self.weboob.do('iter_accounts'): for backend, account in self.weboob.do('iter_accounts'):
self.format(account) self.format(account, backend.name)
except weboob.CallErrors, errors: except weboob.CallErrors, errors:
for backend, error, backtrace in errors: for backend, error, backtrace in errors:
if isinstance(error, weboob.tools.browser.BrowserIncorrectPassword): if isinstance(error, weboob.tools.browser.BrowserIncorrectPassword):
@ -60,7 +60,7 @@ class Boobank(ConsoleApplication):
try: try:
for backend, operation in self.weboob.do(do): for backend, operation in self.weboob.do(do):
self.format(operation) self.format(operation, backend.name)
total += operation.amount total += operation.amount
except weboob.CallErrors, errors: except weboob.CallErrors, errors:
for backend, error, backtrace in errors: for backend, error, backtrace in errors:

View file

@ -1,22 +1,19 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" # Copyright(C) 2010 Romain Bignon
Copyright(C) 2010 Romain Bignon #
# This program is free software; you can redistribute it and/or modify
This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License.
the Free Software Foundation, version 3 of the License. #
# This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details.
GNU General Public License for more details. #
# You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software
along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
"""
from __future__ import with_statement from __future__ import with_statement
@ -62,7 +59,7 @@ class Weboorrents(ConsoleApplication):
if not torrent: if not torrent:
logging.error('Torrent "%s" not found' % id) logging.error('Torrent "%s" not found' % id)
return 1 return 1
self.format(torrent) self.format(torrent, backend.name)
@ConsoleApplication.command('Get the torrent file') @ConsoleApplication.command('Get the torrent file')
def command_getfile(self, id, dest): def command_getfile(self, id, dest):
@ -86,4 +83,4 @@ class Weboorrents(ConsoleApplication):
def command_search(self, pattern=None): def command_search(self, pattern=None):
print u'Search pattern: %s' % pattern if pattern else u'Last torrents' print u'Search pattern: %s' % pattern if pattern else u'Last torrents'
for backend, torrent in self.weboob.do('iter_torrents', pattern=pattern): for backend, torrent in self.weboob.do('iter_torrents', pattern=pattern):
self.format(torrent) self.format(torrent, backend.name)

View file

@ -1,22 +1,19 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" # Copyright(C) 2010 Romain Bignon
Copyright(C) 2010 Romain Bignon #
# This program is free software; you can redistribute it and/or modify
This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License.
the Free Software Foundation, version 3 of the License. #
# This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details.
GNU General Public License for more details. #
# You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software
along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
"""
import logging import logging
@ -41,13 +38,13 @@ class WetBoobs(ConsoleApplication):
@ConsoleApplication.command('search cities') @ConsoleApplication.command('search cities')
def command_search(self, pattern): def command_search(self, pattern):
for backend, city in self.weboob.do('iter_city_search', pattern): for backend, city in self.weboob.do('iter_city_search', pattern):
self.format(city) self.format(city, backend.name)
@ConsoleApplication.command('get current weather') @ConsoleApplication.command('get current weather')
def command_current(self, city): def command_current(self, city):
try: try:
for backend, current in self.weboob.do('get_current', city): for backend, current in self.weboob.do('get_current', city):
self.format(current) self.format(current, backend.name)
except CallErrors, e: except CallErrors, e:
for error in e: for error in e:
if isinstance(error, CityNotFound): if isinstance(error, CityNotFound):
@ -59,7 +56,7 @@ class WetBoobs(ConsoleApplication):
def command_forecasts(self, city): def command_forecasts(self, city):
try: try:
for backend, forecast in self.weboob.do('iter_forecast', city): for backend, forecast in self.weboob.do('iter_forecast', city):
self.format(forecast) self.format(forecast, backend.name)
except CallErrors, e: except CallErrors, e:
for error in e: for error in e:
if isinstance(error, CityNotFound): if isinstance(error, CityNotFound):