store listed accounts and completion on 'coming', 'history' and 'transfer' commands
This commit is contained in:
parent
5c53bb52b5
commit
7efc743694
1 changed files with 26 additions and 0 deletions
|
|
@ -33,6 +33,8 @@ class Boobank(ReplApplication):
|
||||||
COPYRIGHT = 'Copyright(C) 2010 Romain Bignon, Christophe Benz'
|
COPYRIGHT = 'Copyright(C) 2010 Romain Bignon, Christophe Benz'
|
||||||
CAPS = ICapBank
|
CAPS = ICapBank
|
||||||
|
|
||||||
|
accounts = []
|
||||||
|
|
||||||
def do_list(self, line):
|
def do_list(self, line):
|
||||||
"""
|
"""
|
||||||
list
|
list
|
||||||
|
|
@ -41,11 +43,13 @@ class Boobank(ReplApplication):
|
||||||
"""
|
"""
|
||||||
tot_balance = 0.0
|
tot_balance = 0.0
|
||||||
tot_coming = 0.0
|
tot_coming = 0.0
|
||||||
|
self.accounts = []
|
||||||
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_balance += account.balance
|
||||||
tot_coming += account.coming
|
tot_coming += account.coming
|
||||||
|
self.accounts.append(account)
|
||||||
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):
|
||||||
|
|
@ -57,6 +61,16 @@ class Boobank(ReplApplication):
|
||||||
('balance', tot_balance),
|
('balance', tot_balance),
|
||||||
('coming', tot_coming)))
|
('coming', tot_coming)))
|
||||||
|
|
||||||
|
def _complete_account(self, exclude=None):
|
||||||
|
if exclude:
|
||||||
|
id, backend = self.parse_id(exclude)
|
||||||
|
return ['%s@%s' % (acc.id, acc.backend) for acc in self.accounts if not exclude or (acc.id != id and acc.backend == backend)]
|
||||||
|
|
||||||
|
def complete_history(self, text, line, *ignored):
|
||||||
|
args = line.split(' ')
|
||||||
|
if len(args) == 2:
|
||||||
|
return self._complete_account()
|
||||||
|
|
||||||
def do_history(self, id):
|
def do_history(self, id):
|
||||||
"""
|
"""
|
||||||
history ID
|
history ID
|
||||||
|
|
@ -74,6 +88,11 @@ class Boobank(ReplApplication):
|
||||||
for backend, operation in self.do(do):
|
for backend, operation in self.do(do):
|
||||||
self.format(operation)
|
self.format(operation)
|
||||||
|
|
||||||
|
def complete_coming(self, text, line, *ignored):
|
||||||
|
args = line.split(' ')
|
||||||
|
if len(args) == 2:
|
||||||
|
return self._complete_account()
|
||||||
|
|
||||||
def do_coming(self, id):
|
def do_coming(self, id):
|
||||||
"""
|
"""
|
||||||
coming ID
|
coming ID
|
||||||
|
|
@ -91,6 +110,13 @@ class Boobank(ReplApplication):
|
||||||
for backend, operation in self.do(do):
|
for backend, operation in self.do(do):
|
||||||
self.format(operation)
|
self.format(operation)
|
||||||
|
|
||||||
|
def complete_transfer(self, text, line, *ignored):
|
||||||
|
args = line.split(' ')
|
||||||
|
if len(args) == 2:
|
||||||
|
return self._complete_account()
|
||||||
|
if len(args) == 3:
|
||||||
|
return self._complete_account(args[1])
|
||||||
|
|
||||||
def do_transfer(self, line):
|
def do_transfer(self, line):
|
||||||
"""
|
"""
|
||||||
transfer FROM TO AMOUNT
|
transfer FROM TO AMOUNT
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue