Page comic listings.
This commit is contained in:
parent
5ccf44c36a
commit
8b0a523f77
3 changed files with 21 additions and 4 deletions
|
@ -3,7 +3,10 @@ Dosage 1.13 (released xx.xx.2013)
|
||||||
Features:
|
Features:
|
||||||
- comics: Added comic strips AhoiPolloi, AxeCop, Bearmageddon, DeadWinter,
|
- comics: Added comic strips AhoiPolloi, AxeCop, Bearmageddon, DeadWinter,
|
||||||
HarkAVagrant, IAmArg, LoadingArtist, Nnewts, PHDComics, PokeyThePenguin,
|
HarkAVagrant, IAmArg, LoadingArtist, Nnewts, PHDComics, PokeyThePenguin,
|
||||||
SnowFlame and WorldOfMrToast, Zwarwald.
|
SnowFlame, WorldOfMrToast and Zwarwald.
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
- cmdline: Comic lists are now displayed one page at a time.
|
||||||
|
|
||||||
Fixes:
|
Fixes:
|
||||||
- cmdline: Catch error when piping output to another
|
- cmdline: Catch error when piping output to another
|
||||||
|
|
13
dosage
13
dosage
|
@ -15,6 +15,7 @@ import os
|
||||||
import argparse
|
import argparse
|
||||||
import pydoc
|
import pydoc
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
from cStringIO import StringIO
|
||||||
|
|
||||||
from dosagelib import events, scraper
|
from dosagelib import events, scraper
|
||||||
from dosagelib.output import out
|
from dosagelib.output import out
|
||||||
|
@ -206,6 +207,12 @@ def run(options):
|
||||||
|
|
||||||
def doList(columnList=True, verbose=False):
|
def doList(columnList=True, verbose=False):
|
||||||
"""List available comics."""
|
"""List available comics."""
|
||||||
|
page = hasattr(sys.stdout, "isatty") and sys.stdout.isatty()
|
||||||
|
if page:
|
||||||
|
fd = StringIO()
|
||||||
|
else:
|
||||||
|
fd = sys.stdout
|
||||||
|
out.setStream(fd)
|
||||||
out.info('Available comic scrapers:')
|
out.info('Available comic scrapers:')
|
||||||
out.info('Comics marked with [A] require age confirmation with the --adult option.')
|
out.info('Comics marked with [A] require age confirmation with the --adult option.')
|
||||||
scrapers = sorted(getScrapers(['@@']), key=lambda s: s.getName())
|
scrapers = sorted(getScrapers(['@@']), key=lambda s: s.getName())
|
||||||
|
@ -214,6 +221,8 @@ def doList(columnList=True, verbose=False):
|
||||||
else:
|
else:
|
||||||
num = doSingleList(scrapers, verbose=verbose)
|
num = doSingleList(scrapers, verbose=verbose)
|
||||||
out.info('%d supported comics.' % num)
|
out.info('%d supported comics.' % num)
|
||||||
|
if page:
|
||||||
|
pydoc.pager(fd.getvalue())
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
@ -223,7 +232,7 @@ def doSingleList(scrapers, verbose=False):
|
||||||
if verbose:
|
if verbose:
|
||||||
displayComicHelp(scraperobj)
|
displayComicHelp(scraperobj)
|
||||||
else:
|
else:
|
||||||
print(getScraperName(scraperobj))
|
out.info(getScraperName(scraperobj))
|
||||||
return num
|
return num
|
||||||
|
|
||||||
|
|
||||||
|
@ -237,7 +246,7 @@ def doColumnList(scrapers):
|
||||||
maxlen = max(len(name) for name in names)
|
maxlen = max(len(name) for name in names)
|
||||||
namesPerLine = max(int(screenWidth / (maxlen + 1)), 1)
|
namesPerLine = max(int(screenWidth / (maxlen + 1)), 1)
|
||||||
while names:
|
while names:
|
||||||
print(''.join(name.ljust(maxlen) for name in names[:namesPerLine]))
|
out.info(''.join(name.ljust(maxlen) for name in names[:namesPerLine]))
|
||||||
del names[:namesPerLine]
|
del names[:namesPerLine]
|
||||||
return num
|
return num
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,10 @@ class Output(object):
|
||||||
self.context = ''
|
self.context = ''
|
||||||
self.level = 0
|
self.level = 0
|
||||||
self.timestamps = False
|
self.timestamps = False
|
||||||
|
self.setStream(stream)
|
||||||
|
|
||||||
|
def setStream(self, stream):
|
||||||
|
"""Initialize context and indentation."""
|
||||||
self.stream = Colorizer(stream)
|
self.stream = Colorizer(stream)
|
||||||
|
|
||||||
def info(self, s, level=0):
|
def info(self, s, level=0):
|
||||||
|
@ -44,7 +48,8 @@ class Output(object):
|
||||||
else:
|
else:
|
||||||
timestamp = ''
|
timestamp = ''
|
||||||
with lock:
|
with lock:
|
||||||
self.stream.write('%s%s> ' % (timestamp, self.context))
|
if self.context or timestamp:
|
||||||
|
self.stream.write('%s%s> ' % (timestamp, self.context))
|
||||||
self.stream.write('%s' % s, color=color)
|
self.stream.write('%s' % s, color=color)
|
||||||
self.stream.write(os.linesep)
|
self.stream.write(os.linesep)
|
||||||
self.stream.flush()
|
self.stream.flush()
|
||||||
|
|
Loading…
Reference in a new issue