better error messages with list

This commit is contained in:
Emmanuel Garette 2019-04-13 22:04:49 +02:00
parent 1aec891408
commit 63094f7e54
9 changed files with 45 additions and 48 deletions

View File

@ -99,12 +99,12 @@ def test_consistency_error_prefix():
try:
api.option('b').value.set(1)
except Exception as err:
assert str(err) == _('"{0}" is an invalid {1} for "{2}"').format('1', _('integer'), 'b') + ', ' + _('must be different from the value of "{}"').format('a')
assert str(err) == _('"{0}" is an invalid {1} for "{2}"').format('1', _('integer'), 'b') + ', ' + _('must be different from the value of {}').format('"a"')
try:
api.option('b').value.set(1)
except Exception as err:
err.prefix = ''
assert str(err) == _('must be different from the value of "{}"').format('a')
assert str(err) == _('must be different from the value of {}').format('"a"')
def test_consistency_warnings_only_option():

View File

@ -621,9 +621,9 @@ def test_pprint():
except PropertiesOptionError as error:
err = error
list_disabled = '"disabled" (' + display_list([msg_is.format('Test int option', '"1"'), msg_is.format('string2', '"string"')]) + ')'
list_disabled = '"disabled" (' + display_list([msg_is.format('Test int option', '"1"'), msg_is.format('string2', '"string"')], add_quote=False) + ')'
list_hidden = '"hidden" (' + msg_is_not.format('Test int option', display_list([2, 3, 4], 'or', add_quote=True)) + ')'
assert str(err) == _(msg_error.format('option', 'Test string option', properties, display_list([list_disabled, list_hidden])))
assert str(err) == _(msg_error.format('option', 'Test string option', properties, display_list([list_disabled, list_hidden], add_quote=False)))
del err
err = None

View File

@ -45,4 +45,4 @@ allfuncs.extend(all_options)
del(all_options)
__all__ = tuple(allfuncs)
del(allfuncs)
__version__ = "3.0rc5"
__version__ = "3.0rc6"

View File

@ -94,8 +94,8 @@ class PropertiesOptionError(AttributeError):
only_one = len(req) == 1
msg = []
for action, msg_ in req.items():
msg.append('"{0}" ({1})'.format(action, display_list(msg_)))
msg = display_list(msg)
msg.append('"{0}" ({1})'.format(action, display_list(msg_, add_quote=False)))
msg = display_list(msg, add_quote=False)
else:
only_one = len(self.proptype) == 1
msg = display_list(list(self.proptype), add_quote=True)

View File

@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Tiramisu\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-04-08 08:41+CEST\n"
"POT-Creation-Date: 2019-04-13 21:34+CEST\n"
"PO-Revision-Date: \n"
"Last-Translator: Emmanuel Garette <egarette@cadoles.com>\n"
"Language-Team: Tiramisu's team <egarette@cadoles.com>\n"
@ -247,49 +247,46 @@ msgstr ""
"toutes les configs d'une metaconfig doivent avoir la même optiondescription"
#: tiramisu/config.py:1272
#, fuzzy
#| msgid "all config in metaconfig must have the same optiondescription"
msgid "metaconfig must have the same optiondescription"
msgstr ""
"toutes les configs d'une metaconfig doivent avoir la même optiondescription"
msgstr "metaconfig doivent avoir la même optiondescription"
#: tiramisu/error.py:24
#: tiramisu/error.py:26
msgid "and"
msgstr "et"
#: tiramisu/error.py:26
#: tiramisu/error.py:28
msgid "or"
msgstr "ou"
#: tiramisu/error.py:50
#: tiramisu/error.py:52
msgid " {} "
msgstr " {} "
#: tiramisu/error.py:103 tiramisu/setting.py:579
#: tiramisu/error.py:105 tiramisu/setting.py:579
msgid "property"
msgstr "de la propriété"
#: tiramisu/error.py:105 tiramisu/setting.py:581
#: tiramisu/error.py:107 tiramisu/setting.py:581
msgid "properties"
msgstr "des propriétés"
#: tiramisu/error.py:107
#: tiramisu/error.py:109
msgid "cannot access to {0} \"{1}\" because \"{2}\" has {3} {4}"
msgstr "ne peut accéder à {0} \"{1}\" parce que \"{2}\" a {3} {4}"
#: tiramisu/error.py:114
#: tiramisu/error.py:116
msgid "cannot access to {0} \"{1}\" because has {2} {3}"
msgstr "ne peut accéder à l'{0} \"{1}\" a cause {2} {3}"
#: tiramisu/error.py:189
#: tiramisu/error.py:191
msgid "invalid value"
msgstr "valeur invalide"
#: tiramisu/error.py:194
#: tiramisu/error.py:196
msgid "attention, \"{0}\" could be an invalid {1} for \"{2}\""
msgstr "attention, \"{0}\" peut être un {1} invalide pour \"{2}\""
#: tiramisu/error.py:198 tiramisu/error.py:202
#: tiramisu/error.py:200 tiramisu/error.py:204
msgid "\"{0}\" is an invalid {1} for \"{2}\""
msgstr "\"{0}\" est une valeur invalide pour l'option \"{2}\" de type {1}"
@ -490,8 +487,8 @@ msgid "only \"{0}\" is allowed"
msgstr "seul \"{0}\" est autorisé"
#: tiramisu/option/choiceoption.py:117
msgid "only \"{0}\" are allowed"
msgstr "seul \"{0}\" sont autorisés"
msgid "only {0} are allowed"
msgstr "seul {0} sont autorisés"
#: tiramisu/option/dateoption.py:31
msgid "date"
@ -824,12 +821,12 @@ msgstr ""
"devrait être \"{}\""
#: tiramisu/option/option.py:716
msgid "should be different from the value of \"{}\""
msgstr "devrait être différent de la valeur de \"{}\""
msgid "should be different from the value of {}"
msgstr "devrait être différent de la valeur de {}"
#: tiramisu/option/option.py:718
msgid "must be different from the value of \"{}\""
msgstr "doit être différent de la valeur de \"{}\""
msgid "must be different from the value of {}"
msgstr "doit être différent de la valeur de {}"
#: tiramisu/option/option.py:721
msgid "value for {} should be different"

View File

@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2019-04-08 08:41+CEST\n"
"POT-Creation-Date: 2019-04-13 21:34+CEST\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -223,43 +223,43 @@ msgstr ""
msgid "metaconfig must have the same optiondescription"
msgstr ""
#: tiramisu/error.py:24
#: tiramisu/error.py:26
msgid "and"
msgstr ""
#: tiramisu/error.py:26
#: tiramisu/error.py:28
msgid "or"
msgstr ""
#: tiramisu/error.py:50
#: tiramisu/error.py:52
msgid " {} "
msgstr ""
#: tiramisu/error.py:103 tiramisu/setting.py:579
#: tiramisu/error.py:105 tiramisu/setting.py:579
msgid "property"
msgstr ""
#: tiramisu/error.py:105 tiramisu/setting.py:581
#: tiramisu/error.py:107 tiramisu/setting.py:581
msgid "properties"
msgstr ""
#: tiramisu/error.py:107
#: tiramisu/error.py:109
msgid "cannot access to {0} \"{1}\" because \"{2}\" has {3} {4}"
msgstr ""
#: tiramisu/error.py:114
#: tiramisu/error.py:116
msgid "cannot access to {0} \"{1}\" because has {2} {3}"
msgstr ""
#: tiramisu/error.py:189
#: tiramisu/error.py:191
msgid "invalid value"
msgstr ""
#: tiramisu/error.py:194
#: tiramisu/error.py:196
msgid "attention, \"{0}\" could be an invalid {1} for \"{2}\""
msgstr ""
#: tiramisu/error.py:198 tiramisu/error.py:202
#: tiramisu/error.py:200 tiramisu/error.py:204
msgid "\"{0}\" is an invalid {1} for \"{2}\""
msgstr ""
@ -429,7 +429,7 @@ msgid "only \"{0}\" is allowed"
msgstr ""
#: tiramisu/option/choiceoption.py:117
msgid "only \"{0}\" are allowed"
msgid "only {0} are allowed"
msgstr ""
#: tiramisu/option/dateoption.py:31
@ -729,11 +729,11 @@ msgid "unexpected length of \"{}\" in constency \"{}\", should be \"{}\""
msgstr ""
#: tiramisu/option/option.py:716
msgid "should be different from the value of \"{}\""
msgid "should be different from the value of {}"
msgstr ""
#: tiramisu/option/option.py:718
msgid "must be different from the value of \"{}\""
msgid "must be different from the value of {}"
msgstr ""
#: tiramisu/option/option.py:721

View File

@ -113,7 +113,7 @@ class Base:
set_forbidden_properties = calc_properties & properties
if set_forbidden_properties != frozenset():
raise ValueError(_('conflict: properties already set in requirement {0} for {1}'
'').format(display_list(set_forbidden_properties),
'').format(display_list(set_forbidden_properties, add_quote=True),
name))
def _get_function_args(self,

View File

@ -114,5 +114,5 @@ class ChoiceOption(Option):
raise ValueError(_('only "{0}" is allowed'
'').format(values[0]))
else:
raise ValueError(_('only "{0}" are allowed'
'').format(display_list(values)))
raise ValueError(_('only {0} are allowed'
'').format(display_list(values, add_quote=True)))

View File

@ -713,9 +713,9 @@ class Option(BaseOption):
if equal:
if is_current:
if warnings_only:
msg = _('should be different from the value of "{}"')
msg = _('should be different from the value of {}')
else:
msg = _('must be different from the value of "{}"')
msg = _('must be different from the value of {}')
else:
if warnings_only:
msg = _('value for {} should be different')
@ -724,7 +724,7 @@ class Option(BaseOption):
equal_name = []
for opt in equal:
equal_name.append(opt.impl_get_display_name())
raise ValueError(msg.format(display_list(list(equal_name))))
raise ValueError(msg.format(display_list(list(equal_name), add_quote=True)))
def to_dynoption(self,
rootpath: str,