Compare commits

..

No commits in common. "b0687fdcc6cf18a9ffe508bf9625bfe6da0424f4" and "63f76dc68f09180166967fab34dc37b2d2c83caf" have entirely different histories.

81 changed files with 93 additions and 1116 deletions

View file

@ -1,14 +1,3 @@
## 1.2.0a9 (2025-02-10)
### Feat
- can change defaut params for an option
### Fix
- if no description, generate negative_description too
- error messages
## 1.2.0a8 (2025-01-04) ## 1.2.0a8 (2025-01-04)
### Fix ### Fix

View file

@ -45,7 +45,7 @@ msgid ""
"the variable \"{0}\" is mandatory so in \"{1}\" mode but family has the " "the variable \"{0}\" is mandatory so in \"{1}\" mode but family has the "
"higher family mode \"{2}\"" "higher family mode \"{2}\""
msgstr "" msgstr ""
"la variable \"{0}\" est obligatoire, donc en mode \"{1}\", mais la " "la variable \"{0}\" est obligatoire donc dans le mode \"{1}\" mais la "
"famille a un mode supérieur \"{2}\"" "famille a un mode supérieur \"{2}\""
#: src/rougail/annotator/family.py:287 #: src/rougail/annotator/family.py:287

View file

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

View file

@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2025 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the under the terms of the GNU Lesser General Public License as published by the

View file

@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2025 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the under the terms of the GNU Lesser General Public License as published by the

View file

@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2025 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the under the terms of the GNU Lesser General Public License as published by the
@ -136,7 +136,6 @@ class Annotator(Walk):
) )
if family.version == "1.0" and "{{ suffix }}" in path: if family.version == "1.0" and "{{ suffix }}" in path:
path = path.replace("{{ suffix }}", "{{ identifier }}") path = path.replace("{{ suffix }}", "{{ identifier }}")
self.objectspace.dynamics_variable.setdefault(path, []).append(family.path)
self.objectspace.informations.add(family.path, "dynamic_variable", path) self.objectspace.informations.add(family.path, "dynamic_variable", path)
def change_modes(self): def change_modes(self):

View file

@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2025 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the under the terms of the GNU Lesser General Public License as published by the

View file

@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2025 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the under the terms of the GNU Lesser General Public License as published by the

View file

@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2025 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the under the terms of the GNU Lesser General Public License as published by the
@ -130,7 +130,14 @@ class Annotator(Walk): # pylint: disable=R0903
): ):
return return
# copy type and params # copy type and params
calculated_variable, identifier = variable.default.get_variable(self.objectspace) calculated_variable_path = variable.default.variable
calculated_variable, identifier = self.objectspace.paths.get_with_dynamic(
calculated_variable_path,
variable.path,
variable.version,
variable.namespace,
variable.xmlfiles,
)
if calculated_variable is None: if calculated_variable is None:
return return
variable.type = calculated_variable.type variable.type = calculated_variable.type

View file

@ -10,7 +10,7 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2025 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the under the terms of the GNU Lesser General Public License as published by the
@ -33,7 +33,6 @@ from tiramisu import Config
from ruamel.yaml import YAML from ruamel.yaml import YAML
from .utils import _, load_modules, normalize_family from .utils import _, load_modules, normalize_family
from .convert import RougailConvert from .convert import RougailConvert
from .object_model import get_convert_option_types
if version_info.major == 3 and version_info.minor: if version_info.major == 3 and version_info.minor:
import rougail.structural_commandline.object_model import rougail.structural_commandline.object_model
@ -73,52 +72,39 @@ def get_level(module):
class _RougailConfig: class _RougailConfig:
def __init__(self, backward_compatibility: bool, def __init__(self, backward_compatibility: bool, root, extra_vars: dict):
add_extra_options: bool):
self.backward_compatibility = backward_compatibility self.backward_compatibility = backward_compatibility
self.add_extra_options = add_extra_options
self.root = None
def copy(self):
rougailconfig = _RougailConfig(
self.backward_compatibility,
self.add_extra_options,
)
if self.root:
rougailconfig.config.value.importation(self.config.value.exportation())
rougailconfig.config.property.importation(self.config.property.exportation())
rougailconfig.config.property.read_only()
rougailconfig.root = self.root
rougailconfig.config = self.config
rougailconfig.extra_vars = self.extra_vars
for variable in self.not_in_tiramisu:
value = getattr(self, variable)
if not isinstance(value, str):
value = value.copy()
setattr(rougailconfig, variable, value)
return rougailconfig
def generate_config(self):
root, extra_vars = _rougail_config(self.backward_compatibility, self.add_extra_options)
self.root = root self.root = root
self.config = Config( self.config = Config(
self.root, self.root,
) )
self.config.property.read_only()
self.extra_vars = extra_vars self.extra_vars = extra_vars
self.not_in_tiramisu = NOT_IN_TIRAMISU | extra_vars self.not_in_tiramisu = NOT_IN_TIRAMISU | extra_vars
for variable, default_value in self.not_in_tiramisu.items(): for variable, default_value in self.not_in_tiramisu.items():
if not isinstance(default_value, str): if not isinstance(default_value, str):
default_value = default_value.copy() default_value = default_value.copy()
setattr(self, variable, default_value) setattr(self, variable, default_value)
self.config.property.read_only()
def copy(self):
rougailconfig = _RougailConfig(
self.backward_compatibility, self.root, self.extra_vars
)
rougailconfig.config.value.importation(self.config.value.exportation())
rougailconfig.config.property.importation(self.config.property.exportation())
rougailconfig.config.property.read_only()
for variable in self.not_in_tiramisu:
value = getattr(self, variable)
if not isinstance(value, str):
value = value.copy()
setattr(rougailconfig, variable, value)
return rougailconfig
def __setitem__( def __setitem__(
self, self,
key, key,
value, value,
) -> None: ) -> None:
if self.root is None:
self.generate_config()
if key in self.not_in_tiramisu: if key in self.not_in_tiramisu:
setattr(self, key, value) setattr(self, key, value)
else: else:
@ -144,8 +130,6 @@ class _RougailConfig:
self, self,
key, key,
) -> None: ) -> None:
if self.root is None:
self.generate_config()
if key in self.not_in_tiramisu: if key in self.not_in_tiramisu:
return getattr(self, key) return getattr(self, key)
if key == "export_with_import": if key == "export_with_import":
@ -215,10 +199,11 @@ class FakeRougailConvert(RougailConvert):
self.load_unexist_redefine = False self.load_unexist_redefine = False
def _rougail_config( def get_rougail_config(
*,
backward_compatibility: bool = True, backward_compatibility: bool = True,
add_extra_options: bool = True, add_extra_options: bool = True,
) -> "OptionDescription": ) -> _RougailConfig:
rougail_options = f"""default_dictionary_format_version: rougail_options = f"""default_dictionary_format_version:
description: Dictionary format version by default, if not specified in dictionary file description: Dictionary format version by default, if not specified in dictionary file
alternative_name: v alternative_name: v
@ -418,23 +403,6 @@ load_unexist_redefine:
NAME=normalize_family(process), NAME=normalize_family(process),
PROP=prop, PROP=prop,
) )
rougail_process += f"""
default_params:
description: {_("Default parameters for option type")}
"""
for typ, params in get_convert_option_types():
rougail_process += f"""
{typ}:
"""
for key, key_type, multi, value in params:
rougail_process += f"""
{key}:
type: {key_type}
multi: {multi}
mandatory: false
default: {value}
"""
rougail_options += rougail_process rougail_options += rougail_process
# print(rougail_options) # print(rougail_options)
convert = FakeRougailConvert(add_extra_options) convert = FakeRougailConvert(add_extra_options)
@ -470,17 +438,10 @@ default_params:
tiram_obj = convert.save() tiram_obj = convert.save()
optiondescription = {} optiondescription = {}
exec(tiram_obj, {}, optiondescription) # pylint: disable=W0122 exec(tiram_obj, {}, optiondescription) # pylint: disable=W0122
return optiondescription["option_0"], extra_vars
def get_rougail_config(
*,
backward_compatibility: bool = True,
add_extra_options: bool = True,
) -> _RougailConfig:
return _RougailConfig( return _RougailConfig(
backward_compatibility, backward_compatibility,
add_extra_options, optiondescription["option_0"],
extra_vars=extra_vars,
) )

View file

@ -10,7 +10,7 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2025 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the under the terms of the GNU Lesser General Public License as published by the
@ -135,7 +135,7 @@ class ParserVariable:
self.reflector_names = {} self.reflector_names = {}
self.leaders = [] self.leaders = []
self.followers = [] self.followers = []
self.dynamics_variable = {} self.dynamics = []
self.multis = {} self.multis = {}
self.default_multi = {} self.default_multi = {}
self.jinja = {} self.jinja = {}
@ -176,16 +176,6 @@ class ParserVariable:
self.output = rougailconfig["step.output"] self.output = rougailconfig["step.output"]
self.tiramisu_cache = rougailconfig["tiramisu_cache"] self.tiramisu_cache = rougailconfig["tiramisu_cache"]
self.load_unexist_redefine = rougailconfig["load_unexist_redefine"] self.load_unexist_redefine = rougailconfig["load_unexist_redefine"]
# change default initkwargs in CONVERT_OPTION
if hasattr(rougailconfig, 'config'):
for sub_od in rougailconfig.config.option('default_params'):
for option in sub_od:
if option.owner.isdefault():
continue
convert_option = CONVERT_OPTION[sub_od.name()]
if "initkwargs" not in convert_option:
convert_option["initkwargs"] = {}
convert_option["initkwargs"][option.name()] = option.value.get()
def init(self): def init(self):
if self.is_init: if self.is_init:
@ -399,8 +389,13 @@ class ParserVariable:
# it's just for modify subfamily or subvariable, do not redefine # it's just for modify subfamily or subvariable, do not redefine
if family_obj: if family_obj:
if exists in [None, True] and not obj.pop("redefine", False): if exists in [None, True] and not obj.pop("redefine", False):
msg = _('family "{0}" define multiple time').format(path) raise DictConsistencyError(
raise DictConsistencyError(msg, 32, self.paths[path].xmlfiles + [filename]) _(
'The family "{0}" already exists and it is not redefined'
).format(path),
32,
[filename],
)
# convert to Calculation objects # convert to Calculation objects
self.parse_parameters( self.parse_parameters(
path, path,
@ -649,14 +644,14 @@ class ParserVariable:
family_is_leadership is True and first_variable is False, family_is_leadership is True and first_variable is False,
version, version,
) )
self.parse_params(path, obj, filename) self.parse_params(path, obj)
exists = obj.pop("exists", None) exists = obj.pop("exists", None)
if path in self.paths: if path in self.paths:
if not self.load_unexist_redefine and exists is False: if not self.load_unexist_redefine and exists is False:
return return
if not obj.pop("redefine", False): if not obj.pop("redefine", False):
msg = _('variable "{0}" define multiple time').format(path) msg = f'Variable "{path}" already exists'
raise DictConsistencyError(msg, 45, self.paths[path].xmlfiles + [filename]) raise DictConsistencyError(msg, 45, [filename])
self.paths.add( self.paths.add(
path, path,
self.paths[path].model_copy(update=obj), self.paths[path].model_copy(update=obj),
@ -753,15 +748,12 @@ class ParserVariable:
f"at index {idx}: {err}" f"at index {idx}: {err}"
) from err ) from err
def parse_params(self, path, obj, filename): def parse_params(self, path, obj):
"""Parse variable params""" """Parse variable params"""
if "params" not in obj: if "params" not in obj:
return return
if not isinstance(obj["params"], dict): if not isinstance(obj["params"], dict):
raise DictConsistencyError(_("params must be a dict for {0}").format(path), raise Exception(f"params must be a dict for {path}")
55,
[filename],
)
params = [] params = []
for key, val in obj["params"].items(): for key, val in obj["params"].items():
try: try:
@ -774,14 +766,12 @@ class ParserVariable:
is_follower=None, is_follower=None,
attribute=None, attribute=None,
family_is_dynamic=None, family_is_dynamic=None,
xmlfiles=[filename], xmlfiles=None,
) )
) )
except ValidationError as err: except ValidationError as err:
raise DictConsistencyError( raise Exception(
_('"{0}" has an invalid "params" for {1}: {2}').format(key, path, err), f'"{key}" has an invalid "params" for {path}: {err}'
54,
[filename],
) from err ) from err
obj["params"] = params obj["params"] = params
@ -938,17 +928,11 @@ class ParserVariable:
val["is_follower"] = is_follower val["is_follower"] = is_follower
val["attribute"] = attribute val["attribute"] = attribute
val["xmlfiles"] = xmlfiles val["xmlfiles"] = xmlfiles
if param_typ not in PARAM_TYPES:
raise DictConsistencyError(
f'unknown type "{param_typ}" for "{path}"',
52,
xmlfiles,
)
try: try:
params.append(PARAM_TYPES[param_typ](**val)) params.append(PARAM_TYPES[param_typ](**val))
except ValidationError as err: except ValidationError as err:
raise DictConsistencyError( raise DictConsistencyError(
f'"{attribute}" has an invalid "{key}" for "{path}": {err}', f'"{attribute}" has an invalid "{key}" for {path}: {err}',
29, 29,
xmlfiles, xmlfiles,
) from err ) from err

View file

@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2025 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the under the terms of the GNU Lesser General Public License as published by the

View file

@ -8,7 +8,7 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2025 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the under the terms of the GNU Lesser General Public License as published by the

View file

@ -1,7 +1,7 @@
"""Rougail object model """Rougail object model
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2023-2025 Copyright (C) 2023-2024
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the under the terms of the GNU Lesser General Public License as published by the
@ -27,7 +27,6 @@ from pydantic import (
ConfigDict, ConfigDict,
) )
from tiramisu import undefined from tiramisu import undefined
import tiramisu
from .utils import get_jinja_variable_to_param from .utils import get_jinja_variable_to_param
from .error import DictConsistencyError, VariableCalculationDependencyError from .error import DictConsistencyError, VariableCalculationDependencyError
@ -106,35 +105,6 @@ CONVERT_OPTION = {
} }
def get_convert_option_types():
for typ, datas in CONVERT_OPTION.items():
obj = getattr(tiramisu, datas["opttype"])
initkwargs = datas.get("initkwargs", {})
if obj == tiramisu.SymLinkOption:
continue
if obj == tiramisu.ChoiceOption:
inst = obj('a', 'a', ('a',), **initkwargs)
else:
inst = obj('a', 'a', **initkwargs)
extra = getattr(inst, '_extra', {})
if not extra:
continue
params = []
for key, value in extra.items():
if key.startswith('_'):
continue
multi = False
if isinstance(value, bool):
key_type = 'boolean'
elif isinstance(value, str):
key_type = 'string'
elif isinstance(value, list):
key_type = 'string'
multi = True
params.append((key, key_type, multi, value))
yield typ, params
class Param(BaseModel): class Param(BaseModel):
key: str key: str
model_config = ConfigDict(extra="forbid") model_config = ConfigDict(extra="forbid")

View file

@ -1,5 +1,5 @@
""" """
Copyright (C) 2024-2025 Copyright (C) 2024
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the under the terms of the GNU Lesser General Public License as published by the

View file

@ -1,6 +1,6 @@
""" """
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2024-2025 Copyright (C) 2024
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the under the terms of the GNU Lesser General Public License as published by the

View file

@ -1,7 +1,7 @@
"""Annotate to add specify attribute for tiramisu-cmdline """Annotate to add specify attribute for tiramisu-cmdline
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2024-2025 Copyright (C) 2024
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the under the terms of the GNU Lesser General Public License as published by the
@ -91,17 +91,15 @@ class Annotator(Walk):
def manage_negative_description(self, variable) -> None: def manage_negative_description(self, variable) -> None:
if not variable.negative_description: if not variable.negative_description:
if variable.type == "boolean" and not self.objectspace.add_extra_options: if variable.type == "boolean" and not self.objectspace.add_extra_options:
if variable.name == variable.description: raise DictConsistencyError(
variable.negative_description = variable.name _(
else: 'negative_description is mandatory for boolean variable, but "{0}" hasn\'t'
raise DictConsistencyError( ).format(variable.path),
_( 200,
'negative_description is mandatory for boolean variable, but "{0}" hasn\'t' variable.xmlfiles,
).format(variable.path), )
200, return
variable.xmlfiles, if variable.type != "boolean":
)
elif variable.type != "boolean":
raise DictConsistencyError( raise DictConsistencyError(
_( _(
'negative_description is only available for boolean variable, but "{0}" is "{1}"' 'negative_description is only available for boolean variable, but "{0}" is "{1}"'
@ -109,7 +107,6 @@ class Annotator(Walk):
201, 201,
variable.xmlfiles, variable.xmlfiles,
) )
if variable.negative_description: self.objectspace.informations.add(
self.objectspace.informations.add( variable.path, "negative_description", variable.negative_description
variable.path, "negative_description", variable.negative_description )
)

View file

@ -2,7 +2,7 @@
Config file for Rougail-structural_commandline Config file for Rougail-structural_commandline
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2024-2025 Copyright (C) 2024
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the under the terms of the GNU Lesser General Public License as published by the

View file

@ -1,7 +1,7 @@
"""Annotate to add specify attribute for tiramisu-cmdline """Annotate to add specify attribute for tiramisu-cmdline
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2024-2025 Copyright (C) 2024
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the under the terms of the GNU Lesser General Public License as published by the

View file

@ -1,6 +1,6 @@
""" """
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2025 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the under the terms of the GNU Lesser General Public License as published by the
@ -24,8 +24,6 @@ from ruamel.yaml import YAML
from ..utils import normalize_family from ..utils import normalize_family
from ..path import Paths from ..path import Paths
from ..error import DictConsistencyError
from ..i18n import _
class Walker: class Walker:
@ -126,7 +124,7 @@ class Walker:
raise DictConsistencyError( raise DictConsistencyError(
_("duplicate dictionary file name {0}").format(file_path.name), _("duplicate dictionary file name {0}").format(file_path.name),
78, 78,
[filenames[file_path.name], str(file_path)], [filenames[file_path.name][1]],
) )
filenames[file_path.name] = str(file_path) filenames[file_path.name] = str(file_path)

View file

@ -1,6 +1,6 @@
""" """
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2024-2025 Copyright (C) 2024
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the under the terms of the GNU Lesser General Public License as published by the
@ -27,8 +27,7 @@ def get_rougail_config(
main_namespace_default = "rougail" main_namespace_default = "rougail"
else: else:
main_namespace_default = "null" main_namespace_default = "null"
options = f""" options = f"""main_dictionaries:
main_dictionaries:
description: {_("Directories where dictionary files are placed")} description: {_("Directories where dictionary files are placed")}
type: unix_filename type: unix_filename
alternative_name: m alternative_name: m

View file

@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2025 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the under the terms of the GNU Lesser General Public License as published by the
@ -165,7 +165,7 @@ def jinja_to_function(
return values return values
def variable_to_property(prop, value, when, inverse, **kwargs): def variable_to_property(prop, value, when, inverse):
if isinstance(value, PropertiesOptionError): if isinstance(value, PropertiesOptionError):
raise value from value raise value from value
if inverse: if inverse:

View file

@ -10,7 +10,7 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2025 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the under the terms of the GNU Lesser General Public License as published by the
@ -402,7 +402,7 @@ class Common:
kwargs = [] kwargs = []
if "params" in child: if "params" in child:
for key, value in child["params"].items(): for key, value in child["params"].items():
if key is None: if not key:
for val in value: for val in value:
new_args.append(self.populate_param(val)) new_args.append(self.populate_param(val))
else: else:

View file

@ -1,6 +1,6 @@
""" """
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2025 Copyright (C) 2022-2024
distribued with GPL-2 or later license distribued with GPL-2 or later license
@ -23,9 +23,8 @@ from typing import List
from re import findall from re import findall
from tiramisu import undefined, Calculation from tiramisu import undefined, Calculation
from tiramisu.error import PropertiesOptionError, LeadershipError, ConfigError, CancelParam from tiramisu.error import PropertiesOptionError, LeadershipError, ConfigError
from .i18n import _
from .object_model import CONVERT_OPTION from .object_model import CONVERT_OPTION
@ -49,10 +48,8 @@ class UserDatas:
def _populate_values(self, user_datas): def _populate_values(self, user_datas):
for datas in user_datas: for datas in user_datas:
options = datas.get("options", {}) options = datas.get("options", {})
source = datas["source"]
for name, data in datas.get("values", {}).items(): for name, data in datas.get("values", {}).items():
self.values[name] = { self.values[name] = {
"source": source,
"values": data, "values": data,
"options": options.copy(), "options": options.copy(),
} }
@ -151,9 +148,6 @@ class UserDatas:
if path not in self.values: if path not in self.values:
continue continue
options = self.values[path].get("options", {}) options = self.values[path].get("options", {})
if options.get('allow_secrets_variables', True) is False and option.type() == 'password':
self.errors.append(_('the variable "{0}" contains secrets and should not be defined in {1}').format(path, self.values[path]["source"]))
continue
value = self.values[path]["values"] value = self.values[path]["values"]
needs_convert = options.get("needs_convert", False) needs_convert = options.get("needs_convert", False)
@ -212,13 +206,13 @@ class UserDatas:
option = self.config.option(path) option = self.config.option(path)
if option.isoptiondescription(): if option.isoptiondescription():
self.errors.append( self.errors.append(
_('the option "{0}" is an option description').format(option.path()) f'the option "{option.path()}" is an option description'
) )
continue continue
value = data["values"] value = data["values"]
if option.isfollower(): if option.isfollower():
for index, val in enumerate(value): for index, val in enumerate(value):
if val is undefined or isinstance(val, CancelParam): if val is undefined:
continue continue
self.config.option(path, index).value.set(val) self.config.option(path, index).value.set(val)
else: else:

View file

@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2025 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the under the terms of the GNU Lesser General Public License as published by the
@ -114,8 +114,6 @@ def get_jinja_variable_to_param(
jinja_text, current_path, err jinja_text, current_path, err
) )
raise DictConsistencyError(msg, 39, xmlfiles) from err raise DictConsistencyError(msg, 39, xmlfiles) from err
except AttributeError:
pass
variables = list(variables) variables = list(variables)
variables.sort(reverse=True) variables.sort(reverse=True)
founded_variables = {} founded_variables = {}

View file

@ -1,8 +0,0 @@
version: 1.1
file:
type: unix_filename
params:
allow_relative: true
default:
test/unknown_file

View file

@ -1,10 +0,0 @@
{
"rougail.secret1": {
"owner": "default",
"value": null
},
"rougail.secret2": {
"owner": "default",
"value": "value"
}
}

View file

@ -1,4 +0,0 @@
{
"rougail.secret1": null,
"rougail.secret2": "value"
}

View file

@ -1,10 +0,0 @@
{
"rougail.secret1": {
"owner": "default",
"value": null
},
"rougail.secret2": {
"owner": "default",
"value": "value"
}
}

View file

@ -1 +0,0 @@
["rougail.secret1"]

View file

@ -1,16 +0,0 @@
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 = PasswordOption(name="secret1", doc="the first variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'secret'})
option_3 = PasswordOption(name="secret2", doc="the second variable", default="value", properties=frozenset({"mandatory", "standard"}), informations={'type': 'secret'})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3], properties=frozenset({"basic"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -1,11 +0,0 @@
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 = PasswordOption(name="secret1", doc="the first variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'secret'})
option_2 = PasswordOption(name="secret2", doc="the second variable", default="value", properties=frozenset({"mandatory", "standard"}), informations={'type': 'secret'})
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2])

View file

@ -1,14 +0,0 @@
{
"rougail.condition": {
"owner": "default",
"value": "no"
},
"rougail.variable1": {
"owner": "default",
"value": []
},
"rougail.variable2": {
"owner": "default",
"value": []
}
}

View file

@ -1,5 +0,0 @@
{
"rougail.condition": "no",
"rougail.variable1": [],
"rougail.variable2": []
}

View file

@ -1,14 +0,0 @@
{
"rougail.condition": {
"owner": "default",
"value": "no"
},
"rougail.variable1": {
"owner": "default",
"value": []
},
"rougail.variable2": {
"owner": "default",
"value": []
}
}

View file

@ -1 +0,0 @@
["rougail.variable1", "rougail.variable2"]

View file

@ -1,19 +0,0 @@
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")
dict_env['disabled_rougail.variable1'] = "{% if _.condition == \"yes\" %}\ncondition is yes\n{% endif %}\n"
dict_env['disabled_rougail.variable2'] = "{% if _.condition == \"yes\" %}\ncondition is yes\n{% endif %}\n"
option_2 = StrOption(name="condition", doc="a conditional variable", default="no", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_3 = StrOption(name="variable1", doc="a first variable", multi=True, properties=frozenset({"basic", "mandatory", Calculation(func['jinja_to_property'], Params((ParamValue("disabled")), kwargs={'__internal_jinja': ParamValue("disabled_rougail.variable1"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/04_5disabled_calculation_multi/rougail/00-base.yml']), '__internal_attribute': ParamValue("disabled"), '__internal_variable': ParamValue("rougail.variable1"), 'when': ParamValue(True), 'inverse': ParamValue(False), '_.condition': ParamOption(option_2, notraisepropertyerror=True)}), help_function=func['jinja_to_property_help'])}), informations={'type': 'string'})
option_4 = StrOption(name="variable2", doc="a second variable", multi=True, properties=frozenset({"basic", "mandatory", Calculation(func['jinja_to_property'], Params((ParamValue("disabled")), kwargs={'__internal_jinja': ParamValue("disabled_rougail.variable2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/04_5disabled_calculation_multi/rougail/00-base.yml']), '__internal_attribute': ParamValue("disabled"), '__internal_variable': ParamValue("rougail.variable2"), 'when': ParamValue(True), 'inverse': ParamValue(False), '_.condition': ParamOption(option_2, notraisepropertyerror=True)}), help_function=func['jinja_to_property_help'])}), informations={'type': 'string'})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3, option_4], properties=frozenset({"basic"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -1,10 +0,0 @@
{
"rougail.condition": {
"owner": "default",
"value": false
},
"rougail.variable": {
"owner": "default",
"value": []
}
}

View file

@ -1,4 +0,0 @@
{
"rougail.condition": false,
"rougail.variable": []
}

View file

@ -1,10 +0,0 @@
{
"rougail.condition": {
"owner": "default",
"value": false
},
"rougail.variable": {
"owner": "default",
"value": []
}
}

View file

@ -1,16 +0,0 @@
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 = BoolOption(name="condition", doc="a condition", default=False, properties=frozenset({"mandatory", "standard"}), informations={'type': 'boolean'})
option_3 = StrOption(name="variable", doc="a variable", multi=True, properties=frozenset({"basic", "mandatory", Calculation(func['variable_to_property'], Params((ParamValue("disabled"), ParamOption(option_2)), kwargs={'__internal_multi': ParamValue(True), 'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['variable_to_property'])}), informations={'type': 'string'})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3], properties=frozenset({"basic"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -1,11 +0,0 @@
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 = BoolOption(name="condition", doc="a condition", default=False, properties=frozenset({"mandatory", "standard"}), informations={'type': 'boolean'})
option_2 = StrOption(name="variable", doc="a variable", multi=True, properties=frozenset({"basic", "mandatory", Calculation(func['variable_to_property'], Params((ParamValue("disabled"), ParamOption(option_1)), kwargs={'__internal_multi': ParamValue(True), 'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['variable_to_property'])}), informations={'type': 'string'})
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2])

View file

@ -1,35 +0,0 @@
{
"rougail.leader.leader": {
"owner": "default",
"value": [
"value1",
"value2"
]
},
"rougail.leader.follower1": {
"owner": [
"default",
"default"
],
"value": [
"val11",
"val11"
]
},
"rougail.leader.follower2": {
"owner": [
"default",
"default"
],
"value": [
"val21",
"val21"
]
},
"rougail.calculate": {
"owner": "default",
"value": [
"val11"
]
}
}

View file

@ -1,17 +0,0 @@
{
"rougail.leader.leader": [
{
"rougail.leader.leader": "value1",
"rougail.leader.follower1": "val11",
"rougail.leader.follower2": "val21"
},
{
"rougail.leader.leader": "value2",
"rougail.leader.follower1": "val11",
"rougail.leader.follower2": "val21"
}
],
"rougail.calculate": [
"val11"
]
}

View file

@ -1,35 +0,0 @@
{
"rougail.leader.leader": {
"owner": "default",
"value": [
"value1",
"value2"
]
},
"rougail.leader.follower1": {
"owner": [
"default",
"default"
],
"value": [
"val11",
"val11"
]
},
"rougail.leader.follower2": {
"owner": [
"default",
"default"
],
"value": [
"val21",
"val21"
]
},
"rougail.calculate": {
"owner": "default",
"value": [
"val11"
]
}
}

View file

@ -1,20 +0,0 @@
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")
dict_env['default_rougail.calculate'] = "{{ _.leader.follower1[0] }}"
option_3 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_4 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_5 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_2 = Leadership(name="leader", doc="a leadership", children=[option_3, option_4, option_5], properties=frozenset({"standard"}))
option_6 = StrOption(name="calculate", doc="a calculated variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_rougail.calculate"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['../rougail-tests/structures/40_9leadership-calculation-outside-follower-first/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("rougail.calculate"), '_.leader.follower1': ParamOption(option_4, notraisepropertyerror=True)})), properties=frozenset({"mandatory", "notunique", "standard"}), informations={'type': 'string'})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[optiondescription_2, option_6], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -1,15 +0,0 @@
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")
dict_env['default_calculate'] = "{{ _.leader.follower1[0] }}"
option_2 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_3 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_4 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_1 = Leadership(name="leader", doc="a leadership", children=[option_2, option_3, option_4], properties=frozenset({"standard"}))
option_5 = StrOption(name="calculate", doc="a calculated variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_calculate"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['../rougail-tests/structures/40_9leadership-calculation-outside-follower-first/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("calculate"), '_.leader.follower1': ParamOption(option_3, notraisepropertyerror=True)})), properties=frozenset({"mandatory", "notunique", "standard"}), informations={'type': 'string'})
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, option_5])

View file

@ -1,35 +0,0 @@
{
"rougail.leader.leader": {
"owner": "default",
"value": [
"value1",
"value2"
]
},
"rougail.leader.follower1": {
"owner": [
"default",
"default"
],
"value": [
"val11",
"val11"
]
},
"rougail.leader.follower2": {
"owner": [
"default",
"default"
],
"value": [
"val21",
"val21"
]
},
"rougail.calculate": {
"owner": "default",
"value": [
"val11"
]
}
}

View file

@ -1,17 +0,0 @@
{
"rougail.leader.leader": [
{
"rougail.leader.leader": "value1",
"rougail.leader.follower1": "val11",
"rougail.leader.follower2": "val21"
},
{
"rougail.leader.leader": "value2",
"rougail.leader.follower1": "val11",
"rougail.leader.follower2": "val21"
}
],
"rougail.calculate": [
"val11"
]
}

View file

@ -1,35 +0,0 @@
{
"rougail.leader.leader": {
"owner": "default",
"value": [
"value1",
"value2"
]
},
"rougail.leader.follower1": {
"owner": [
"default",
"default"
],
"value": [
"val11",
"val11"
]
},
"rougail.leader.follower2": {
"owner": [
"default",
"default"
],
"value": [
"val21",
"val21"
]
},
"rougail.calculate": {
"owner": "default",
"value": [
"val11"
]
}
}

View file

@ -1,20 +0,0 @@
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")
dict_env['default_rougail.calculate'] = "{{ _.leader.follower1[-1] }}"
option_3 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_4 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_5 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_2 = Leadership(name="leader", doc="a leadership", children=[option_3, option_4, option_5], properties=frozenset({"standard"}))
option_6 = StrOption(name="calculate", doc="a calculated variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_rougail.calculate"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['../rougail-tests/structures/40_9leadership-calculation-outside-follower-last/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("rougail.calculate"), '_.leader.follower1': ParamOption(option_4, notraisepropertyerror=True)})), properties=frozenset({"mandatory", "notunique", "standard"}), informations={'type': 'string'})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[optiondescription_2, option_6], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -1,15 +0,0 @@
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")
dict_env['default_calculate'] = "{{ _.leader.follower1[-1] }}"
option_2 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_3 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_4 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_1 = Leadership(name="leader", doc="a leadership", children=[option_2, option_3, option_4], properties=frozenset({"standard"}))
option_5 = StrOption(name="calculate", doc="a calculated variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_calculate"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['../rougail-tests/structures/40_9leadership-calculation-outside-follower-last/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("calculate"), '_.leader.follower1': ParamOption(option_3, notraisepropertyerror=True)})), properties=frozenset({"mandatory", "notunique", "standard"}), informations={'type': 'string'})
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, option_5])

View file

@ -1,36 +0,0 @@
{
"rougail.leader.leader": {
"owner": "default",
"value": [
"value1",
"value2"
]
},
"rougail.leader.follower1": {
"owner": [
"default",
"default"
],
"value": [
"val11",
"val11"
]
},
"rougail.leader.follower2": {
"owner": [
"default",
"default"
],
"value": [
"val21",
"val21"
]
},
"rougail.calculate": {
"owner": "default",
"value": [
"val11",
"val11"
]
}
}

View file

@ -1,18 +0,0 @@
{
"rougail.leader.leader": [
{
"rougail.leader.leader": "value1",
"rougail.leader.follower1": "val11",
"rougail.leader.follower2": "val21"
},
{
"rougail.leader.leader": "value2",
"rougail.leader.follower1": "val11",
"rougail.leader.follower2": "val21"
}
],
"rougail.calculate": [
"val11",
"val11"
]
}

View file

@ -1,36 +0,0 @@
{
"rougail.leader.leader": {
"owner": "default",
"value": [
"value1",
"value2"
]
},
"rougail.leader.follower1": {
"owner": [
"default",
"default"
],
"value": [
"val11",
"val11"
]
},
"rougail.leader.follower2": {
"owner": [
"default",
"default"
],
"value": [
"val21",
"val21"
]
},
"rougail.calculate": {
"owner": "default",
"value": [
"val11",
"val11"
]
}
}

View file

@ -1,19 +0,0 @@
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_3 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_4 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_5 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_2 = Leadership(name="leader", doc="a leadership", children=[option_3, option_4, option_5], properties=frozenset({"standard"}))
option_6 = StrOption(name="calculate", doc="a calculated variable", multi=True, default=Calculation(func['calc_value'], Params((ParamOption(option_4)), kwargs={'__internal_multi': ParamValue(True)})), properties=frozenset({"mandatory", "notunique", "standard"}), informations={'type': 'string'})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[optiondescription_2, option_6], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -1,14 +0,0 @@
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_2 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_3 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_4 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_1 = Leadership(name="leader", doc="a leadership", children=[option_2, option_3, option_4], properties=frozenset({"standard"}))
option_5 = StrOption(name="calculate", doc="a calculated variable", multi=True, default=Calculation(func['calc_value'], Params((ParamOption(option_3)), kwargs={'__internal_multi': ParamValue(True)})), properties=frozenset({"mandatory", "notunique", "standard"}), informations={'type': 'string'})
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, option_5])

View file

@ -1,33 +0,0 @@
{
"rougail.leader.leader": {
"owner": "default",
"value": [
"value1",
"value2"
]
},
"rougail.leader.follower1": {
"owner": [
"default",
"default"
],
"value": [
"val11",
"val11"
]
},
"rougail.leader.follower2": {
"owner": [
"default",
"default"
],
"value": [
"val21",
"val21"
]
},
"rougail.calculate": {
"owner": "default",
"value": "value1"
}
}

View file

@ -1,15 +0,0 @@
{
"rougail.leader.leader": [
{
"rougail.leader.leader": "value1",
"rougail.leader.follower1": "val11",
"rougail.leader.follower2": "val21"
},
{
"rougail.leader.leader": "value2",
"rougail.leader.follower1": "val11",
"rougail.leader.follower2": "val21"
}
],
"rougail.calculate": "value1"
}

View file

@ -1,33 +0,0 @@
{
"rougail.leader.leader": {
"owner": "default",
"value": [
"value1",
"value2"
]
},
"rougail.leader.follower1": {
"owner": [
"default",
"default"
],
"value": [
"val11",
"val11"
]
},
"rougail.leader.follower2": {
"owner": [
"default",
"default"
],
"value": [
"val21",
"val21"
]
},
"rougail.calculate": {
"owner": "default",
"value": "value1"
}
}

View file

@ -1,20 +0,0 @@
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")
dict_env['default_rougail.calculate'] = "{{ _.leader.leader[0] }}"
option_3 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_4 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_5 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_2 = Leadership(name="leader", doc="a leadership", children=[option_3, option_4, option_5], properties=frozenset({"standard"}))
option_6 = StrOption(name="calculate", doc="a calculated variable", default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_rougail.calculate"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/40_9leadership-calculation-outside-leader-first/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("rougail.calculate"), '_.leader.leader': ParamOption(option_3, notraisepropertyerror=True)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[optiondescription_2, option_6], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -1,15 +0,0 @@
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")
dict_env['default_calculate'] = "{{ _.leader.leader[0] }}"
option_2 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_3 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_4 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_1 = Leadership(name="leader", doc="a leadership", children=[option_2, option_3, option_4], properties=frozenset({"standard"}))
option_5 = StrOption(name="calculate", doc="a calculated variable", default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_calculate"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/40_9leadership-calculation-outside-leader-first/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("calculate"), '_.leader.leader': ParamOption(option_2, notraisepropertyerror=True)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, option_5])

View file

@ -1,33 +0,0 @@
{
"rougail.leader.leader": {
"owner": "default",
"value": [
"value1",
"value2"
]
},
"rougail.leader.follower1": {
"owner": [
"default",
"default"
],
"value": [
"val11",
"val11"
]
},
"rougail.leader.follower2": {
"owner": [
"default",
"default"
],
"value": [
"val21",
"val21"
]
},
"rougail.calculate": {
"owner": "default",
"value": "value2"
}
}

View file

@ -1,15 +0,0 @@
{
"rougail.leader.leader": [
{
"rougail.leader.leader": "value1",
"rougail.leader.follower1": "val11",
"rougail.leader.follower2": "val21"
},
{
"rougail.leader.leader": "value2",
"rougail.leader.follower1": "val11",
"rougail.leader.follower2": "val21"
}
],
"rougail.calculate": "value2"
}

View file

@ -1,33 +0,0 @@
{
"rougail.leader.leader": {
"owner": "default",
"value": [
"value1",
"value2"
]
},
"rougail.leader.follower1": {
"owner": [
"default",
"default"
],
"value": [
"val11",
"val11"
]
},
"rougail.leader.follower2": {
"owner": [
"default",
"default"
],
"value": [
"val21",
"val21"
]
},
"rougail.calculate": {
"owner": "default",
"value": "value2"
}
}

View file

@ -1,20 +0,0 @@
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")
dict_env['default_rougail.calculate'] = "{{ _.leader.leader[-1] }}"
option_3 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_4 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_5 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_2 = Leadership(name="leader", doc="a leadership", children=[option_3, option_4, option_5], properties=frozenset({"standard"}))
option_6 = StrOption(name="calculate", doc="a calculated variable", default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_rougail.calculate"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/40_9leadership-calculation-outside-leader-last/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("rougail.calculate"), '_.leader.leader': ParamOption(option_3, notraisepropertyerror=True)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[optiondescription_2, option_6], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -1,15 +0,0 @@
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")
dict_env['default_calculate'] = "{{ _.leader.leader[-1] }}"
option_2 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_3 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_4 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_1 = Leadership(name="leader", doc="a leadership", children=[option_2, option_3, option_4], properties=frozenset({"standard"}))
option_5 = StrOption(name="calculate", doc="a calculated variable", default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_calculate"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/40_9leadership-calculation-outside-leader-last/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("calculate"), '_.leader.leader': ParamOption(option_2, notraisepropertyerror=True)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, option_5])

View file

@ -1,36 +0,0 @@
{
"rougail.leader.leader": {
"owner": "default",
"value": [
"value1",
"value2"
]
},
"rougail.leader.follower1": {
"owner": [
"default",
"default"
],
"value": [
"val11",
"val11"
]
},
"rougail.leader.follower2": {
"owner": [
"default",
"default"
],
"value": [
"val21",
"val21"
]
},
"rougail.calculate": {
"owner": "default",
"value": [
"value1",
"value2"
]
}
}

View file

@ -1,18 +0,0 @@
{
"rougail.leader.leader": [
{
"rougail.leader.leader": "value1",
"rougail.leader.follower1": "val11",
"rougail.leader.follower2": "val21"
},
{
"rougail.leader.leader": "value2",
"rougail.leader.follower1": "val11",
"rougail.leader.follower2": "val21"
}
],
"rougail.calculate": [
"value1",
"value2"
]
}

View file

@ -1,36 +0,0 @@
{
"rougail.leader.leader": {
"owner": "default",
"value": [
"value1",
"value2"
]
},
"rougail.leader.follower1": {
"owner": [
"default",
"default"
],
"value": [
"val11",
"val11"
]
},
"rougail.leader.follower2": {
"owner": [
"default",
"default"
],
"value": [
"val21",
"val21"
]
},
"rougail.calculate": {
"owner": "default",
"value": [
"value1",
"value2"
]
}
}

View file

@ -1,19 +0,0 @@
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_3 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_4 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_5 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_2 = Leadership(name="leader", doc="a leadership", children=[option_3, option_4, option_5], properties=frozenset({"standard"}))
option_6 = StrOption(name="calculate", doc="a calculated variable", multi=True, default=Calculation(func['calc_value'], Params((ParamOption(option_3)), kwargs={'__internal_multi': ParamValue(True)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[optiondescription_2, option_6], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -1,14 +0,0 @@
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_2 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_3 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_4 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_1 = Leadership(name="leader", doc="a leadership", children=[option_2, option_3, option_4], properties=frozenset({"standard"}))
option_5 = StrOption(name="calculate", doc="a calculated variable", multi=True, default=Calculation(func['calc_value'], Params((ParamOption(option_2)), kwargs={'__internal_multi': ParamValue(True)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, option_5])

View file

@ -119,7 +119,7 @@ def launch_flattener(test_dir,
mkdir(makedict_dir) mkdir(makedict_dir)
config_dict = dict(option_value(config.value.get())) config_dict = dict(option_value(config.value.get()))
if not isfile(Path(test_dir) / 'tiramisu' / 'base.py'): if not isfile(Path(test_dir) / 'tiramisu' / 'base.py'):
tconfig_dict = config_add_rougail(config_dict) tconfig_dict = {f'rougail.{path}': value for path, value in config_dict.items()}
else: else:
tconfig_dict = config_dict tconfig_dict = config_dict
if not isfile(makedict_file) or debug: if not isfile(makedict_file) or debug:
@ -127,7 +127,7 @@ def launch_flattener(test_dir,
dump(tconfig_dict, fh, indent=4) dump(tconfig_dict, fh, indent=4)
fh.write('\n') fh.write('\n')
if filename == 'no_namespace': if filename == 'no_namespace':
config_dict = config_add_rougail(config_dict) config_dict = {f'rougail.{path}': value for path, value in config_dict.items()}
elif filename != 'base': elif filename != 'base':
config_dict_prefix = {'1': {}, '2': {}} config_dict_prefix = {'1': {}, '2': {}}
for key, value in config_dict.items(): for key, value in config_dict.items():
@ -165,18 +165,6 @@ def launch_flattener(test_dir,
mandatory(test_dir, mandatory_file, config.value.mandatory(), filename) mandatory(test_dir, mandatory_file, config.value.mandatory(), filename)
def config_add_rougail(config):
config_dict = {}
for path, value in config.items():
if value and isinstance(value, list) and isinstance(value[0], dict):
config_dict[f'rougail.{path}'] = []
for v in value:
config_dict[f'rougail.{path}'].append({f'rougail.{k}': w for k, w in v.items()})
else:
config_dict[f'rougail.{path}'] = value
return config_dict
def value_owner(test_dir, makedict_value_owner, config, filename): def value_owner(test_dir, makedict_value_owner, config, filename):
ret = {} ret = {}
for key, value in option_value(config.value.get(), True): for key, value in option_value(config.value.get(), True):
@ -201,7 +189,7 @@ def value_owner(test_dir, makedict_value_owner, config, filename):
'value': value, 'value': value,
} }
if not isfile(Path(test_dir) / 'tiramisu' / 'base.py'): if not isfile(Path(test_dir) / 'tiramisu' / 'base.py'):
tret = config_add_rougail(ret) tret = {f'rougail.{path}': value for path, value in ret.items()}
else: else:
tret = ret tret = ret
if not isfile(makedict_value_owner) or debug: if not isfile(makedict_value_owner) or debug:
@ -209,7 +197,7 @@ def value_owner(test_dir, makedict_value_owner, config, filename):
dump(tret, fh, indent=4) dump(tret, fh, indent=4)
fh.write('\n') fh.write('\n')
if filename == 'no_namespace': if filename == 'no_namespace':
ret = config_add_rougail(ret) ret = {f'rougail.{path}': value for path, value in ret.items()}
elif filename != 'base': elif filename != 'base':
ret_prefix = {'1': {}, '2': {}} ret_prefix = {'1': {}, '2': {}}
for key, value in ret.items(): for key, value in ret.items():

View file

@ -56,17 +56,3 @@ def test_personalize_annotate_twice():
with raises(DictConsistencyError) as err: with raises(DictConsistencyError) as err:
eolobj.converted.annotate() eolobj.converted.annotate()
assert err.value.errno == 85 assert err.value.errno == 85
def test_option_params():
RougailConfig['dictionaries_dir'] = ['tests/default_option_params/structure']
RougailConfig["default_params.unix_filename.test_existence"] = True
eolobj = Rougail()
with raises(ValueError):
eolobj.get_config()
eolobj = Rougail()
with raises(ValueError):
eolobj.get_config()
RougailConfig["default_params.unix_filename.test_existence"] = False
eolobj = Rougail()
eolobj.get_config()