Made the multimatch error messages with the multimatch_string supplied more useful, addressing the first part of #933.
This commit is contained in:
parent
3c1245b1a6
commit
08f34ae61b
1 changed files with 9 additions and 11 deletions
|
|
@ -301,7 +301,7 @@ def time_format(seconds, style=0):
|
||||||
"""
|
"""
|
||||||
days_str = hours_str = ''
|
days_str = hours_str = ''
|
||||||
minutes_str = '0 minutes'
|
minutes_str = '0 minutes'
|
||||||
|
|
||||||
if days > 0:
|
if days > 0:
|
||||||
if days == 1:
|
if days == 1:
|
||||||
days_str = '%i day, ' % days
|
days_str = '%i day, ' % days
|
||||||
|
|
@ -1231,7 +1231,7 @@ def string_suggestions(string, vocabulary, cutoff=0.6, maxnum=3):
|
||||||
maxnum (int): Maximum number of suggestions to return.
|
maxnum (int): Maximum number of suggestions to return.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
suggestions (list): Suggestions from `vocabulary` with a
|
suggestions (list): Suggestions from `vocabulary` with a
|
||||||
similarity-rating that higher than or equal to `cutoff`.
|
similarity-rating that higher than or equal to `cutoff`.
|
||||||
Could be empty if there are no matches.
|
Could be empty if there are no matches.
|
||||||
|
|
||||||
|
|
@ -1549,15 +1549,13 @@ def at_search_result(matches, caller, query="", quiet=False, **kwargs):
|
||||||
error = kwargs.get("nofound_string") or _("Could not find '%s'." % query)
|
error = kwargs.get("nofound_string") or _("Could not find '%s'." % query)
|
||||||
matches = None
|
matches = None
|
||||||
elif len(matches) > 1:
|
elif len(matches) > 1:
|
||||||
error = kwargs.get("multimatch_string", None)
|
error = kwargs.get("multimatch_string",
|
||||||
if not error:
|
_("More than one match for '%s' (please narrow target):" % query))
|
||||||
error = _("More than one match for '%s'" \
|
for num, result in enumerate(matches):
|
||||||
" (please narrow target):" % query)
|
error += "\n %i%s%s%s" % (
|
||||||
for num, result in enumerate(matches):
|
num + 1, _MULTIMATCH_SEPARATOR,
|
||||||
error += "\n %i%s%s%s" % (
|
result.get_display_name(caller) if hasattr(result, "get_display_name") else result.key,
|
||||||
num + 1, _MULTIMATCH_SEPARATOR,
|
result.get_extra_info(caller))
|
||||||
result.get_display_name(caller) if hasattr(result, "get_display_name") else result.key,
|
|
||||||
result.get_extra_info(caller))
|
|
||||||
matches = None
|
matches = None
|
||||||
else:
|
else:
|
||||||
# exactly one match
|
# exactly one match
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue