improve message for 'oauth:deviantart' etc (closes #989)

This commit is contained in:
Mike Fährmann
2020-09-29 21:25:24 +02:00
parent 430b6d6e2e
commit bdc6c8f074

View File

@@ -180,16 +180,11 @@ class OAuthBase(Extractor):
self.send(msg) self.send(msg)
def _generate_message(self, names, values): def _generate_message(self, names, values):
if len(names) == 1: _vh, _va, _is, _it = (
_vh = "This value has" ("This value has", "this value", "is", "it")
_is = "is" if len(names) == 1 else
_it = "it" ("These values have", "these values", "are", "them")
_va = "this value" )
else:
_vh = "These values have"
_is = "are"
_it = "them"
_va = "these values"
msg = "\nYour {} {}\n\n{}\n\n".format( msg = "\nYour {} {}\n\n{}\n\n".format(
" and ".join("'" + n + "'" for n in names), " and ".join("'" + n + "'" for n in names),
@@ -197,23 +192,21 @@ class OAuthBase(Extractor):
"\n".join(values), "\n".join(values),
) )
if self.cache: opt = self.oauth_config(names[0])
opt = self.oauth_config(names[0]) if self.cache and (opt is None or opt == "cache"):
if opt is None or opt == "cache": msg += _vh + " been cached and will automatically be used."
msg += _vh + " been cached and will automatically be used."
else:
msg += (
"Set 'extractor.{}.{}' to \"cache\" to use {}.".format(
self.subcategory, names[0], _it,
)
)
else: else:
msg += "Put " + _va + " into your configuration file as \n" msg += "Put " + _va + " into your configuration file as \n"
msg += " and\n".join( msg += " and\n".join(
"'extractor." + self.subcategory + "." + n + "'" "'extractor." + self.subcategory + "." + n + "'"
for n in names for n in names
) )
msg += "." if self.cache:
msg += (
"\nor set\n'extractor.{}.{}' to \"cache\""
.format(self.subcategory, names[0])
)
msg += "\nto use {}.".format(_it)
return msg return msg