Compare commits

..

4 commits

10 changed files with 46 additions and 5 deletions

View file

@ -1,3 +1,16 @@
## 1.2.0a15 (2025-04-01)
### Feat
- can link regexp variable
- can link choice variable
### Fix
- update tests
- do not raise variable in property with force_optional
- update translation
## 1.2.0a14 (2025-03-30)
### Fix

View file

@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
[project]
name = "rougail"
version = "1.2.0a14"
version = "1.2.0a15"
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
readme = "README.md"
description = "A consistency handling system that was initially designed in the configuration management"

View file

@ -589,7 +589,9 @@ class VariablePropertyCalculation(_VariableCalculation):
identifier,
needs_multi=False,
)
if params[None] and "variable" in params[None][0]:
if objectspace.force_optional and (not params[None] or "variable" not in params[None][0]):
params = {None: [None, None, False]}
else:
variable = params[None][0]["variable"]
if self.when is not undefined:
if self.version == "1.0":

View file

@ -39,6 +39,7 @@ from rougail.error import display_xmlfiles
from tiramisu import DynOptionDescription, calc_value, function_waiting_for_error
from tiramisu.error import ValueWarning, ConfigError, PropertiesOptionError, CancelParam
from .utils import normalize_family
from .i18n import _
global func
@ -163,7 +164,7 @@ def jinja_to_function(
except Exception as err:
kw_str = ", ".join(kw_to_string(kw))
raise ConfigError(
f'cannot calculating "{__internal_attribute}" attribute for variable "{__internal_variable}" in {display_xmlfiles(__internal_files)} with parameters "{kw_str}": {err}'
_('cannot calculating "{0}" attribute for variable "{1}" in {2} with parameters "{3}": {4}').format(__internal_attribute, __internal_variable, display_xmlfiles(__internal_files), kw_str, err)
) from err
convert = CONVERT_OPTION[__internal_type].get("func", str)
if __internal_multi:

View file

@ -0,0 +1,10 @@
{
"rougail.var1": {
"owner": "default",
"value": "#a1a1a1"
},
"rougail.var2": {
"owner": "default",
"value": "#a1a1a1"
}
}

View file

@ -0,0 +1,4 @@
{
"rougail.var1": "#a1a1a1",
"rougail.var2": "#a1a1a1"
}

View file

@ -0,0 +1,10 @@
{
"rougail.var1": {
"owner": "default",
"value": "#a1a1a1"
},
"rougail.var2": {
"owner": "default",
"value": "#a1a1a1"
}
}

View file

@ -0,0 +1 @@
[]

View file

@ -21,6 +21,6 @@ class Regexp_option_3(RegexpOption):
Regexp_option_3._regexp = re_compile(r"^#(?:[0-9a-f]{3}){1,2}$")
option_2 = Regexp_option_2(name="var1", doc="a first variable", default="#a1a1a1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'regexp', 'test': ('#b1b1b1', '#b2b2b2')})
option_3 = Regexp_option_3(name="var2", doc="a second variable", default=Calculation(func['calc_value'], Params((ParamOption(option_2)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'regexp'})
option_3 = Regexp_option_3(name="var2", doc="a second variable", default=Calculation(func['calc_value'], Params((ParamOption(option_2)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'regexp', 'test': ('#b2b1b1', '#b3b2b2')})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -17,5 +17,5 @@ class Regexp_option_2(RegexpOption):
Regexp_option_2._regexp = re_compile(r"^#(?:[0-9a-f]{3}){1,2}$")
option_1 = Regexp_option_1(name="var1", doc="a first variable", default="#a1a1a1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'regexp', 'test': ('#b1b1b1', '#b2b2b2')})
option_2 = Regexp_option_2(name="var2", doc="a second variable", default=Calculation(func['calc_value'], Params((ParamOption(option_1)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'regexp'})
option_2 = Regexp_option_2(name="var2", doc="a second variable", default=Calculation(func['calc_value'], Params((ParamOption(option_1)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'regexp', 'test': ('#b2b1b1', '#b3b2b2')})
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2])