Fix bug in verbose single comic list.

This commit is contained in:
Tobias Gruetzmacher 2015-05-16 14:47:54 +02:00
parent 962286d391
commit a36fef4a24

17
dosage
View file

@ -149,11 +149,16 @@ def displayHelp(options):
def displayComicHelp(scraperobj): def displayComicHelp(scraperobj):
"""Print help for a comic.""" """Print help for a comic."""
orig_context = out.context orig_context = out.context
out.context = getScraperName(scraperobj) out.context = scraperobj.getName()
try: try:
out.info(u"URL: " + scraperobj.url) out.info(u"URL: " + scraperobj.url)
if scraperobj.lang: if scraperobj.lang:
out.info(u"Language: " + pycountry.languages.get(alpha2 = scraperobj.lang).name) out.info(u"Language: " + pycountry.languages.get(alpha2 = scraperobj.lang).name)
if scraperobj.adult:
out.info(u"Adult comic, use option --adult to fetch.")
disabled = scraperobj.getDisabledReasons()
if disabled:
out.info(u"Disabled: " + " ".join(disabled.values()))
if scraperobj.help: if scraperobj.help:
for line in scraperobj.help.splitlines(): for line in scraperobj.help.splitlines():
out.info(line) out.info(line)
@ -181,7 +186,7 @@ def voteComic(scraperobj):
"""Vote for given comic scraper.""" """Vote for given comic scraper."""
errors = 0 errors = 0
orig_context = out.context orig_context = out.context
out.context = getScraperName(scraperobj) out.context = scraperobj.getName()
try: try:
name = scraperobj.getName() name = scraperobj.getName()
answer = scraperobj.vote() answer = scraperobj.vote()
@ -262,7 +267,7 @@ def doSingleList(scrapers, verbose=False):
if verbose: if verbose:
displayComicHelp(scraperobj) displayComicHelp(scraperobj)
else: else:
out.info(getScraperName(scraperobj, reasons=disabled)) out.info(getTaggedScraperName(scraperobj, reasons=disabled))
return num, disabled return num, disabled
@ -272,7 +277,7 @@ def doColumnList(scrapers):
screenWidth = get_columns(sys.stdout) screenWidth = get_columns(sys.stdout)
# limit name length so at least two columns are there # limit name length so at least two columns are there
limit = (screenWidth // 2) - 8 limit = (screenWidth // 2) - 8
names = [getScraperName(scraperobj, limit=limit, reasons=disabled) for scraperobj in scrapers] names = [getTaggedScraperName(scraperobj, limit=limit, reasons=disabled) for scraperobj in scrapers]
num = len(names) num = len(names)
maxlen = max(len(name) for name in names) maxlen = max(len(name) for name in names)
namesPerLine = max(screenWidth // (maxlen + 1), 1) namesPerLine = max(screenWidth // (maxlen + 1), 1)
@ -285,7 +290,7 @@ TAG_ADULT = "adult"
TAG_LANG = "lang" TAG_LANG = "lang"
TAG_DISABLED = "dis" TAG_DISABLED = "dis"
def getScraperName(scraperobj, limit=None, reasons=None): def getTaggedScraperName(scraperobj, limit=None, reasons=None):
"""Get comic scraper name.""" """Get comic scraper name."""
tags = [] tags = []
if scraperobj.adult: if scraperobj.adult:
@ -293,7 +298,7 @@ def getScraperName(scraperobj, limit=None, reasons=None):
if scraperobj.lang != "en": if scraperobj.lang != "en":
tags.append("%s:%s" % (TAG_LANG, scraperobj.lang)) tags.append("%s:%s" % (TAG_LANG, scraperobj.lang))
disabled = scraperobj.getDisabledReasons() disabled = scraperobj.getDisabledReasons()
if disabled: if disabled and reasons:
reasons.update(disabled) reasons.update(disabled)
for reason in disabled: for reason in disabled:
tags.append("%s:%s" % (TAG_DISABLED, reason)) tags.append("%s:%s" % (TAG_DISABLED, reason))