in a tty, ask user to press <Enter> when text exceed the term height
This commit is contained in:
parent
e1f21bca03
commit
d2c70b7e98
6 changed files with 24 additions and 40 deletions
|
|
@ -29,9 +29,6 @@ __all__ = ['Radioob']
|
||||||
class RadioListFormatter(IFormatter):
|
class RadioListFormatter(IFormatter):
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
def after_format(self, formatted):
|
|
||||||
print formatted.encode('utf-8')
|
|
||||||
|
|
||||||
def flush(self):
|
def flush(self):
|
||||||
self.count = 0
|
self.count = 0
|
||||||
pass
|
pass
|
||||||
|
|
@ -48,10 +45,6 @@ class RadioListFormatter(IFormatter):
|
||||||
result += ' (Current: %s - %s)' % (item['current'].artist, item['current'].title)
|
result += ' (Current: %s - %s)' % (item['current'].artist, item['current'].title)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def set_header(self, string):
|
|
||||||
if self.display_header:
|
|
||||||
print string.encode('utf-8')
|
|
||||||
|
|
||||||
class Radioob(ReplApplication):
|
class Radioob(ReplApplication):
|
||||||
APPNAME = 'radioob'
|
APPNAME = 'radioob'
|
||||||
VERSION = '0.3'
|
VERSION = '0.3'
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,6 @@ __all__ = ['Videoob']
|
||||||
class VideoListFormatter(IFormatter):
|
class VideoListFormatter(IFormatter):
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
def after_format(self, formatted):
|
|
||||||
print formatted.encode('utf-8')
|
|
||||||
|
|
||||||
def flush(self):
|
def flush(self):
|
||||||
self.count = 0
|
self.count = 0
|
||||||
pass
|
pass
|
||||||
|
|
@ -50,10 +47,6 @@ class VideoListFormatter(IFormatter):
|
||||||
result += u' (%s/%s)' % (item['rating'], item['rating_max'])
|
result += u' (%s/%s)' % (item['rating'], item['rating_max'])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def set_header(self, string):
|
|
||||||
if self.display_header:
|
|
||||||
print string.encode('utf-8')
|
|
||||||
|
|
||||||
class Videoob(ReplApplication):
|
class Videoob(ReplApplication):
|
||||||
APPNAME = 'videoob'
|
APPNAME = 'videoob'
|
||||||
VERSION = '0.3'
|
VERSION = '0.3'
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,6 @@ def sizeof_fmt(num):
|
||||||
num /= 1024.0
|
num /= 1024.0
|
||||||
|
|
||||||
class TorrentInfoFormatter(IFormatter):
|
class TorrentInfoFormatter(IFormatter):
|
||||||
def after_format(self, formatted):
|
|
||||||
print formatted.encode('utf-8')
|
|
||||||
|
|
||||||
def flush(self):
|
def flush(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
@ -53,16 +50,9 @@ class TorrentInfoFormatter(IFormatter):
|
||||||
result += item['description']
|
result += item['description']
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def set_header(self, string):
|
|
||||||
if self.display_header:
|
|
||||||
print string.encode('utf-8')
|
|
||||||
|
|
||||||
class TorrentListFormatter(IFormatter):
|
class TorrentListFormatter(IFormatter):
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
def after_format(self, formatted):
|
|
||||||
print formatted.encode('utf-8')
|
|
||||||
|
|
||||||
def flush(self):
|
def flush(self):
|
||||||
self.count = 0
|
self.count = 0
|
||||||
pass
|
pass
|
||||||
|
|
@ -78,10 +68,6 @@ class TorrentListFormatter(IFormatter):
|
||||||
result += ' %10s (Seed: %2d / Leech: %2d)' % (size, item['seeders'], item['leechers'])
|
result += ' %10s (Seed: %2d / Leech: %2d)' % (size, item['seeders'], item['leechers'])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def set_header(self, string):
|
|
||||||
if self.display_header:
|
|
||||||
print string.encode('utf-8')
|
|
||||||
|
|
||||||
class Weboorrents(ReplApplication):
|
class Weboorrents(ReplApplication):
|
||||||
APPNAME = 'weboorrents'
|
APPNAME = 'weboorrents'
|
||||||
VERSION = '0.3'
|
VERSION = '0.3'
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
from weboob.capabilities.base import CapBaseObject, FieldNotFound
|
from weboob.capabilities.base import CapBaseObject, FieldNotFound
|
||||||
from weboob.tools.ordereddict import OrderedDict
|
from weboob.tools.ordereddict import OrderedDict
|
||||||
|
|
||||||
|
|
@ -29,9 +32,27 @@ class IFormatter(object):
|
||||||
self.display_header = display_header
|
self.display_header = display_header
|
||||||
self.return_only = return_only
|
self.return_only = return_only
|
||||||
self.interactive = False
|
self.interactive = False
|
||||||
|
self.print_lines = 0
|
||||||
|
self.termrows = 0
|
||||||
|
self.termcols = 0
|
||||||
|
if os.isatty(sys.stdout.fileno()):
|
||||||
|
size = os.popen('stty size', 'r').read().split()
|
||||||
|
self.termrows = int(size[0])
|
||||||
|
self.termcols = int(size[1])
|
||||||
|
|
||||||
def after_format(self, formatted):
|
def after_format(self, formatted):
|
||||||
raise NotImplementedError()
|
for line in formatted.split('\n'):
|
||||||
|
if self.termrows and (self.print_lines + 1) >= self.termrows:
|
||||||
|
prompt = '--Press return to continue--'
|
||||||
|
sys.stdout.write(prompt)
|
||||||
|
sys.stdout.flush()
|
||||||
|
r = sys.stdin.readline()
|
||||||
|
self.print_lines = 0
|
||||||
|
|
||||||
|
if isinstance(line, unicode):
|
||||||
|
line = line.encode('utf-8')
|
||||||
|
print line
|
||||||
|
self.print_lines += 1
|
||||||
|
|
||||||
def build_id(self, v, backend_name):
|
def build_id(self, v, backend_name):
|
||||||
return u'%s@%s' % (unicode(v), backend_name)
|
return u'%s@%s' % (unicode(v), backend_name)
|
||||||
|
|
@ -80,7 +101,8 @@ class IFormatter(object):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def set_header(self, string):
|
def set_header(self, string):
|
||||||
raise NotImplementedError()
|
if self.display_header:
|
||||||
|
print string.encode('utf-8')
|
||||||
|
|
||||||
def to_dict(self, obj, condition=None, selected_fields=None):
|
def to_dict(self, obj, condition=None, selected_fields=None):
|
||||||
def iter_select_and_decorate(d):
|
def iter_select_and_decorate(d):
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,6 @@ class MultilineFormatter(IFormatter):
|
||||||
self.key_value_separator = key_value_separator
|
self.key_value_separator = key_value_separator
|
||||||
self.after_item = after_item
|
self.after_item = after_item
|
||||||
|
|
||||||
def after_format(self, formatted):
|
|
||||||
print formatted.encode('utf-8')
|
|
||||||
|
|
||||||
def flush(self):
|
def flush(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,6 @@ class SimpleFormatter(IFormatter):
|
||||||
self.field_separator = field_separator
|
self.field_separator = field_separator
|
||||||
self.key_value_separator = key_value_separator
|
self.key_value_separator = key_value_separator
|
||||||
|
|
||||||
def after_format(self, formatted):
|
|
||||||
print formatted.encode('utf-8')
|
|
||||||
|
|
||||||
def flush(self):
|
def flush(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
@ -38,7 +35,3 @@ class SimpleFormatter(IFormatter):
|
||||||
return self.field_separator.join(u'%s%s' % (
|
return self.field_separator.join(u'%s%s' % (
|
||||||
(u'%s%s' % (k, self.key_value_separator) if self.display_keys else ''), v)
|
(u'%s%s' % (k, self.key_value_separator) if self.display_keys else ''), v)
|
||||||
for k, v in item.iteritems())
|
for k, v in item.iteritems())
|
||||||
|
|
||||||
def set_header(self, string):
|
|
||||||
if self.display_header:
|
|
||||||
print string.encode('utf-8')
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue