use IFormatter.(BOLD|NC) on every formatters
This commit is contained in:
parent
5192694f24
commit
bafbf3644a
6 changed files with 26 additions and 28 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2009-2010 Romain Bignon, Christophe Benz
|
||||
# Copyright(C) 2009-2011 Romain Bignon, Christophe Benz
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -71,7 +71,7 @@ class AccountListFormatter(IFormatter):
|
|||
result += ' %s Account Balance Coming \n' % ((' ' * 15) if not self.interactive else '')
|
||||
result += '------------------------------------------%s+----------+----------\n' % (('-' * 15) if not self.interactive else '')
|
||||
result += (u' %s%-' + (u'15' if self.interactive else '30') + u's%s %-25s %8s %8s') % \
|
||||
(ReplApplication.BOLD, id, ReplApplication.NC,
|
||||
(self.BOLD, id, self.NC,
|
||||
item['label'], '%.2f' % item['balance'], '%.2f' % (item['coming'] or 0.0))
|
||||
|
||||
self.tot_balance += item['balance']
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2010 Christophe Benz
|
||||
# Copyright(C) 2010-2011 Christophe Benz
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -77,14 +77,14 @@ class MessagesListFormatter(IFormatter):
|
|||
unread = ' '
|
||||
if self.interactive:
|
||||
backend = item['id'].split('@', 1)[1]
|
||||
result = u'%s* (%d) %s %s (%s)%s' % (ReplApplication.BOLD,
|
||||
result = u'%s* (%d) %s %s (%s)%s' % (self.BOLD,
|
||||
self.count, unread,
|
||||
item['title'], backend,
|
||||
ReplApplication.NC)
|
||||
self.NC)
|
||||
else:
|
||||
result = u'%s* (%s) %s %s%s' % (ReplApplication.BOLD, item['id'],
|
||||
result = u'%s* (%s) %s %s%s' % (self.BOLD, item['id'],
|
||||
unread, item['title'],
|
||||
ReplApplication.NC)
|
||||
self.NC)
|
||||
if item['date']:
|
||||
result += u'\n %s' % item['date']
|
||||
return result
|
||||
|
|
@ -119,21 +119,21 @@ class MessagesListFormatter(IFormatter):
|
|||
|
||||
if self.interactive:
|
||||
result = u'%s%s* (%d)%s %s <%s> %s (%s)\n' % (depth * ' ',
|
||||
ReplApplication.BOLD,
|
||||
self.BOLD,
|
||||
self.count,
|
||||
ReplApplication.NC,
|
||||
self.NC,
|
||||
flags,
|
||||
message.sender,
|
||||
message.title,
|
||||
backend)
|
||||
else:
|
||||
result = u'%s%s* (%s.%s@%s)%s %s <%s> %s\n' % (depth * ' ',
|
||||
ReplApplication.BOLD,
|
||||
self.BOLD,
|
||||
message.thread.id,
|
||||
message.id,
|
||||
backend,
|
||||
flags,
|
||||
ReplApplication.NC,
|
||||
self.NC,
|
||||
message.sender,
|
||||
message.title)
|
||||
if message.children:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2010 Christophe Benz, Romain Bignon, John Obbele
|
||||
# Copyright(C) 2010-2011 Christophe Benz, Romain Bignon, John Obbele
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -41,9 +41,9 @@ class VideoListFormatter(IFormatter):
|
|||
self.count += 1
|
||||
if self.interactive:
|
||||
backend = item['id'].split('@', 1)[1]
|
||||
result = u'%s* (%d) %s (%s)%s\n' % (ReplApplication.BOLD, self.count, item['title'], backend, ReplApplication.NC)
|
||||
result = u'%s* (%d) %s (%s)%s\n' % (self.BOLD, self.count, item['title'], backend, self.NC)
|
||||
else:
|
||||
result = u'%s* (%s) %s%s\n' % (ReplApplication.BOLD, item['id'], item['title'], ReplApplication.NC)
|
||||
result = u'%s* (%s) %s%s\n' % (self.BOLD, item['id'], item['title'], self.NC)
|
||||
result += ' %s' % (item['duration'] if item['duration'] else item['date'])
|
||||
if item['author'] is not NotLoaded:
|
||||
result += ' - %s' % item['author']
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2010 Romain Bignon
|
||||
# Copyright(C) 2010-2011 Romain Bignon
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -41,16 +41,16 @@ class TorrentInfoFormatter(IFormatter):
|
|||
pass
|
||||
|
||||
def format_dict(self, item):
|
||||
result = u'%s%s%s\n' % (ReplApplication.BOLD, item['name'], ReplApplication.NC)
|
||||
result = u'%s%s%s\n' % (self.BOLD, item['name'], self.NC)
|
||||
result += 'ID: %s\n' % item['id']
|
||||
result += 'Size: %s\n' % sizeof_fmt(item['size'])
|
||||
result += 'Seeders: %s\n' % item['seeders']
|
||||
result += 'Leechers: %s\n' % item['leechers']
|
||||
result += 'URL: %s\n' % item['url']
|
||||
result += '\n%sFiles%s\n' % (ReplApplication.BOLD, ReplApplication.NC)
|
||||
result += '\n%sFiles%s\n' % (self.BOLD, self.NC)
|
||||
for f in item['files']:
|
||||
result += ' * %s\n' % f
|
||||
result += '\n%sDescription%s\n' % (ReplApplication.BOLD, ReplApplication.NC)
|
||||
result += '\n%sDescription%s\n' % (self.BOLD, self.NC)
|
||||
result += item['description']
|
||||
return result
|
||||
|
||||
|
|
@ -68,9 +68,9 @@ class TorrentListFormatter(IFormatter):
|
|||
self.count += 1
|
||||
if self.interactive:
|
||||
backend = item['id'].split('@', 1)[1]
|
||||
result = u'%s* (%d) %s (%s)%s\n' % (ReplApplication.BOLD, self.count, item['name'], backend, ReplApplication.NC)
|
||||
result = u'%s* (%d) %s (%s)%s\n' % (self.BOLD, self.count, item['name'], backend, self.NC)
|
||||
else:
|
||||
result = u'%s* (%s) %s%s\n' % (ReplApplication.BOLD, item['id'], item['name'], ReplApplication.NC)
|
||||
result = u'%s* (%s) %s%s\n' % (self.BOLD, item['id'], item['name'], self.NC)
|
||||
size = sizeof_fmt(item['size'])
|
||||
result += ' %10s (Seed: %2d / Leech: %2d)' % (size, item['seeders'], item['leechers'])
|
||||
return result
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2010 Romain Bignon
|
||||
# Copyright(C) 2010-2011 Romain Bignon
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -31,7 +31,7 @@ class ForecastsFormatter(IFormatter):
|
|||
pass
|
||||
|
||||
def format_dict(self, item):
|
||||
result = u'%s* %-15s%s (%s°%s - %s°%s)' % (ReplApplication.BOLD, '%s:' % item['date'], ReplApplication.NC, item['low'], item['unit'], item['high'], item['unit'])
|
||||
result = u'%s* %-15s%s (%s°%s - %s°%s)' % (self.BOLD, '%s:' % item['date'], self.NC, item['low'], item['unit'], item['high'], item['unit'])
|
||||
if 'text' in item and item['text']:
|
||||
result += ' %s' % item['text']
|
||||
return result
|
||||
|
|
@ -48,7 +48,7 @@ class CurrentFormatter(IFormatter):
|
|||
else:
|
||||
date = item['date']
|
||||
|
||||
result = u'%s%s%s: %s' % (ReplApplication.BOLD, date, ReplApplication.NC, item['temp'])
|
||||
result = u'%s%s%s: %s' % (self.BOLD, date, self.NC, item['temp'])
|
||||
if 'unit' in item and item['unit']:
|
||||
result += u'°%s' % item['unit']
|
||||
if 'text' in item and item['text']:
|
||||
|
|
@ -66,9 +66,9 @@ class CitiesFormatter(IFormatter):
|
|||
self.count += 1
|
||||
if self.interactive:
|
||||
backend = item['id'].split('@', 1)[1]
|
||||
result = u'%s* (%d) %s (%s)%s' % (ReplApplication.BOLD, self.count, item['name'], backend, ReplApplication.NC)
|
||||
result = u'%s* (%d) %s (%s)%s' % (self.BOLD, self.count, item['name'], backend, self.NC)
|
||||
else:
|
||||
result = u'%s* (%s) %s%s' % (ReplApplication.BOLD, item['id'], item['name'], ReplApplication.NC)
|
||||
result = u'%s* (%s) %s%s' % (self.BOLD, item['id'], item['name'], self.NC)
|
||||
return result
|
||||
|
||||
class WetBoobs(ReplApplication):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2010 Christophe Benz
|
||||
# Copyright(C) 2010-2011 Christophe Benz
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -55,7 +55,6 @@ class MandatoryFieldsNotFound(Exception):
|
|||
|
||||
|
||||
class IFormatter(object):
|
||||
|
||||
MANDATORY_FIELDS = None
|
||||
|
||||
def get_bold(self):
|
||||
|
|
@ -86,7 +85,6 @@ class IFormatter(object):
|
|||
if os.isatty(sys.stdout.fileno()) and os.isatty(sys.stdin.fileno()):
|
||||
self.termrows = int(os.popen('stty size', 'r').read().split()[0])
|
||||
|
||||
|
||||
def after_format(self, formatted):
|
||||
if self.outfile != sys.stdout:
|
||||
with open(self.outfile, "a+") as outfile:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue