add a formatter for subscriptions, and do 'ls' work
This commit is contained in:
parent
6ad93c7ea9
commit
9c4b8e3a59
1 changed files with 28 additions and 1 deletions
|
|
@ -20,20 +20,47 @@
|
|||
|
||||
import sys
|
||||
|
||||
from weboob.capabilities.bill import ICapBill, Detail
|
||||
from weboob.capabilities.bill import ICapBill, Detail, Subscription
|
||||
from weboob.tools.application.repl import ReplApplication
|
||||
from weboob.tools.application.formatters.iformatter import IFormatter
|
||||
|
||||
|
||||
__all__ = ['Boobill']
|
||||
|
||||
|
||||
class SubscriptionsFormatter(IFormatter):
|
||||
MANDATORY_FIELDS = ('id', 'label')
|
||||
count = 0
|
||||
|
||||
def flush(self):
|
||||
self.count = 0
|
||||
|
||||
def format_dict(self, item):
|
||||
self.count += 1
|
||||
|
||||
if self.interactive:
|
||||
backend = item['id'].split('@', 1)[1]
|
||||
id = '#%d (%s)' % (self.count, backend)
|
||||
else:
|
||||
id = item['id']
|
||||
|
||||
return u'%s%s%s %s' % (self.BOLD, id, self.NC, item['label'])
|
||||
|
||||
|
||||
class Boobill(ReplApplication):
|
||||
APPNAME = 'boobill'
|
||||
VERSION = '0.b'
|
||||
COPYRIGHT = 'Copyright(C) 2012 Florent Fourcot'
|
||||
DESCRIPTION = 'Console application allowing to get and download bills.'
|
||||
CAPS = ICapBill
|
||||
COLLECTION_OBJECTS = (Subscription, )
|
||||
EXTRA_FORMATTERS = {'subscriptions': SubscriptionsFormatter,
|
||||
}
|
||||
DEFAULT_FORMATTER = 'table'
|
||||
COMMANDS_FORMATTERS = {'subscriptions': 'subscriptions',
|
||||
'ls': 'subscriptions',
|
||||
}
|
||||
|
||||
|
||||
def main(self, argv):
|
||||
self.load_config()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue