display a 'Total' line on command 'list'
This commit is contained in:
parent
af08bd0eeb
commit
3bf7975ad1
2 changed files with 12 additions and 1 deletions
|
|
@ -40,15 +40,24 @@ class Boobank(ConsoleApplication):
|
||||||
@ConsoleApplication.command('List every available accounts')
|
@ConsoleApplication.command('List every available accounts')
|
||||||
def command_list(self):
|
def command_list(self):
|
||||||
self.load_configured_backends(ICapBank)
|
self.load_configured_backends(ICapBank)
|
||||||
|
tot_balance = 0.0
|
||||||
|
tot_coming = 0.0
|
||||||
try:
|
try:
|
||||||
for backend, account in self.do('iter_accounts'):
|
for backend, account in self.do('iter_accounts'):
|
||||||
self.format(account)
|
self.format(account)
|
||||||
|
tot_balance += account.balance
|
||||||
|
tot_coming += account.coming
|
||||||
except weboob.core.CallErrors, errors:
|
except weboob.core.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):
|
||||||
logging.error(u'Error: Incorrect password for backend %s' % backend.name)
|
logging.error(u'Error: Incorrect password for backend %s' % backend.name)
|
||||||
else:
|
else:
|
||||||
logging.error(u'Error[%s]: %s\n%s' % (backend.name, error, backtrace))
|
logging.error(u'Error[%s]: %s\n%s' % (backend.name, error, backtrace))
|
||||||
|
else:
|
||||||
|
self.format((('id', ''),
|
||||||
|
('label', 'Total'),
|
||||||
|
('balance', tot_balance),
|
||||||
|
('coming', tot_coming)))
|
||||||
|
|
||||||
@ConsoleApplication.command('Display old operations')
|
@ConsoleApplication.command('Display old operations')
|
||||||
def command_history(self, id):
|
def command_history(self, id):
|
||||||
|
|
|
||||||
|
|
@ -57,10 +57,12 @@ class IFormatter(object):
|
||||||
@param condition [Condition] condition to objects to display
|
@param condition [Condition] condition to objects to display
|
||||||
@return a string of the formatted object
|
@return a string of the formatted object
|
||||||
"""
|
"""
|
||||||
assert isinstance(obj, (dict, CapBaseObject))
|
assert isinstance(obj, (dict, CapBaseObject, tuple))
|
||||||
|
|
||||||
if isinstance(obj, dict):
|
if isinstance(obj, dict):
|
||||||
item = obj
|
item = obj
|
||||||
|
elif isinstance(obj, tuple):
|
||||||
|
item = OrderedDict([(k, v) for k, v in obj])
|
||||||
else:
|
else:
|
||||||
item = self.to_dict(obj, condition, selected_fields)
|
item = self.to_dict(obj, condition, selected_fields)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue