From 69d7d970c1145782c3c0f8b6d9c0bcc6453844b2 Mon Sep 17 00:00:00 2001 From: Christophe Benz Date: Mon, 12 Apr 2010 16:27:10 +0200 Subject: [PATCH] print header only if needed --- scripts/boobank | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/boobank b/scripts/boobank index 38493a7a26..4ba8fd9289 100755 --- a/scripts/boobank +++ b/scripts/boobank @@ -38,17 +38,21 @@ class Boobank(ConsoleApplication): @ConsoleApplication.command('List every available accounts') def command_list(self): - lines = [' ID Account Balance Coming ', - '+-----------------+---------------------+--------------+-------------+'] + accounts = [] for name, backend, in self.weboob.iter_backends(): try: for account in backend.iter_accounts(): - lines.append('%17s %-20s %11.2f %11.2f' % ( + accounts.append('%17s %-20s %11.2f %11.2f' % ( account.id, account.label, account.balance, account.coming)) except weboob.tools.browser.BrowserIncorrectPassword: print >>sys.stderr, 'Error: Incorrect password for backend %s' % name return 1 - print '\n'.join(lines) + if len(accounts): + print ' ID Account Balance Coming ' + print '+-----------------+---------------------+--------------+-------------+' + print '\n'.join(accounts) + else: + print 'No accounts found' @ConsoleApplication.command('Display all future operations') def command_coming(self, id): -- GitLab