implement mandatory fields for custom formatters
This commit is contained in:
parent
bebd4318ec
commit
560798bf7d
6 changed files with 37 additions and 1 deletions
|
|
@ -26,13 +26,17 @@ from weboob.tools.application.formatters.iformatter import IFormatter
|
|||
|
||||
__all__ = ['Weboorrents']
|
||||
|
||||
|
||||
def sizeof_fmt(num):
|
||||
for x in ['bytes','KB','MB','GB','TB']:
|
||||
if num < 1024.0:
|
||||
return "%-4.1f%s" % (num, x)
|
||||
num /= 1024.0
|
||||
|
||||
|
||||
class TorrentInfoFormatter(IFormatter):
|
||||
MANDATORY_FIELDS = ('id', 'name', 'size', 'seeders', 'leechers', 'url', 'files', 'description')
|
||||
|
||||
def flush(self):
|
||||
pass
|
||||
|
||||
|
|
@ -50,7 +54,10 @@ class TorrentInfoFormatter(IFormatter):
|
|||
result += item['description']
|
||||
return result
|
||||
|
||||
|
||||
class TorrentListFormatter(IFormatter):
|
||||
MANDATORY_FIELDS = ('id', 'name', 'size', 'seeders', 'leechers')
|
||||
|
||||
count = 0
|
||||
|
||||
def flush(self):
|
||||
|
|
@ -68,6 +75,7 @@ class TorrentListFormatter(IFormatter):
|
|||
result += ' %10s (Seed: %2d / Leech: %2d)' % (size, item['seeders'], item['leechers'])
|
||||
return result
|
||||
|
||||
|
||||
class Weboorrents(ReplApplication):
|
||||
APPNAME = 'weboorrents'
|
||||
VERSION = '0.4'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue