fix: better error message
This commit is contained in:
parent
e59b9e84df
commit
0bc1e24d38
6 changed files with 115 additions and 52 deletions
|
|
@ -5,8 +5,8 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"POT-Creation-Date: 2025-04-03 20:44+0200\n"
|
||||
"PO-Revision-Date: 2025-04-03 20:46+0200\n"
|
||||
"POT-Creation-Date: 2025-04-09 08:23+0200\n"
|
||||
"PO-Revision-Date: 2025-04-09 08:26+0200\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: fr\n"
|
||||
|
|
@ -239,7 +239,7 @@ msgstr ""
|
|||
"définition invalide pour la définition des \"structures\" ({0}), aucun "
|
||||
"fichier de structure ne peut être chargé !"
|
||||
|
||||
#: src/rougail/error.py:67
|
||||
#: src/rougail/error.py:67 src/rougail/user_datas.py:251
|
||||
msgid "{0} in {1}"
|
||||
msgstr "{0} dans {1}"
|
||||
|
||||
|
|
@ -273,7 +273,7 @@ msgstr ""
|
|||
|
||||
#: src/rougail/object_model.py:229
|
||||
msgid "cannot find variable \"{0}\" defined in \"{1}\" for \"{2}\""
|
||||
msgstr "ne peut trouve la variable \"{0}\" défini dans \"{1}\" pour \"{2}\""
|
||||
msgstr "ne peut trouver la variable \"{0}\" défini dans \"{1}\" pour \"{2}\""
|
||||
|
||||
#: src/rougail/object_model.py:232
|
||||
msgid "variable \"{0}\" defined in \"{1}\" for \"{2}\" is a dynamic variable"
|
||||
|
|
@ -303,7 +303,7 @@ msgstr ""
|
|||
"La variable \"{0}\" n'est pas trouvé pour l'attribut \"{1}\" dans la "
|
||||
"variable \"{2}\""
|
||||
|
||||
#: src/rougail/object_model.py:533
|
||||
#: src/rougail/object_model.py:536
|
||||
msgid ""
|
||||
"the variable \"{0}\" has an invalid attribute \"{1}\", the variable \"{2}\" "
|
||||
"is multi but is inside a list"
|
||||
|
|
@ -311,7 +311,7 @@ msgstr ""
|
|||
"la variable \"{0}\" a un attribut invalide \"{1}\", la variable \"{2}\" est "
|
||||
"multiple mais est dans une liste"
|
||||
|
||||
#: src/rougail/object_model.py:536
|
||||
#: src/rougail/object_model.py:539
|
||||
msgid ""
|
||||
"the variable \"{0}\" has an invalid attribute \"{1}\", the variable \"{2}\" "
|
||||
"is not multi but is not inside a list"
|
||||
|
|
@ -319,11 +319,11 @@ msgstr ""
|
|||
"la variable \"{0}\" a un attribut invalide \"{1}\", la variable \"{2}\" "
|
||||
"n'est pas multiple mais n'est pas dans une liste"
|
||||
|
||||
#: src/rougail/object_model.py:539
|
||||
#: src/rougail/object_model.py:542
|
||||
msgid "the variable \"{0}\" has an invalid attribute \"{1}\", it's a list"
|
||||
msgstr "la variable \"{0}\" a un attribut invalide \"{1}\", c'est une liste"
|
||||
|
||||
#: src/rougail/object_model.py:548
|
||||
#: src/rougail/object_model.py:550
|
||||
msgid ""
|
||||
"the variable \"{0}\" has an invalid attribute \"{1}\", the variable \"{2}\" "
|
||||
"is a multi"
|
||||
|
|
@ -331,7 +331,7 @@ msgstr ""
|
|||
"la variable \"{0}\" a un attribut invalide \"{1}\", la variable \"{2}\" est "
|
||||
"multiple"
|
||||
|
||||
#: src/rougail/object_model.py:570
|
||||
#: src/rougail/object_model.py:572
|
||||
msgid ""
|
||||
"\"{0}\" attribut shall not have an \"optional\" attribute for variable "
|
||||
"\"{1}\""
|
||||
|
|
@ -339,15 +339,15 @@ msgstr ""
|
|||
"l'attribut \"{0}\" ne devrait pas avoir d'attribut \"optional\" pour la "
|
||||
"variable \"{1}\""
|
||||
|
||||
#: src/rougail/object_model.py:582
|
||||
#: src/rougail/object_model.py:584
|
||||
msgid ""
|
||||
"variable \"{0}\" has a default variable calculated with \"{1}\" which has "
|
||||
"variable \"{0}\" has a default value calculated with \"{1}\" which has "
|
||||
"incompatible type"
|
||||
msgstr ""
|
||||
"la variable \"{0}\" a une valeur par défaut calculé a partir de \"{1}\" "
|
||||
"laquelle a un type incompatible"
|
||||
|
||||
#: src/rougail/object_model.py:618
|
||||
#: src/rougail/object_model.py:620
|
||||
msgid ""
|
||||
"\"when\" is not allowed in format version 1.0 for attribute \"{0}\" for "
|
||||
"variable \"{1}\""
|
||||
|
|
@ -355,7 +355,7 @@ msgstr ""
|
|||
"\"when\" n'est pas autorisé avec le format en version 1.0 pour l'attribut "
|
||||
"\"{0}\" pour la variable \"{1}\""
|
||||
|
||||
#: src/rougail/object_model.py:621
|
||||
#: src/rougail/object_model.py:623
|
||||
msgid ""
|
||||
"the variable \"{0}\" has an invalid attribute \"{1}\", \"when\" and "
|
||||
"\"when_not\" cannot set together"
|
||||
|
|
@ -363,7 +363,7 @@ msgstr ""
|
|||
"la variable \"{0}\" a un attribut invalide \"{1}\", \"when\" et \"when_not\" "
|
||||
"ne peuvent pas être défini ensemble"
|
||||
|
||||
#: src/rougail/object_model.py:627
|
||||
#: src/rougail/object_model.py:629
|
||||
msgid ""
|
||||
"\"when_not\" is not allowed in format version 1.0 for attribute \"{0}\" for "
|
||||
"variable \"{1}\""
|
||||
|
|
@ -371,7 +371,7 @@ msgstr ""
|
|||
"\"when_not\" n'est pas autorisé au format 1.0 pour l'attribut \"{0}\" pour "
|
||||
"la variable variable \"{1}\""
|
||||
|
||||
#: src/rougail/object_model.py:680
|
||||
#: src/rougail/object_model.py:682
|
||||
msgid ""
|
||||
"cannot find variable \"{0}\" for the information \"{1}\" when calculating "
|
||||
"\"{2}\""
|
||||
|
|
@ -379,18 +379,18 @@ msgstr ""
|
|||
"ne peut trouver la variable \"{0}\" pour l'information \"{1}\" lors du "
|
||||
"calcul de \"{2}\""
|
||||
|
||||
#: src/rougail/object_model.py:683
|
||||
#: src/rougail/object_model.py:685
|
||||
msgid ""
|
||||
"identifier not allowed for the information \"{0}\" when calculating \"{1}\""
|
||||
msgstr ""
|
||||
"identifier n'est pas autorisé pour l'information \"{0}\" lors du calcul de "
|
||||
"\"{1}\""
|
||||
|
||||
#: src/rougail/object_model.py:732
|
||||
#: src/rougail/object_model.py:734
|
||||
msgid "\"when\" is not allowed in format version 1.0 for attribute \"{0}\""
|
||||
msgstr "\"when\" n'est pas autorisé au format 1.0 pour l'attribut \"{0}\""
|
||||
|
||||
#: src/rougail/object_model.py:736 src/rougail/object_model.py:744
|
||||
#: src/rougail/object_model.py:738 src/rougail/object_model.py:746
|
||||
msgid ""
|
||||
"the identifier has an invalid attribute \"{0}\", \"when\" and \"when_not\" "
|
||||
"cannot set together"
|
||||
|
|
@ -398,7 +398,7 @@ msgstr ""
|
|||
"l'identifiant a un attribut invalide \"{0}\", \"when\" et \"when_not\" ne "
|
||||
"peuvent pas être défini ensemble"
|
||||
|
||||
#: src/rougail/object_model.py:766
|
||||
#: src/rougail/object_model.py:768
|
||||
msgid ""
|
||||
"the variable \"{0}\" is not a follower, so cannot have index type for \"{1}\""
|
||||
msgstr ""
|
||||
|
|
@ -478,15 +478,26 @@ msgstr ""
|
|||
msgid "internal error, {0} is not a dynamic variable"
|
||||
msgstr "erreur interne, \"{0}\" n'est pas une variable dynamique"
|
||||
|
||||
#: src/rougail/user_datas.py:164
|
||||
#: src/rougail/user_datas.py:116
|
||||
msgid ""
|
||||
"cannot load variable path \"{0}\", the identifier \"{1}\" is not valid in {2}"
|
||||
msgstr ""
|
||||
"ne peut charger la variable \"{0}\", l'identifiant \"{1}\" n'est pas valide "
|
||||
"dans {2}"
|
||||
|
||||
#: src/rougail/user_datas.py:171
|
||||
msgid "the variable \"{0}\" contains secrets and should not be defined in {1}"
|
||||
msgstr ""
|
||||
"la variable \"{0}\" contient des secrets et ne devrait pas être défini dans "
|
||||
"{1}"
|
||||
|
||||
#: src/rougail/user_datas.py:227
|
||||
msgid "the option \"{0}\" is an option description"
|
||||
msgstr "l'option \"{0}\" est une option description"
|
||||
#: src/rougail/user_datas.py:234
|
||||
msgid "the variable \"{0}\" is a family in {1}"
|
||||
msgstr "la variable \"{0}\" est une famille dans {1}"
|
||||
|
||||
#: src/rougail/user_datas.py:249
|
||||
msgid "{0} loaded from {1}"
|
||||
msgstr "{0} chargée depuis {1}"
|
||||
|
||||
#: src/rougail/utils.py:55
|
||||
msgid ""
|
||||
|
|
@ -500,6 +511,15 @@ msgstr ""
|
|||
msgid "error in jinja \"{0}\" for the variable \"{1}\": {2}"
|
||||
msgstr "erreur dans Jinja \"{0}\" pour la variable \"{1}\": {2}"
|
||||
|
||||
#~ msgid "error in {0}: {1}"
|
||||
#~ msgstr "erreur dans {0} : {1}"
|
||||
|
||||
#~ msgid "cannot find variable \"{0}\" from {1}: {2}"
|
||||
#~ msgstr "ne peut trouver la variable \"{0}\" depuis {1} : {2}"
|
||||
|
||||
#~ msgid "the option \"{0}\" is an option description"
|
||||
#~ msgstr "l'option \"{0}\" est une option description"
|
||||
|
||||
#~ msgid "Update dictionaries to newest Rougail format version"
|
||||
#~ msgstr ""
|
||||
#~ "Mettre à jour le fichier de structure vers la dernière version du format "
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2025-04-03 20:46+0200\n"
|
||||
"POT-Creation-Date: 2025-04-09 08:26+0200\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"
|
||||
|
|
@ -187,7 +187,7 @@ msgstr ""
|
|||
msgid "invalid \"structural\" definition ({0}), we cannot load any structural file!"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/error.py:67
|
||||
#: src/rougail/error.py:67 src/rougail/user_datas.py:251
|
||||
msgid "{0} in {1}"
|
||||
msgstr ""
|
||||
|
||||
|
|
@ -231,59 +231,59 @@ msgstr ""
|
|||
msgid "Variable not found \"{0}\" for attribut \"{1}\" in variable \"{2}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/object_model.py:533
|
||||
#: src/rougail/object_model.py:536
|
||||
msgid "the variable \"{0}\" has an invalid attribute \"{1}\", the variable \"{2}\" is multi but is inside a list"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/object_model.py:536
|
||||
#: src/rougail/object_model.py:539
|
||||
msgid "the variable \"{0}\" has an invalid attribute \"{1}\", the variable \"{2}\" is not multi but is not inside a list"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/object_model.py:539
|
||||
#: src/rougail/object_model.py:542
|
||||
msgid "the variable \"{0}\" has an invalid attribute \"{1}\", it's a list"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/object_model.py:548
|
||||
#: src/rougail/object_model.py:550
|
||||
msgid "the variable \"{0}\" has an invalid attribute \"{1}\", the variable \"{2}\" is a multi"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/object_model.py:570
|
||||
#: src/rougail/object_model.py:572
|
||||
msgid "\"{0}\" attribut shall not have an \"optional\" attribute for variable \"{1}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/object_model.py:582
|
||||
#: src/rougail/object_model.py:584
|
||||
msgid "variable \"{0}\" has a default value calculated with \"{1}\" which has incompatible type"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/object_model.py:618
|
||||
#: src/rougail/object_model.py:620
|
||||
msgid "\"when\" is not allowed in format version 1.0 for attribute \"{0}\" for variable \"{1}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/object_model.py:621
|
||||
#: src/rougail/object_model.py:623
|
||||
msgid "the variable \"{0}\" has an invalid attribute \"{1}\", \"when\" and \"when_not\" cannot set together"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/object_model.py:627
|
||||
#: src/rougail/object_model.py:629
|
||||
msgid "\"when_not\" is not allowed in format version 1.0 for attribute \"{0}\" for variable \"{1}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/object_model.py:680
|
||||
#: src/rougail/object_model.py:682
|
||||
msgid "cannot find variable \"{0}\" for the information \"{1}\" when calculating \"{2}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/object_model.py:683
|
||||
#: src/rougail/object_model.py:685
|
||||
msgid "identifier not allowed for the information \"{0}\" when calculating \"{1}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/object_model.py:732
|
||||
#: src/rougail/object_model.py:734
|
||||
msgid "\"when\" is not allowed in format version 1.0 for attribute \"{0}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/object_model.py:736 src/rougail/object_model.py:744
|
||||
#: src/rougail/object_model.py:738 src/rougail/object_model.py:746
|
||||
msgid "the identifier has an invalid attribute \"{0}\", \"when\" and \"when_not\" cannot set together"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/object_model.py:766
|
||||
#: src/rougail/object_model.py:768
|
||||
msgid "the variable \"{0}\" is not a follower, so cannot have index type for \"{1}\""
|
||||
msgstr ""
|
||||
|
||||
|
|
@ -343,12 +343,20 @@ msgstr ""
|
|||
msgid "internal error, {0} is not a dynamic variable"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_datas.py:164
|
||||
#: src/rougail/user_datas.py:116
|
||||
msgid "cannot load variable path \"{0}\", the identifier \"{1}\" is not valid in {2}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_datas.py:171
|
||||
msgid "the variable \"{0}\" contains secrets and should not be defined in {1}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_datas.py:227
|
||||
msgid "the option \"{0}\" is an option description"
|
||||
#: src/rougail/user_datas.py:234
|
||||
msgid "the variable \"{0}\" is a family in {1}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_datas.py:249
|
||||
msgid "{0} loaded from {1}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/utils.py:55
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||
from typing import List
|
||||
from re import findall
|
||||
|
||||
from rougail.utils import normalize_family
|
||||
from tiramisu import undefined, Calculation
|
||||
from tiramisu.error import (
|
||||
PropertiesOptionError,
|
||||
|
|
@ -29,6 +30,7 @@ from tiramisu.error import (
|
|||
ConfigError,
|
||||
CancelParam,
|
||||
)
|
||||
from .error import DictConsistencyError
|
||||
|
||||
from .i18n import _
|
||||
from .object_model import CONVERT_OPTION
|
||||
|
|
@ -75,16 +77,15 @@ class UserDatas:
|
|||
cache = {}
|
||||
added = []
|
||||
for path, data in list(self.values.items()):
|
||||
value = data["values"]
|
||||
try:
|
||||
option = self.config.option(path)
|
||||
option.name()
|
||||
except (ConfigError, PropertiesOptionError):
|
||||
pass
|
||||
except AttributeError:
|
||||
self._not_found_is_dynamic(self.config, path, cache, added)
|
||||
self._not_found_is_dynamic(self.config, path, cache, added, data)
|
||||
|
||||
def _not_found_is_dynamic(self, config, path, cache, added):
|
||||
def _not_found_is_dynamic(self, config, path, cache, added, data):
|
||||
"""if path is not found, check if parent is a dynamic family"""
|
||||
current_path = ""
|
||||
identifiers = []
|
||||
|
|
@ -111,9 +112,14 @@ class UserDatas:
|
|||
# it's not a dynamic variable
|
||||
continue
|
||||
identifier = self._get_identifier(tconfig.name(), name)
|
||||
if identifier != normalize_family(identifier):
|
||||
msg = _('cannot load variable path "{0}", the identifier "{1}" is not valid in {2}').format(path, identifier, data["source"])
|
||||
self.warnings.append(msg)
|
||||
continue
|
||||
if identifier is None:
|
||||
# it's a dynamic variable but doesn't match the current name
|
||||
continue
|
||||
# get the variable associate to this dynamic family
|
||||
dynamic_variable = tconfig.information.get(
|
||||
"dynamic_variable",
|
||||
None,
|
||||
|
|
@ -133,6 +139,7 @@ class UserDatas:
|
|||
dynamic_variable = dynamic_variable.replace(
|
||||
"{{ identifier }}", str(s), 1
|
||||
)
|
||||
# do not add values in variable if has already a value
|
||||
if dynamic_variable not in self.values and not dyn_options_values:
|
||||
self.values[dynamic_variable] = {"values": []}
|
||||
added.append(dynamic_variable)
|
||||
|
|
@ -224,8 +231,9 @@ class UserDatas:
|
|||
option = self.config.option(path)
|
||||
if option.isoptiondescription():
|
||||
self.errors.warnings(
|
||||
_('the option "{0}" is an option description').format(
|
||||
option.path()
|
||||
_('the variable "{0}" is a family in {1}').format(
|
||||
option.path(),
|
||||
data["source"],
|
||||
)
|
||||
)
|
||||
continue
|
||||
|
|
@ -238,11 +246,9 @@ class UserDatas:
|
|||
else:
|
||||
option.value.set(value)
|
||||
except AttributeError as err:
|
||||
self.warnings.append(str(err))
|
||||
except (ValueError, LeadershipError) as err:
|
||||
self.warnings.append(str(err))
|
||||
except PropertiesOptionError as err:
|
||||
self.warnings.append(str(err))
|
||||
self.warnings.append(_('{0} loaded from {1}').format(err, data["source"]))
|
||||
except (ValueError, LeadershipError, PropertiesOptionError) as err:
|
||||
self.warnings.append(_('{0} in {1}').format(err, data["source"]))
|
||||
|
||||
|
||||
def convert_value(option, value):
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
from tiramisu import *
|
||||
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||
from re import compile as re_compile
|
||||
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||
load_functions('../rougail-tests/funcs/test.py')
|
||||
try:
|
||||
groups.namespace
|
||||
except:
|
||||
groups.addgroup('namespace')
|
||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||
option_2 = StrOption(name="var", doc="A suffix variable", multi=True, default=["Val1", "VAL2"], default_multi="Val1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
|
||||
option_4 = StrOption(name="var", doc="A dynamic variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'})
|
||||
optiondescription_3 = ConvertDynOptionDescription(name="dyn{{ identifier }}", doc="A dynamic family", identifiers=Calculation(func['calc_value'], Params((ParamOption(option_2)))), children=[option_4], properties=frozenset({"basic"}), informations={'dynamic_variable': 'rougail.var'})
|
||||
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, optiondescription_3], properties=frozenset({"basic"}))
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
from tiramisu import *
|
||||
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||
from re import compile as re_compile
|
||||
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||
load_functions('../rougail-tests/funcs/test.py')
|
||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||
option_1 = StrOption(name="var", doc="A suffix variable", multi=True, default=["Val1", "VAL2"], default_multi="Val1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
|
||||
option_3 = StrOption(name="var", doc="A dynamic variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'})
|
||||
optiondescription_2 = ConvertDynOptionDescription(name="dyn{{ identifier }}", doc="A dynamic family", identifiers=Calculation(func['calc_value'], Params((ParamOption(option_1)))), children=[option_3], properties=frozenset({"basic"}), informations={'dynamic_variable': 'var'})
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, optiondescription_2])
|
||||
Loading…
Reference in a new issue