parent
9fee613cba
commit
c712da56a3
2 changed files with 22 additions and 5 deletions
|
|
@ -24,7 +24,8 @@ from decimal import Decimal
|
|||
from weboob.capabilities.bill import ICapBill, Detail, Subscription
|
||||
from weboob.tools.application.repl import ReplApplication, defaultcount
|
||||
from weboob.tools.application.formatters.iformatter import PrettyFormatter
|
||||
|
||||
from weboob.tools.application.base import MoreResultsAvailable
|
||||
from weboob.core import CallErrors
|
||||
|
||||
__all__ = ['Boobill']
|
||||
|
||||
|
|
@ -67,12 +68,28 @@ class Boobill(ReplApplication):
|
|||
else:
|
||||
l.append((id, backend_name))
|
||||
|
||||
more_results = []
|
||||
not_implemented = []
|
||||
self.start_format()
|
||||
for id, backend in l:
|
||||
names = (backend,) if backend is not None else None
|
||||
try:
|
||||
for backend, result in self.do(method, id, backends=names):
|
||||
self.format(result)
|
||||
except CallErrors as errors:
|
||||
for backend, error, backtrace in errors:
|
||||
if isinstance(error, MoreResultsAvailable):
|
||||
more_results.append(id + u'@' + backend.name)
|
||||
elif isinstance(error, NotImplementedError):
|
||||
if backend not in not_implemented:
|
||||
not_implemented.append(backend)
|
||||
else:
|
||||
self.bcall_error_handler(backend, error, backtrace)
|
||||
|
||||
self.start_format()
|
||||
for backend, result in self.do(method, id, backends=names):
|
||||
self.format(result)
|
||||
if len(more_results) > 0:
|
||||
print >>sys.stderr, 'Hint: There are more results available for %s (use option -n or count command)' % (', '.join(more_results))
|
||||
for backend in not_implemented:
|
||||
print >>sys.stderr, u'Error(%s): This feature is not supported yet by this backend.' % backend.name
|
||||
|
||||
def do_subscriptions(self, line):
|
||||
"""
|
||||
|
|
@ -104,6 +121,7 @@ class Boobill(ReplApplication):
|
|||
names = (backend,) if backend is not None else None
|
||||
# XXX: should be generated by backend? -Flo
|
||||
# XXX: no, but you should do it in a specific formatter -romain
|
||||
# TODO: do it, and use exec_method here. Code is obsolete
|
||||
mysum = Detail()
|
||||
mysum.label = u"Sum"
|
||||
mysum.infos = u"Generated by boobill"
|
||||
|
|
|
|||
|
|
@ -247,7 +247,6 @@ class ReplApplication(Cmd, ConsoleApplication):
|
|||
if len(self.objects) > 0:
|
||||
return self.objects
|
||||
elif method is not None:
|
||||
fields = None
|
||||
kwargs['backends'] = self.enabled_backends
|
||||
for backend, object in self.weboob.do(self._do_complete, None, None, method, *args, **kwargs):
|
||||
self.add_object(object)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue