Made the multimatch error messages with the multimatch_string supplied more useful, addressing the first part of #933.

This commit is contained in:
Griatch 2016-04-11 23:44:27 +02:00
parent 3c1245b1a6
commit 08f34ae61b

View file

@ -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