capabilities objets inherit from CapBaseObject (refs #369)
This commit is contained in:
parent
33d1574878
commit
e980e040ba
20 changed files with 126 additions and 102 deletions
|
|
@ -35,14 +35,14 @@ class Boobank(ConsoleApplication):
|
|||
COPYRIGHT = 'Copyright(C) 2010 Romain Bignon'
|
||||
|
||||
def main(self, argv):
|
||||
self.load_configured_backends(ICapBank)
|
||||
return self.process_command(*argv[1:])
|
||||
|
||||
@ConsoleApplication.command('List every available accounts')
|
||||
def command_list(self):
|
||||
self.load_configured_backends(ICapBank)
|
||||
try:
|
||||
for backend, account in self.do('iter_accounts'):
|
||||
self.format(account, backend.name)
|
||||
self.format(account)
|
||||
except weboob.core.CallErrors, errors:
|
||||
for backend, error, backtrace in errors:
|
||||
if isinstance(error, weboob.tools.browser.BrowserIncorrectPassword):
|
||||
|
|
@ -52,19 +52,13 @@ class Boobank(ConsoleApplication):
|
|||
|
||||
@ConsoleApplication.command('Display all future operations')
|
||||
def command_coming(self, id):
|
||||
total = 0.0
|
||||
id, backend_name = self.parse_id(id)
|
||||
names = (backend_name,) if backend_name is not None else None
|
||||
self.load_configured_backends(ICapBank, names=names)
|
||||
|
||||
def do(backend):
|
||||
account = backend.get_account(id)
|
||||
return backend.iter_operations(account)
|
||||
|
||||
try:
|
||||
for backend, operation in self.do(do):
|
||||
self.format(operation, backend.name)
|
||||
total += operation.amount
|
||||
except weboob.core.CallErrors, errors:
|
||||
for backend, error, backtrace in errors:
|
||||
if isinstance(error, AccountNotFound):
|
||||
logging.error(u'Error: account %s not found' % id)
|
||||
else:
|
||||
logging.error(u'Error[%s]: %s\n%s' % (backend.name, error, backtrace))
|
||||
for backend, operation in self.do(do):
|
||||
self.format(operation)
|
||||
|
|
|
|||
|
|
@ -47,12 +47,12 @@ class Chatoob(ConsoleApplication):
|
|||
@ConsoleApplication.command('list online contacts')
|
||||
def command_list(self):
|
||||
for backend, contact in self.do('iter_contacts', status=Contact.STATUS_ONLINE, caps=ICapContact):
|
||||
self.format(contact, backend.name)
|
||||
self.format(contact)
|
||||
|
||||
@ConsoleApplication.command('get messages')
|
||||
def command_messages(self):
|
||||
for backend, message in self.do('iter_chat_messages'):
|
||||
self.format(message, backend.name)
|
||||
self.format(message)
|
||||
|
||||
@ConsoleApplication.command('send message to contact')
|
||||
def command_send(self, _id, message):
|
||||
|
|
|
|||
|
|
@ -37,6 +37,6 @@ class Geolooc(ConsoleApplication):
|
|||
|
||||
self.load_configured_backends(ICapGeolocIp)
|
||||
for backend, location in self.do('get_location', argv[1]):
|
||||
self.format(location, backend.name)
|
||||
self.format(location)
|
||||
|
||||
return 0
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class Traveloob(ConsoleApplication):
|
|||
def command_stations(self, pattern):
|
||||
self.load_backends(ICapTravel)
|
||||
for backend, station in self.do('iter_station_search', pattern):
|
||||
self.format(station, backend.name)
|
||||
self.format(station)
|
||||
|
||||
@ConsoleApplication.command('List all departures for a given station')
|
||||
def command_departures(self, station, arrival=None):
|
||||
|
|
@ -59,4 +59,4 @@ class Traveloob(ConsoleApplication):
|
|||
|
||||
self.load_backends(ICapTravel, names=backends)
|
||||
for backend, departure in self.do('iter_station_departures', station_id, arrival_id):
|
||||
self.format(departure, backend.name)
|
||||
self.format(departure)
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class Videoob(ConsoleApplication):
|
|||
for backend, video in self.do('get_video', _id):
|
||||
if video is None:
|
||||
continue
|
||||
self.format(video, backend.name)
|
||||
self.format(video)
|
||||
|
||||
@ConsoleApplication.command('Search for videos')
|
||||
def command_search(self, pattern=None):
|
||||
|
|
@ -53,4 +53,4 @@ class Videoob(ConsoleApplication):
|
|||
self.set_formatter_header(u'Search pattern: %s' % pattern if pattern else u'Latest videos')
|
||||
for backend, video in self.do('iter_search_results', pattern=pattern, nsfw=self.options.nsfw,
|
||||
max_results=self.options.count):
|
||||
self.format(video, backend.name)
|
||||
self.format(video)
|
||||
|
|
|
|||
|
|
@ -47,6 +47,6 @@ class WeboobCli(ConsoleApplication):
|
|||
self.load_backends(cap_s)
|
||||
|
||||
for backend, obj in self.do(cmd, *args):
|
||||
self.format(obj, backend.name)
|
||||
self.format(obj)
|
||||
|
||||
return 0
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class Weboorrents(ConsoleApplication):
|
|||
found = 0
|
||||
for backend, torrent in self.do('get_torrent', _id, backends=backend_name):
|
||||
if torrent:
|
||||
self.format(torrent, backend.name)
|
||||
self.format(torrent)
|
||||
found = 1
|
||||
|
||||
if not found:
|
||||
|
|
@ -67,4 +67,4 @@ class Weboorrents(ConsoleApplication):
|
|||
def command_search(self, pattern=None):
|
||||
self.set_formatter_header(u'Search pattern: %s' % pattern if pattern else u'Latest torrents')
|
||||
for backend, torrent in self.do('iter_torrents', pattern=pattern):
|
||||
self.format(torrent, backend.name)
|
||||
self.format(torrent)
|
||||
|
|
|
|||
|
|
@ -39,13 +39,13 @@ class WetBoobs(ConsoleApplication):
|
|||
@ConsoleApplication.command('search cities')
|
||||
def command_search(self, pattern):
|
||||
for backend, city in self.do('iter_city_search', pattern):
|
||||
self.format(city, backend.name)
|
||||
self.format(city)
|
||||
|
||||
@ConsoleApplication.command('get current weather')
|
||||
def command_current(self, city):
|
||||
try:
|
||||
for backend, current in self.do('get_current', city):
|
||||
self.format(current, backend.name)
|
||||
self.format(current)
|
||||
except CallErrors, e:
|
||||
for error in e:
|
||||
if isinstance(error, CityNotFound):
|
||||
|
|
@ -57,7 +57,7 @@ class WetBoobs(ConsoleApplication):
|
|||
def command_forecasts(self, city):
|
||||
try:
|
||||
for backend, forecast in self.do('iter_forecast', city):
|
||||
self.format(forecast, backend.name)
|
||||
self.format(forecast)
|
||||
except CallErrors, e:
|
||||
for error in e:
|
||||
if isinstance(error, CityNotFound):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue