Fix comic list output.
This commit is contained in:
parent
cc4f94e9cf
commit
ef17268ace
2 changed files with 28 additions and 20 deletions
44
dosage
44
dosage
|
@ -174,6 +174,7 @@ def displayHelp(options):
|
||||||
|
|
||||||
def displayComicHelp(scraperobj):
|
def displayComicHelp(scraperobj):
|
||||||
"""Print description and help for a comic."""
|
"""Print description and help for a comic."""
|
||||||
|
orig_context = out.context
|
||||||
out.context = getScraperName(scraperobj)
|
out.context = getScraperName(scraperobj)
|
||||||
try:
|
try:
|
||||||
out.info(u"URL: " + scraperobj.url)
|
out.info(u"URL: " + scraperobj.url)
|
||||||
|
@ -191,7 +192,7 @@ def displayComicHelp(scraperobj):
|
||||||
out.exception(msg)
|
out.exception(msg)
|
||||||
return 1
|
return 1
|
||||||
finally:
|
finally:
|
||||||
out.context = u''
|
out.context = orig_context
|
||||||
|
|
||||||
|
|
||||||
# the comic scraper job queue
|
# the comic scraper job queue
|
||||||
|
@ -207,6 +208,7 @@ def get_hostname(url):
|
||||||
|
|
||||||
lock = threading.Lock()
|
lock = threading.Lock()
|
||||||
def get_host_lock(url):
|
def get_host_lock(url):
|
||||||
|
"""Get lock object for given URL host."""
|
||||||
hostname = get_hostname(url)
|
hostname = get_hostname(url)
|
||||||
return host_locks.setdefault(hostname, threading.Lock())
|
return host_locks.setdefault(hostname, threading.Lock())
|
||||||
|
|
||||||
|
@ -280,6 +282,7 @@ def voteComics(options):
|
||||||
def voteComic(scraperobj):
|
def voteComic(scraperobj):
|
||||||
"""Vote for given comic scraper."""
|
"""Vote for given comic scraper."""
|
||||||
errors = 0
|
errors = 0
|
||||||
|
orig_context = out.context
|
||||||
out.context = getScraperName(scraperobj)
|
out.context = getScraperName(scraperobj)
|
||||||
try:
|
try:
|
||||||
name = scraperobj.getName()
|
name = scraperobj.getName()
|
||||||
|
@ -298,7 +301,7 @@ def voteComic(scraperobj):
|
||||||
out.exception(msg)
|
out.exception(msg)
|
||||||
errors += 1
|
errors += 1
|
||||||
finally:
|
finally:
|
||||||
out.context = u''
|
out.context = orig_context
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
|
|
||||||
|
@ -356,22 +359,27 @@ 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()
|
orig_context = out.context
|
||||||
if page:
|
out.context = u''
|
||||||
fd = StringIO(u'')
|
try:
|
||||||
out.setStream(fd)
|
page = hasattr(sys.stdout, "isatty") and sys.stdout.isatty()
|
||||||
out.info(u'Available comic scrapers:')
|
if page:
|
||||||
out.info(u'Comics tagged with [%s] require age confirmation with the --adult option.' % TAG_ADULT)
|
fd = StringIO(u'')
|
||||||
out.info(u'Non-english comics are tagged with [%s].' % TAG_LANG)
|
out.setStream(fd)
|
||||||
scrapers = sorted(getScrapers(['@@']), key=lambda s: s.getName())
|
out.info(u'Available comic scrapers:')
|
||||||
if columnList:
|
out.info(u'Comics tagged with [%s] require age confirmation with the --adult option.' % TAG_ADULT)
|
||||||
num = doColumnList(scrapers)
|
out.info(u'Non-english comics are tagged with [%s].' % TAG_LANG)
|
||||||
else:
|
scrapers = sorted(getScrapers(['@@']), key=lambda s: s.getName())
|
||||||
num = doSingleList(scrapers, verbose=verbose)
|
if columnList:
|
||||||
out.info(u'%d supported comics.' % num)
|
num = doColumnList(scrapers)
|
||||||
if page:
|
else:
|
||||||
pydoc.pager(fd.getvalue())
|
num = doSingleList(scrapers, verbose=verbose)
|
||||||
return 0
|
out.info(u'%d supported comics.' % num)
|
||||||
|
if page:
|
||||||
|
pydoc.pager(fd.getvalue())
|
||||||
|
return 0
|
||||||
|
finally:
|
||||||
|
out.context = orig_context
|
||||||
|
|
||||||
|
|
||||||
def doSingleList(scrapers, verbose=False):
|
def doSingleList(scrapers, verbose=False):
|
||||||
|
|
|
@ -21,7 +21,7 @@ class Output(object):
|
||||||
|
|
||||||
def __init__(self, stream=None):
|
def __init__(self, stream=None):
|
||||||
"""Initialize context and indentation."""
|
"""Initialize context and indentation."""
|
||||||
self.context = u''
|
self.context = None
|
||||||
self.level = 0
|
self.level = 0
|
||||||
self.timestamps = False
|
self.timestamps = False
|
||||||
if stream is None:
|
if stream is None:
|
||||||
|
@ -77,7 +77,7 @@ class Output(object):
|
||||||
with lock:
|
with lock:
|
||||||
if self.context:
|
if self.context:
|
||||||
self.stream.write(u'%s%s> ' % (timestamp, self.context))
|
self.stream.write(u'%s%s> ' % (timestamp, self.context))
|
||||||
else:
|
elif self.context is None:
|
||||||
self.stream.write(u'%s%s> ' % (timestamp, get_threadname()))
|
self.stream.write(u'%s%s> ' % (timestamp, get_threadname()))
|
||||||
self.stream.write(u'%s' % s, color=color)
|
self.stream.write(u'%s' % s, color=color)
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue