colorize 'seeders' and 'leechers'
This commit is contained in:
parent
dec819fb8c
commit
663278e7b0
1 changed files with 20 additions and 5 deletions
|
|
@ -66,12 +66,27 @@ class TorrentListFormatter(PrettyFormatter):
|
||||||
def get_title(self, obj):
|
def get_title(self, obj):
|
||||||
return obj.name
|
return obj.name
|
||||||
|
|
||||||
|
NB2COLOR = ((0, 'red', None),
|
||||||
|
(1, 'blue', None),
|
||||||
|
(5, 'green', None),
|
||||||
|
(10, 'green', 'bold'),
|
||||||
|
)
|
||||||
|
def _get_color(self, nb):
|
||||||
|
if empty(nb):
|
||||||
|
return self.colored('N/A', 'red')
|
||||||
|
|
||||||
|
for threshold, _color, _attr in self.NB2COLOR:
|
||||||
|
if nb >= threshold:
|
||||||
|
color = _color
|
||||||
|
attr = _attr
|
||||||
|
|
||||||
|
return self.colored('%3d' % nb, color, attr)
|
||||||
|
|
||||||
def get_description(self, obj):
|
def get_description(self, obj):
|
||||||
size = sizeof_fmt(obj.size)
|
size = self.colored('%10s' % sizeof_fmt(obj.size), 'magenta')
|
||||||
if not empty(obj.seeders) and not empty(obj.leechers):
|
return '%s (Seed: %s / Leech: %s)' % (size,
|
||||||
return '%10s (Seed: %2d / Leech: %2d)' % (size, obj.seeders, obj.leechers)
|
self._get_color(obj.seeders),
|
||||||
else:
|
self._get_color(obj.leechers))
|
||||||
return '%10s (Seed and Leech not available)' % size
|
|
||||||
|
|
||||||
|
|
||||||
class Weboorrents(ReplApplication):
|
class Weboorrents(ReplApplication):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue