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:
|
||||
- comics: Added comic strips AhoiPolloi, AxeCop, Bearmageddon, DeadWinter,
|
||||
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:
|
||||
- cmdline: Catch error when piping output to another
|
||||
|
|
13
dosage
13
dosage
|
@ -15,6 +15,7 @@ import os
|
|||
import argparse
|
||||
import pydoc
|
||||
from collections import OrderedDict
|
||||
from cStringIO import StringIO
|
||||
|
||||
from dosagelib import events, scraper
|
||||
from dosagelib.output import out
|
||||
|
@ -206,6 +207,12 @@ def run(options):
|
|||
|
||||
def doList(columnList=True, verbose=False):
|
||||
"""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('Comics marked with [A] require age confirmation with the --adult option.')
|
||||
scrapers = sorted(getScrapers(['@@']), key=lambda s: s.getName())
|
||||
|
@ -214,6 +221,8 @@ def doList(columnList=True, verbose=False):
|
|||
else:
|
||||
num = doSingleList(scrapers, verbose=verbose)
|
||||
out.info('%d supported comics.' % num)
|
||||
if page:
|
||||
pydoc.pager(fd.getvalue())
|
||||
return 0
|
||||
|
||||
|
||||
|
@ -223,7 +232,7 @@ def doSingleList(scrapers, verbose=False):
|
|||
if verbose:
|
||||
displayComicHelp(scraperobj)
|
||||
else:
|
||||
print(getScraperName(scraperobj))
|
||||
out.info(getScraperName(scraperobj))
|
||||
return num
|
||||
|
||||
|
||||
|
@ -237,7 +246,7 @@ def doColumnList(scrapers):
|
|||
maxlen = max(len(name) for name in names)
|
||||
namesPerLine = max(int(screenWidth / (maxlen + 1)), 1)
|
||||
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]
|
||||
return num
|
||||
|
||||
|
|
|
@ -17,6 +17,10 @@ class Output(object):
|
|||
self.context = ''
|
||||
self.level = 0
|
||||
self.timestamps = False
|
||||
self.setStream(stream)
|
||||
|
||||
def setStream(self, stream):
|
||||
"""Initialize context and indentation."""
|
||||
self.stream = Colorizer(stream)
|
||||
|
||||
def info(self, s, level=0):
|
||||
|
@ -44,7 +48,8 @@ class Output(object):
|
|||
else:
|
||||
timestamp = ''
|
||||
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(os.linesep)
|
||||
self.stream.flush()
|
||||
|
|
Loading…
Reference in a new issue