add information in tiramisu option for doc
This commit is contained in:
parent
560deb52b6
commit
c6644231c9
3458 changed files with 14278 additions and 23526 deletions
|
@ -45,7 +45,7 @@ def get_annotators(annotators, module_name):
|
||||||
path = str(pathobj)
|
path = str(pathobj)
|
||||||
if not path.endswith(".py") or path.endswith("__.py"):
|
if not path.endswith(".py") or path.endswith("__.py"):
|
||||||
continue
|
continue
|
||||||
module = load_modules(path)
|
module = load_modules(module_name, path)
|
||||||
if "Annotator" not in dir(module):
|
if "Annotator" not in dir(module):
|
||||||
continue
|
continue
|
||||||
annotators[module_name].append(module.Annotator)
|
annotators[module_name].append(module.Annotator)
|
||||||
|
@ -71,12 +71,10 @@ class SpaceAnnotator: # pylint: disable=R0903
|
||||||
annotators.extend(ANNOTATORS[extra_annotator])
|
annotators.extend(ANNOTATORS[extra_annotator])
|
||||||
annotators = sorted(annotators, key=get_level)
|
annotators = sorted(annotators, key=get_level)
|
||||||
functions = {}
|
functions = {}
|
||||||
functions_files = objectspace.rougailconfig["functions_file"]
|
functions_files = objectspace.rougailconfig["functions_files"]
|
||||||
if not isinstance(functions_files, list):
|
|
||||||
functions_files = [functions_files]
|
|
||||||
for functions_file in functions_files:
|
for functions_file in functions_files:
|
||||||
if isfile(functions_file):
|
if isfile(functions_file):
|
||||||
loaded_modules = load_modules(functions_file)
|
loaded_modules = load_modules('function_file', functions_file)
|
||||||
for function in dir(loaded_modules):
|
for function in dir(loaded_modules):
|
||||||
if function.startswith("_"):
|
if function.startswith("_"):
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -93,7 +93,7 @@ class Annotator(Walk):
|
||||||
if isinstance(family, self.objectspace.family) and not self._has_variable(
|
if isinstance(family, self.objectspace.family) and not self._has_variable(
|
||||||
family.path
|
family.path
|
||||||
):
|
):
|
||||||
if "." in family.path:
|
if self.objectspace.paths.default_namespace is None or "." in family.path:
|
||||||
removed_families.append(family.path)
|
removed_families.append(family.path)
|
||||||
removed_families.reverse()
|
removed_families.reverse()
|
||||||
for family in removed_families:
|
for family in removed_families:
|
||||||
|
@ -141,6 +141,12 @@ class Annotator(Walk):
|
||||||
families.reverse()
|
families.reverse()
|
||||||
for family in families:
|
for family in families:
|
||||||
self._change_family_mode(family)
|
self._change_family_mode(family)
|
||||||
|
if self.objectspace.paths.default_namespace is None:
|
||||||
|
for variable_path in self.objectspace.parents['.']:
|
||||||
|
variable = self.objectspace.paths[variable_path]
|
||||||
|
if variable.type == "symlink" or variable_path in self.objectspace.families:
|
||||||
|
continue
|
||||||
|
self._change_variable_mode(variable, default_variable_mode, False)
|
||||||
|
|
||||||
def valid_mode(
|
def valid_mode(
|
||||||
self,
|
self,
|
||||||
|
@ -314,21 +320,6 @@ class Annotator(Walk):
|
||||||
if not variable.mode:
|
if not variable.mode:
|
||||||
variable.mode = variable_mode
|
variable.mode = variable_mode
|
||||||
|
|
||||||
def dynamic_families(self):
|
|
||||||
"""link dynamic families to object"""
|
|
||||||
for family in self.get_families():
|
|
||||||
if family.type != "dynamic":
|
|
||||||
continue
|
|
||||||
for variable in self.objectspace.parents[family.path]:
|
|
||||||
if (
|
|
||||||
isinstance(variable, self.objectspace.family)
|
|
||||||
and not variable.leadership
|
|
||||||
):
|
|
||||||
msg = _(
|
|
||||||
f'dynamic family "{family.name}" cannot contains another family'
|
|
||||||
)
|
|
||||||
raise DictConsistencyError(msg, 22, family.xmlfiles)
|
|
||||||
|
|
||||||
def convert_help(self):
|
def convert_help(self):
|
||||||
"""Convert variable help"""
|
"""Convert variable help"""
|
||||||
for family in self.get_families():
|
for family in self.get_families():
|
||||||
|
|
|
@ -112,21 +112,21 @@ class Annotator(Walk):
|
||||||
self._convert_property(variable)
|
self._convert_property(variable)
|
||||||
if variable.hidden:
|
if variable.hidden:
|
||||||
if variable.hidden is True:
|
if variable.hidden is True:
|
||||||
self.frozen[variable.path] = True
|
self.frozen[path] = True
|
||||||
elif self.frozen.get(variable.path) is not True:
|
elif self.frozen.get(path) is not True:
|
||||||
self.frozen.setdefault(variable.path, []).append(variable.hidden)
|
self.frozen.setdefault(path, []).append(variable.hidden)
|
||||||
if variable.path in self.frozen:
|
if path in self.frozen:
|
||||||
frozen = self.frozen[variable.path]
|
frozen = self.frozen[path]
|
||||||
if frozen is True:
|
if frozen is True:
|
||||||
value = True
|
value = True
|
||||||
else:
|
else:
|
||||||
value = []
|
value = []
|
||||||
for calculation in frozen:
|
for calculation in frozen:
|
||||||
calculation_object = calculation.__class__
|
calculation_copy = calculation.copy()
|
||||||
calculation_dict = calculation.model_dump().copy()
|
calculation_copy.attribute_name = 'frozen'
|
||||||
calculation_dict["attribute_name"] = "frozen"
|
calculation_copy.ori_path = calculation_copy.path
|
||||||
calculation_dict["path"] = variable.path
|
calculation_copy.path = path
|
||||||
value.append(calculation_object(**calculation_dict))
|
value.append(calculation_copy)
|
||||||
if len(value) == 1:
|
if len(value) == 1:
|
||||||
value = value[0]
|
value = value[0]
|
||||||
self.objectspace.properties.add(path, "frozen", value)
|
self.objectspace.properties.add(path, "frozen", value)
|
||||||
|
@ -142,7 +142,7 @@ class Annotator(Walk):
|
||||||
if variable.unique is False:
|
if variable.unique is False:
|
||||||
self.objectspace.properties.add(path, "notunique", True)
|
self.objectspace.properties.add(path, "notunique", True)
|
||||||
if variable.auto_save:
|
if variable.auto_save:
|
||||||
self.objectspace.properties.add(variable.path, "force_store_value", True)
|
self.objectspace.properties.add(path, "force_store_value", True)
|
||||||
|
|
||||||
def _convert_property(
|
def _convert_property(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -65,12 +65,14 @@ class Annotator(Walk): # pylint: disable=R0903
|
||||||
if not objectspace.paths:
|
if not objectspace.paths:
|
||||||
return
|
return
|
||||||
self.objectspace = objectspace
|
self.objectspace = objectspace
|
||||||
|
if self.objectspace.rougailconfig["main_namespace"]:
|
||||||
self.forbidden_name = [
|
self.forbidden_name = [
|
||||||
"services",
|
self.objectspace.rougailconfig["main_namespace"]
|
||||||
self.objectspace.rougailconfig["variable_namespace"],
|
|
||||||
]
|
]
|
||||||
for extra in self.objectspace.rougailconfig["extra_dictionaries"]:
|
for extra in self.objectspace.rougailconfig["extra_dictionaries"]:
|
||||||
self.forbidden_name.append(extra)
|
self.forbidden_name.append(extra)
|
||||||
|
else:
|
||||||
|
self.forbidden_name = []
|
||||||
# default type inference from a default value with :term:`basic types`
|
# default type inference from a default value with :term:`basic types`
|
||||||
self.basic_types = {str: "string", int: "number", bool: "boolean", float: "float"}
|
self.basic_types = {str: "string", int: "number", bool: "boolean", float: "float"}
|
||||||
self.convert_variable()
|
self.convert_variable()
|
||||||
|
|
|
@ -28,52 +28,287 @@ You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
"""
|
"""
|
||||||
from os.path import abspath, dirname, join
|
from pathlib import Path
|
||||||
|
from tiramisu import OptionDescription, Leadership, \
|
||||||
ROUGAILROOT = "/srv/rougail"
|
StrOption, BoolOption, ChoiceOption, FilenameOption, \
|
||||||
DTDDIR = join(dirname(abspath(__file__)), "data")
|
Config, calc_value, \
|
||||||
|
Calculation, Params, ParamOption, ParamSelfOption, ParamValue, submulti
|
||||||
|
from .utils import _, load_modules, normalize_family
|
||||||
|
|
||||||
|
|
||||||
RougailConfig = {
|
RENAMED = {'dictionaries_dir': 'main_dictionaries',
|
||||||
"default_dictionary_format_version": None,
|
'variable_namespace': 'main_namespace',
|
||||||
"dictionaries_dir": [join(ROUGAILROOT, "dictionaries")],
|
'functions_file': 'functions_files',
|
||||||
"extra_dictionaries": {},
|
|
||||||
"services_dir": [join(ROUGAILROOT, "services")],
|
|
||||||
"patches_dir": join(ROUGAILROOT, "patches"),
|
|
||||||
"templates_dir": join(ROUGAILROOT, "templates"),
|
|
||||||
"destinations_dir": join(ROUGAILROOT, "destinations"),
|
|
||||||
"tmp_dir": join(ROUGAILROOT, "tmp"),
|
|
||||||
"functions_file": join(ROUGAILROOT, "functions.py"),
|
|
||||||
"system_service_directory": "/usr/lib/systemd/system",
|
|
||||||
"systemd_service_destination_directory": "/usr/local/lib",
|
|
||||||
"systemd_service_directory": "/systemd",
|
|
||||||
"systemd_service_file": "rougail.conf",
|
|
||||||
"systemd_service_ip_file": "rougail_ip.conf",
|
|
||||||
"systemd_tmpfile_factory_dir": "/usr/local/lib",
|
|
||||||
"systemd_tmpfile_directory": "/tmpfiles.d",
|
|
||||||
"systemd_tmpfile_file": "0rougail.conf",
|
|
||||||
"systemd_tmpfile_delete_before_create": False,
|
|
||||||
"variable_namespace": "rougail",
|
|
||||||
"variable_namespace_description": "Rougail",
|
|
||||||
"auto_freeze_variable": "server_deployed",
|
|
||||||
"internal_functions": [],
|
|
||||||
"multi_functions": [],
|
|
||||||
"extra_annotators": [],
|
|
||||||
"modes_level": ["basic", "standard", "advanced"],
|
|
||||||
"default_family_mode": "basic",
|
|
||||||
"default_variable_mode": "standard",
|
|
||||||
"default_files_engine": "jinja",
|
|
||||||
"default_files_mode": 644,
|
|
||||||
"default_files_owner": "root",
|
|
||||||
"default_files_group": "root",
|
|
||||||
"default_files_included": "no",
|
|
||||||
"default_overrides_engine": "jinja",
|
|
||||||
"default_service_names_engine": "none",
|
|
||||||
"default_certificate_domain": "rougail.server_name",
|
|
||||||
"base_option_name": "baseoption",
|
|
||||||
"export_with_import": True,
|
|
||||||
"force_convert_dyn_option_description": False,
|
|
||||||
"suffix": "",
|
|
||||||
"tiramisu_cache": None,
|
|
||||||
"custom_types": {},
|
|
||||||
}
|
}
|
||||||
|
NOT_IN_TIRAMISU = {'custom_types': {},
|
||||||
|
}
|
||||||
|
SUBMODULES = None
|
||||||
|
|
||||||
|
|
||||||
|
def get_sub_modules():
|
||||||
|
global SUBMODULES
|
||||||
|
if SUBMODULES is None:
|
||||||
|
SUBMODULES = {}
|
||||||
|
for submodule in Path(__file__).parent.iterdir():
|
||||||
|
if submodule.name.startswith('_') or not submodule.is_dir():
|
||||||
|
continue
|
||||||
|
config_file = submodule / 'config.py'
|
||||||
|
if config_file.is_file():
|
||||||
|
SUBMODULES[submodule.name] = load_modules('rougail.' + submodule.name + '.config', str(config_file))
|
||||||
|
return SUBMODULES
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def get_in_list(lst, index):
|
||||||
|
if not lst:
|
||||||
|
return None
|
||||||
|
if index > len(lst):
|
||||||
|
index = 0
|
||||||
|
return lst[index]
|
||||||
|
|
||||||
|
|
||||||
|
def validator_modes(mode, modes, typ):
|
||||||
|
if mode not in modes:
|
||||||
|
raise ValueError(f'cannot find "{mode}" in modes_level ({modes}) for {typ}')
|
||||||
|
|
||||||
|
|
||||||
|
def get_level(module):
|
||||||
|
return module['level']
|
||||||
|
|
||||||
|
|
||||||
|
class _RougailConfig:
|
||||||
|
def __init__(self,
|
||||||
|
backward_compatibility: bool,
|
||||||
|
config,
|
||||||
|
):
|
||||||
|
self.backward_compatibility = backward_compatibility
|
||||||
|
self.config = config
|
||||||
|
for variable, default_value in NOT_IN_TIRAMISU.items():
|
||||||
|
if not isinstance(default_value, str):
|
||||||
|
default_value = default_value.copy()
|
||||||
|
setattr(self, variable, default_value)
|
||||||
|
|
||||||
|
def copy(self):
|
||||||
|
rougailconfig = get_rougail_config(backward_compatibility=self.backward_compatibility)
|
||||||
|
rougailconfig.config.value.importation(self.config.value.exportation())
|
||||||
|
rougailconfig.config.property.importation(self.config.property.exportation())
|
||||||
|
rougailconfig.config.property.read_only()
|
||||||
|
for variable in NOT_IN_TIRAMISU:
|
||||||
|
value = getattr(self, variable)
|
||||||
|
if not isinstance(value, str):
|
||||||
|
value = value.copy()
|
||||||
|
setattr(rougailconfig, variable, value)
|
||||||
|
return rougailconfig
|
||||||
|
|
||||||
|
def __setitem__(self,
|
||||||
|
key,
|
||||||
|
value,
|
||||||
|
) -> None:
|
||||||
|
if key in NOT_IN_TIRAMISU:
|
||||||
|
setattr(self, key, value)
|
||||||
|
else:
|
||||||
|
self.config.property.read_write()
|
||||||
|
if key == 'export_with_import':
|
||||||
|
key = 'not_export_with_import'
|
||||||
|
key = RENAMED.get(key, key)
|
||||||
|
option = self.config.option(key)
|
||||||
|
if option.isoptiondescription() and option.isleadership():
|
||||||
|
leader = list(value)
|
||||||
|
option.leader().value.set(leader)
|
||||||
|
follower = option.followers()[0]
|
||||||
|
for idx, val in enumerate(value.values()):
|
||||||
|
self.config.option(follower.path(), idx).value.set(val)
|
||||||
|
elif key == 'not_export_with_import':
|
||||||
|
option.value.set(not value)
|
||||||
|
else:
|
||||||
|
option.value.set(value)
|
||||||
|
self.config.property.read_only()
|
||||||
|
|
||||||
|
def __getitem__(self,
|
||||||
|
key,
|
||||||
|
) -> None:
|
||||||
|
if key in NOT_IN_TIRAMISU:
|
||||||
|
return getattr(self, key)
|
||||||
|
if key == 'export_with_import':
|
||||||
|
key = 'not_export_with_import'
|
||||||
|
option = self.config.option(key)
|
||||||
|
if option.isoptiondescription() and option.isleadership():
|
||||||
|
return self.get_leadership(option)
|
||||||
|
ret = self.config.option(key).value.get()
|
||||||
|
if key == 'not_export_with_import':
|
||||||
|
return not ret
|
||||||
|
return ret
|
||||||
|
|
||||||
|
def get_leadership(self,
|
||||||
|
option
|
||||||
|
) -> dict:
|
||||||
|
leader, *followers = option.value.get().values()
|
||||||
|
return dict(zip(leader, followers))
|
||||||
|
|
||||||
|
|
||||||
|
def get_rougail_config(*,
|
||||||
|
backward_compatibility=True,
|
||||||
|
) -> _RougailConfig:
|
||||||
|
default_dictionary_format_version = ChoiceOption('default_dictionary_format_version',
|
||||||
|
_('Dictionary format version by default, if not specified in dictionary file'),
|
||||||
|
('1.0', '1.1'),
|
||||||
|
)
|
||||||
|
main_dictionaries = FilenameOption('main_dictionaries',
|
||||||
|
_('Directories where dictionary files are placed'),
|
||||||
|
multi=True,
|
||||||
|
properties=('mandatory',),
|
||||||
|
allow_relative=True,
|
||||||
|
test_existence=True,
|
||||||
|
types=['directory'],
|
||||||
|
)
|
||||||
|
if backward_compatibility:
|
||||||
|
main_namespace_default = 'rougail'
|
||||||
|
else:
|
||||||
|
main_namespace_default = None
|
||||||
|
main_namespace = StrOption('main_namespace',
|
||||||
|
_('Main namespace name'),
|
||||||
|
default=main_namespace_default,
|
||||||
|
)
|
||||||
|
extra_dictionaries = Leadership('extra_dictionaries',
|
||||||
|
_('Extra namespaces'),
|
||||||
|
[StrOption('names',
|
||||||
|
_('Extra namespace name'),
|
||||||
|
multi=True,
|
||||||
|
),
|
||||||
|
FilenameOption('directory_extra',
|
||||||
|
_('Directories where extra dictionary files are placed'),
|
||||||
|
multi=submulti,
|
||||||
|
properties=('mandatory',),
|
||||||
|
allow_relative=True,
|
||||||
|
test_existence=True,
|
||||||
|
types=['directory'],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
properties=('mandatory',
|
||||||
|
Calculation(calc_value,
|
||||||
|
Params(ParamValue('disabled'),
|
||||||
|
kwargs={'condition': ParamOption(main_namespace),
|
||||||
|
'expected': ParamValue(None)})),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
functions_files = FilenameOption('functions_files',
|
||||||
|
_('File with functions'),
|
||||||
|
multi=True,
|
||||||
|
allow_relative=True,
|
||||||
|
test_existence=True,
|
||||||
|
types=['file'],
|
||||||
|
)
|
||||||
|
modes_level = StrOption('modes_level',
|
||||||
|
_('All modes level available'),
|
||||||
|
default=["basic", "standard", "advanced"],
|
||||||
|
multi=True,
|
||||||
|
properties=('mandatory', 'not_for_commandline'),
|
||||||
|
)
|
||||||
|
default_family_mode = StrOption('default_family_mode',
|
||||||
|
_('Default mode for a family'),
|
||||||
|
default=Calculation(get_in_list, Params((ParamOption(modes_level), ParamValue(0)))),
|
||||||
|
validators=[Calculation(validator_modes, Params((ParamSelfOption(), ParamOption(modes_level), ParamValue('default_family_mode'))))],
|
||||||
|
properties=('mandatory', 'not_for_commandline'),
|
||||||
|
)
|
||||||
|
default_variable_mode = StrOption('default_variable_mode',
|
||||||
|
_('Default mode for a variable'),
|
||||||
|
default=Calculation(get_in_list, Params((ParamOption(modes_level), ParamValue(1)))),
|
||||||
|
validators=[Calculation(validator_modes, Params((ParamSelfOption(), ParamOption(modes_level), ParamValue('default_variable_mode'))))],
|
||||||
|
properties=('mandatory', 'not_for_commandline'),
|
||||||
|
)
|
||||||
|
base_option_name = StrOption('base_option_name',
|
||||||
|
_('Option name for the base option'),
|
||||||
|
default="baseoption",
|
||||||
|
properties=('mandatory', 'not_for_commandline'),
|
||||||
|
)
|
||||||
|
not_export_with_import = BoolOption('not_export_with_import',
|
||||||
|
_('In cache file, do not importation of Tiramisu and other dependencies'),
|
||||||
|
default=False,
|
||||||
|
properties=('mandatory', 'not_for_commandline'),
|
||||||
|
)
|
||||||
|
tiramisu_cache = StrOption('tiramisu_cache',
|
||||||
|
_('Tiramisu cache filename'),
|
||||||
|
)
|
||||||
|
internal_functions = StrOption('internal_functions',
|
||||||
|
_('Name of internal functions that we can use as a function'),
|
||||||
|
properties=('not_for_commandline',),
|
||||||
|
multi=True,
|
||||||
|
)
|
||||||
|
extra_annotators = StrOption('extra_annotators',
|
||||||
|
_('Name of extra annotators'),
|
||||||
|
properties=('not_for_commandline',),
|
||||||
|
multi=True,
|
||||||
|
)
|
||||||
|
suffix = StrOption('suffix',
|
||||||
|
_('Suffix add to generated option name'),
|
||||||
|
default='',
|
||||||
|
properties=('not_for_commandline',),
|
||||||
|
)
|
||||||
|
|
||||||
|
options = [default_dictionary_format_version,
|
||||||
|
main_dictionaries,
|
||||||
|
main_namespace,
|
||||||
|
extra_dictionaries,
|
||||||
|
functions_files,
|
||||||
|
modes_level,
|
||||||
|
default_family_mode,
|
||||||
|
default_variable_mode,
|
||||||
|
base_option_name,
|
||||||
|
not_export_with_import,
|
||||||
|
tiramisu_cache,
|
||||||
|
internal_functions,
|
||||||
|
extra_annotators,
|
||||||
|
suffix,
|
||||||
|
]
|
||||||
|
processes = {# 'structural': [],
|
||||||
|
'user data': [],
|
||||||
|
'output': [],
|
||||||
|
}
|
||||||
|
|
||||||
|
for module in get_sub_modules().values():
|
||||||
|
data = module.get_rougail_config()
|
||||||
|
processes[data['process']].append(data)
|
||||||
|
for process in processes:
|
||||||
|
if processes[process]:
|
||||||
|
objects = [obj['name'] for obj in sorted(processes[process], key=get_level)]
|
||||||
|
default = objects[0]
|
||||||
|
if process == 'output':
|
||||||
|
properties = ('mandatory',)
|
||||||
|
else:
|
||||||
|
objects.insert(0, None)
|
||||||
|
properties = tuple()
|
||||||
|
option = ChoiceOption(normalize_family(process),
|
||||||
|
f'Select the {process}',
|
||||||
|
default=default,
|
||||||
|
values=tuple(objects),
|
||||||
|
properties=properties,
|
||||||
|
)
|
||||||
|
options.append(option)
|
||||||
|
for obj in processes[process]:
|
||||||
|
od = OptionDescription(obj['name'],
|
||||||
|
obj['description'],
|
||||||
|
obj['options'],
|
||||||
|
properties=(Calculation(calc_value,
|
||||||
|
Params(ParamValue('disabled'),
|
||||||
|
kwargs={'condition': ParamOption(option),
|
||||||
|
'reverse_condition': ParamValue(True),
|
||||||
|
'expected': ParamValue(obj['name'])})),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
options.append(od)
|
||||||
|
else:
|
||||||
|
options.append(StrOption(normalize_family(process),
|
||||||
|
f'Select the {process}',
|
||||||
|
properties=('hidden',),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
root = OptionDescription('root',
|
||||||
|
'root',
|
||||||
|
options,
|
||||||
|
)
|
||||||
|
config = Config(root)
|
||||||
|
config.property.read_only()
|
||||||
|
return _RougailConfig(backward_compatibility, config)
|
||||||
|
|
||||||
|
|
||||||
|
RougailConfig = get_rougail_config()
|
||||||
|
|
|
@ -47,6 +47,10 @@ from typing import (
|
||||||
from pydantic import ValidationError
|
from pydantic import ValidationError
|
||||||
from ruamel.yaml import YAML
|
from ruamel.yaml import YAML
|
||||||
from ruamel.yaml.comments import CommentedMap
|
from ruamel.yaml.comments import CommentedMap
|
||||||
|
from pydantic import ValidationError
|
||||||
|
|
||||||
|
from warnings import warn
|
||||||
|
|
||||||
from tiramisu.error import display_list
|
from tiramisu.error import display_list
|
||||||
|
|
||||||
from .annotator import SpaceAnnotator
|
from .annotator import SpaceAnnotator
|
||||||
|
@ -65,7 +69,8 @@ from .object_model import (
|
||||||
VariableCalculation,
|
VariableCalculation,
|
||||||
)
|
)
|
||||||
from .tiramisureflector import TiramisuReflector
|
from .tiramisureflector import TiramisuReflector
|
||||||
from .utils import get_realpath
|
from .utils import get_realpath, normalize_family
|
||||||
|
from .error import DictConsistencyError
|
||||||
|
|
||||||
property_types = Union[Literal[True], Calculation]
|
property_types = Union[Literal[True], Calculation]
|
||||||
properties_types = Dict[str, property_types]
|
properties_types = Dict[str, property_types]
|
||||||
|
@ -97,7 +102,7 @@ class Property:
|
||||||
|
|
||||||
|
|
||||||
class Paths:
|
class Paths:
|
||||||
_regexp_relative = compile(r"^_*\.(.*)$")
|
regexp_relative = compile(r"^_*\.(.*)$")
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -105,6 +110,8 @@ class Paths:
|
||||||
) -> None:
|
) -> None:
|
||||||
self._data: Dict[str, Union[Variable, Family]] = {}
|
self._data: Dict[str, Union[Variable, Family]] = {}
|
||||||
self._dynamics: Dict[str:str] = {}
|
self._dynamics: Dict[str:str] = {}
|
||||||
|
if default_namespace is not None:
|
||||||
|
default_namespace = normalize_family(default_namespace)
|
||||||
self.default_namespace = default_namespace
|
self.default_namespace = default_namespace
|
||||||
self.path_prefix = None
|
self.path_prefix = None
|
||||||
|
|
||||||
|
@ -124,6 +131,18 @@ class Paths:
|
||||||
if not force and is_dynamic:
|
if not force and is_dynamic:
|
||||||
self._dynamics[path] = dynamic
|
self._dynamics[path] = dynamic
|
||||||
|
|
||||||
|
def get_relative_path(self,
|
||||||
|
path: str,
|
||||||
|
current_path: str,
|
||||||
|
):
|
||||||
|
relative, subpath = path.split(".", 1)
|
||||||
|
relative_len = len(relative)
|
||||||
|
path_len = current_path.count(".")
|
||||||
|
if path_len + 1 == relative_len:
|
||||||
|
return subpath
|
||||||
|
parent_path = current_path.rsplit(".", relative_len)[0]
|
||||||
|
return parent_path + "." + subpath
|
||||||
|
|
||||||
def get_with_dynamic(
|
def get_with_dynamic(
|
||||||
self,
|
self,
|
||||||
path: str,
|
path: str,
|
||||||
|
@ -134,12 +153,10 @@ class Paths:
|
||||||
xmlfiles: List[str],
|
xmlfiles: List[str],
|
||||||
) -> Any:
|
) -> Any:
|
||||||
suffix = None
|
suffix = None
|
||||||
if version != "1.0" and self._regexp_relative.search(path):
|
if version != '1.0' and self.regexp_relative.search(path):
|
||||||
relative, subpath = path.split(".", 1)
|
path = self.get_relative_path(path,
|
||||||
relative_len = len(relative)
|
current_path,
|
||||||
path_len = current_path.count(".")
|
)
|
||||||
parent_path = current_path.rsplit(".", relative_len)[0]
|
|
||||||
path = parent_path + "." + subpath
|
|
||||||
else:
|
else:
|
||||||
path = get_realpath(path, suffix_path)
|
path = get_realpath(path, suffix_path)
|
||||||
dynamic = None
|
dynamic = None
|
||||||
|
@ -159,7 +176,11 @@ class Paths:
|
||||||
new_path = name
|
new_path = name
|
||||||
continue
|
continue
|
||||||
for dynamic_path in self._dynamics:
|
for dynamic_path in self._dynamics:
|
||||||
|
if '.' in dynamic_path:
|
||||||
parent_dynamic, name_dynamic = dynamic_path.rsplit(".", 1)
|
parent_dynamic, name_dynamic = dynamic_path.rsplit(".", 1)
|
||||||
|
else:
|
||||||
|
parent_dynamic = None
|
||||||
|
name_dynamic = dynamic_path
|
||||||
if (
|
if (
|
||||||
version == "1.0"
|
version == "1.0"
|
||||||
and parent_dynamic == parent_path
|
and parent_dynamic == parent_path
|
||||||
|
@ -192,7 +213,11 @@ class Paths:
|
||||||
new_path = name
|
new_path = name
|
||||||
continue
|
continue
|
||||||
for dynamic_path in self._dynamics:
|
for dynamic_path in self._dynamics:
|
||||||
|
if '.' in dynamic_path:
|
||||||
parent_dynamic, name_dynamic = dynamic_path.rsplit(".", 1)
|
parent_dynamic, name_dynamic = dynamic_path.rsplit(".", 1)
|
||||||
|
else:
|
||||||
|
parent_dynamic = None
|
||||||
|
name_dynamic = dynamic_path
|
||||||
if (
|
if (
|
||||||
"{{ suffix }}" not in name_dynamic
|
"{{ suffix }}" not in name_dynamic
|
||||||
or parent_path != parent_dynamic
|
or parent_path != parent_dynamic
|
||||||
|
@ -203,6 +228,9 @@ class Paths:
|
||||||
if len(finded) != 1 or not finded[0]:
|
if len(finded) != 1 or not finded[0]:
|
||||||
continue
|
continue
|
||||||
suffixes.append(finded[0])
|
suffixes.append(finded[0])
|
||||||
|
if new_path is None:
|
||||||
|
new_path = name_dynamic
|
||||||
|
else:
|
||||||
new_path += "." + name_dynamic
|
new_path += "." + name_dynamic
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
@ -274,7 +302,7 @@ class Informations:
|
||||||
if path not in self._data:
|
if path not in self._data:
|
||||||
self._data[path] = {}
|
self._data[path] = {}
|
||||||
if key in self._data[path]:
|
if key in self._data[path]:
|
||||||
raise Exception(f"already key {key} in {path}")
|
raise Exception(f'an information "{key}" is already present in "{path}"')
|
||||||
self._data[path][key] = data
|
self._data[path][key] = data
|
||||||
|
|
||||||
def get(
|
def get(
|
||||||
|
@ -286,7 +314,10 @@ class Informations:
|
||||||
|
|
||||||
class ParserVariable:
|
class ParserVariable:
|
||||||
def __init__(self, rougailconfig):
|
def __init__(self, rougailconfig):
|
||||||
self.paths = Paths(rougailconfig["variable_namespace"])
|
main_namespace = rougailconfig["main_namespace"]
|
||||||
|
if main_namespace is not None:
|
||||||
|
main_namespace = rougailconfig["main_namespace"]
|
||||||
|
self.paths = Paths(main_namespace)
|
||||||
self.families = []
|
self.families = []
|
||||||
self.variables = []
|
self.variables = []
|
||||||
self.parents = {".": []}
|
self.parents = {".": []}
|
||||||
|
@ -432,6 +463,9 @@ class ParserVariable:
|
||||||
if name.startswith("_"):
|
if name.startswith("_"):
|
||||||
msg = f'the variable or family name "{name}" is incorrect, it must not starts with "_" character'
|
msg = f'the variable or family name "{name}" is incorrect, it must not starts with "_" character'
|
||||||
raise DictConsistencyError(msg, 16, [filename])
|
raise DictConsistencyError(msg, 16, [filename])
|
||||||
|
if not subpath:
|
||||||
|
path = name
|
||||||
|
else:
|
||||||
path = f"{subpath}.{name}"
|
path = f"{subpath}.{name}"
|
||||||
if version == "0.1" and not isinstance(obj, dict) and obj is not None:
|
if version == "0.1" and not isinstance(obj, dict) and obj is not None:
|
||||||
msg = f'the variable "{path}" has a wrong type "{type(obj)}"'
|
msg = f'the variable "{path}" has a wrong type "{type(obj)}"'
|
||||||
|
@ -480,7 +514,7 @@ class ParserVariable:
|
||||||
return
|
return
|
||||||
family_obj = {}
|
family_obj = {}
|
||||||
subfamily_obj = {}
|
subfamily_obj = {}
|
||||||
force_to_attrs = list(self.list_attributes(obj, version))
|
force_to_attrs = list(self.list_attributes(obj))
|
||||||
for key, value in obj.items():
|
for key, value in obj.items():
|
||||||
if key in force_to_attrs:
|
if key in force_to_attrs:
|
||||||
if key.startswith("_"):
|
if key.startswith("_"):
|
||||||
|
@ -493,7 +527,7 @@ class ParserVariable:
|
||||||
if family_obj:
|
if family_obj:
|
||||||
if not obj.pop("redefine", False):
|
if not obj.pop("redefine", False):
|
||||||
raise Exception(
|
raise Exception(
|
||||||
f"The family {path} already exists and she is not redefined in {filemane}"
|
f"The family {path} already exists and she is not redefined in {filename}"
|
||||||
)
|
)
|
||||||
self.paths.add(
|
self.paths.add(
|
||||||
path,
|
path,
|
||||||
|
@ -518,14 +552,15 @@ class ParserVariable:
|
||||||
if self.get_family_or_variable_type(family_obj) == "dynamic":
|
if self.get_family_or_variable_type(family_obj) == "dynamic":
|
||||||
family_is_dynamic = True
|
family_is_dynamic = True
|
||||||
parent_dynamic = path
|
parent_dynamic = path
|
||||||
if version == "1.0" and "{{ suffix }}" not in name:
|
if '{{ suffix }}' not in name:
|
||||||
name += "{{ suffix }}"
|
if "variable" in family_obj:
|
||||||
path += "{{ suffix }}"
|
name += '{{ suffix }}'
|
||||||
if "{{ suffix }}" not in name:
|
path += '{{ suffix }}'
|
||||||
|
else:
|
||||||
msg = f'dynamic family name must have "{{{{ suffix }}}}" in his name for "{path}"'
|
msg = f'dynamic family name must have "{{{{ suffix }}}}" in his name for "{path}"'
|
||||||
raise DictConsistencyError(msg, 13, [filename])
|
raise DictConsistencyError(msg, 13, [filename])
|
||||||
if version != "1.0" and not family_obj and comment:
|
if version != '1.0' and not family_obj and comment:
|
||||||
family_obj["description"] = comment
|
family_obj['description'] = comment
|
||||||
self.add_family(
|
self.add_family(
|
||||||
path,
|
path,
|
||||||
name,
|
name,
|
||||||
|
@ -558,7 +593,6 @@ class ParserVariable:
|
||||||
def list_attributes(
|
def list_attributes(
|
||||||
self,
|
self,
|
||||||
obj: Dict[str, Any],
|
obj: Dict[str, Any],
|
||||||
version: str,
|
|
||||||
) -> Iterator[str]:
|
) -> Iterator[str]:
|
||||||
"""List attributes"""
|
"""List attributes"""
|
||||||
force_to_variable = []
|
force_to_variable = []
|
||||||
|
@ -581,7 +615,8 @@ class ParserVariable:
|
||||||
):
|
):
|
||||||
# it's a dict, so a new variables!
|
# it's a dict, so a new variables!
|
||||||
continue
|
continue
|
||||||
if version == '1.0' and key == "variable" and obj.get("type") != "dynamic" and obj.get("_type") != "dynamic":
|
# 'variable' for compatibility to format 1.0
|
||||||
|
if key == "variable" and obj.get("type") != "dynamic" and obj.get("_type") != "dynamic":
|
||||||
continue
|
continue
|
||||||
if key in self.family_attrs:
|
if key in self.family_attrs:
|
||||||
yield key
|
yield key
|
||||||
|
@ -599,6 +634,7 @@ class ParserVariable:
|
||||||
"""Add a new family"""
|
"""Add a new family"""
|
||||||
family["path"] = path
|
family["path"] = path
|
||||||
family["namespace"] = self.namespace
|
family["namespace"] = self.namespace
|
||||||
|
family["version"] = version
|
||||||
family["xmlfiles"] = [filename]
|
family["xmlfiles"] = [filename]
|
||||||
obj_type = self.get_family_or_variable_type(family)
|
obj_type = self.get_family_or_variable_type(family)
|
||||||
if obj_type == "dynamic":
|
if obj_type == "dynamic":
|
||||||
|
@ -625,9 +661,17 @@ class ParserVariable:
|
||||||
del family["variable"]
|
del family["variable"]
|
||||||
# FIXME only for 1.0
|
# FIXME only for 1.0
|
||||||
if "variable" in family:
|
if "variable" in family:
|
||||||
raise Exception(
|
family['dynamic'] = {'type': 'variable',
|
||||||
f'dynamic family must not have "variable" attribute for "{family["path"]}" in {family["xmlfiles"]}'
|
'variable': family['variable'],
|
||||||
)
|
'propertyerror': False,
|
||||||
|
'allow_none': True,
|
||||||
|
}
|
||||||
|
del family['variable']
|
||||||
|
if version != "1.0":
|
||||||
|
warning = f'"variable" attribute in dynamic family "{ path }" is depreciated in {filename}'
|
||||||
|
warn(warning)
|
||||||
|
if "variable" in family:
|
||||||
|
raise Exception(f'dynamic family must not have "variable" attribute for "{family["path"]}" in {family["xmlfiles"]}')
|
||||||
else:
|
else:
|
||||||
family_obj = self.family
|
family_obj = self.family
|
||||||
# convert to Calculation objects
|
# convert to Calculation objects
|
||||||
|
@ -720,7 +764,7 @@ class ParserVariable:
|
||||||
# so do nothing
|
# so do nothing
|
||||||
return
|
return
|
||||||
if "redefine" in obj and obj["redefine"]:
|
if "redefine" in obj and obj["redefine"]:
|
||||||
msg = f'cannot redefine the inexisting variable "{path}" in {filename}'
|
msg = f'cannot redefine the inexisting variable "{path}"'
|
||||||
raise DictConsistencyError(msg, 46, [filename])
|
raise DictConsistencyError(msg, 46, [filename])
|
||||||
obj["path"] = path
|
obj["path"] = path
|
||||||
self.add_variable(
|
self.add_variable(
|
||||||
|
@ -861,7 +905,11 @@ class ParserVariable:
|
||||||
parent_dynamic,
|
parent_dynamic,
|
||||||
)
|
)
|
||||||
self.variables.append(variable["path"])
|
self.variables.append(variable["path"])
|
||||||
self.parents[variable["path"].rsplit(".", 1)[0]].append(variable["path"])
|
if '.' in variable["path"]:
|
||||||
|
parent_path = variable["path"].rsplit(".", 1)[0]
|
||||||
|
else:
|
||||||
|
parent_path = "."
|
||||||
|
self.parents[parent_path].append(variable["path"])
|
||||||
self.set_name(
|
self.set_name(
|
||||||
variable_obj,
|
variable_obj,
|
||||||
"option_",
|
"option_",
|
||||||
|
@ -875,7 +923,10 @@ class ParserVariable:
|
||||||
del self.paths[path]
|
del self.paths[path]
|
||||||
self.families.remove(path)
|
self.families.remove(path)
|
||||||
del self.parents[path]
|
del self.parents[path]
|
||||||
|
if '.' in path:
|
||||||
parent = path.rsplit(".", 1)[0]
|
parent = path.rsplit(".", 1)[0]
|
||||||
|
else:
|
||||||
|
parent = '.'
|
||||||
self.parents[parent].remove(path)
|
self.parents[parent].remove(path)
|
||||||
|
|
||||||
###############################################################################################
|
###############################################################################################
|
||||||
|
@ -1039,28 +1090,54 @@ class RougailConvert(ParserVariable):
|
||||||
"",
|
"",
|
||||||
False,
|
False,
|
||||||
None,
|
None,
|
||||||
None,
|
'',
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
root_parent = "."
|
root_parent = "."
|
||||||
|
if self.rougailconfig["main_namespace"]:
|
||||||
directory_dict = chain(
|
directory_dict = chain(
|
||||||
(
|
(
|
||||||
(
|
(
|
||||||
self.rougailconfig["variable_namespace"],
|
self.rougailconfig["main_namespace"],
|
||||||
self.rougailconfig["dictionaries_dir"],
|
self.rougailconfig["main_dictionaries"],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
self.rougailconfig["extra_dictionaries"].items(),
|
self.rougailconfig["extra_dictionaries"].items(),
|
||||||
)
|
)
|
||||||
for namespace, extra_dirs in directory_dict:
|
for namespace, extra_dirs in directory_dict:
|
||||||
|
if namespace is None:
|
||||||
self.namespace = namespace
|
self.namespace = namespace
|
||||||
|
else:
|
||||||
|
self.namespace = normalize_family(namespace)
|
||||||
if root_parent == ".":
|
if root_parent == ".":
|
||||||
namespace_path = self.namespace
|
namespace_path = self.namespace
|
||||||
else:
|
else:
|
||||||
namespace_path = f"{root_parent}.{self.namespace}"
|
namespace_path = f"{root_parent}.{self.namespace}"
|
||||||
if namespace_path in self.parents:
|
if namespace_path in self.parents:
|
||||||
raise Exception("pfff")
|
raise Exception("pfff")
|
||||||
for filename in self.get_sorted_filename(extra_dirs):
|
for idx, filename in enumerate(self.get_sorted_filename(extra_dirs)):
|
||||||
|
if not idx:
|
||||||
|
self.parse_family(
|
||||||
|
'',
|
||||||
|
self.namespace,
|
||||||
|
namespace_path,
|
||||||
|
{'description': namespace,
|
||||||
|
},
|
||||||
|
'',
|
||||||
|
)
|
||||||
|
self.parse_variable_file(
|
||||||
|
filename,
|
||||||
|
namespace_path,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self.namespace = None
|
||||||
|
if root_parent == ".":
|
||||||
|
namespace_path = ''
|
||||||
|
else:
|
||||||
|
namespace_path = f"{root_parent}"
|
||||||
|
if namespace_path in self.parents:
|
||||||
|
raise Exception("pfff")
|
||||||
|
for filename in self.get_sorted_filename(self.rougailconfig["main_dictionaries"]):
|
||||||
self.parse_variable_file(
|
self.parse_variable_file(
|
||||||
filename,
|
filename,
|
||||||
namespace_path,
|
namespace_path,
|
||||||
|
@ -1093,13 +1170,6 @@ class RougailConvert(ParserVariable):
|
||||||
objects,
|
objects,
|
||||||
filename,
|
filename,
|
||||||
)
|
)
|
||||||
self.parse_family(
|
|
||||||
filename,
|
|
||||||
self.namespace,
|
|
||||||
path,
|
|
||||||
{},
|
|
||||||
version,
|
|
||||||
)
|
|
||||||
for name, obj in objects.items():
|
for name, obj in objects.items():
|
||||||
comment = self.get_comment(name, objects)
|
comment = self.get_comment(name, objects)
|
||||||
self.family_or_variable(
|
self.family_or_variable(
|
||||||
|
@ -1124,7 +1194,7 @@ class RougailConvert(ParserVariable):
|
||||||
continue
|
continue
|
||||||
filenames = {}
|
filenames = {}
|
||||||
for file_path in directory.iterdir():
|
for file_path in directory.iterdir():
|
||||||
if not file_path.suffix == ".yml":
|
if file_path.suffix not in [".yml", ".yaml"]:
|
||||||
continue
|
continue
|
||||||
if file_path.name in filenames:
|
if file_path.name in filenames:
|
||||||
raise DictConsistencyError(
|
raise DictConsistencyError(
|
||||||
|
@ -1176,15 +1246,12 @@ class RougailConvert(ParserVariable):
|
||||||
|
|
||||||
def reflect(self) -> None:
|
def reflect(self) -> None:
|
||||||
"""Apply TiramisuReflector"""
|
"""Apply TiramisuReflector"""
|
||||||
functions_file = self.rougailconfig["functions_file"]
|
functions_files = [
|
||||||
if not isinstance(functions_file, list):
|
func for func in self.rougailconfig["functions_files"] if func not in self.exclude_imports
|
||||||
functions_file = [functions_file]
|
|
||||||
functions_file = [
|
|
||||||
func for func in functions_file if func not in self.exclude_imports
|
|
||||||
]
|
]
|
||||||
self.reflector = TiramisuReflector(
|
self.reflector = TiramisuReflector(
|
||||||
self,
|
self,
|
||||||
functions_file,
|
functions_files,
|
||||||
)
|
)
|
||||||
|
|
||||||
def save(
|
def save(
|
||||||
|
|
|
@ -51,40 +51,45 @@ def convert_boolean(value: str) -> bool:
|
||||||
|
|
||||||
|
|
||||||
CONVERT_OPTION = {
|
CONVERT_OPTION = {
|
||||||
"string": dict(opttype="StrOption"),
|
"string": dict(opttype="StrOption", example="xxx"),
|
||||||
"number": dict(opttype="IntOption", func=int),
|
"number": dict(opttype="IntOption", func=int, example=42),
|
||||||
"float": dict(opttype="FloatOption", func=float),
|
"float": dict(opttype="FloatOption", func=float, example=1.42),
|
||||||
"boolean": dict(opttype="BoolOption", func=convert_boolean),
|
"boolean": dict(opttype="BoolOption", func=convert_boolean),
|
||||||
"secret": dict(opttype="PasswordOption"),
|
"secret": dict(opttype="PasswordOption", example="xxx"),
|
||||||
"mail": dict(opttype="EmailOption"),
|
"mail": dict(opttype="EmailOption", example="user@example.net"),
|
||||||
"unix_filename": dict(opttype="FilenameOption"),
|
"unix_filename": dict(opttype="FilenameOption", example="/tmp/myfile.txt"),
|
||||||
"date": dict(opttype="DateOption"),
|
"date": dict(opttype="DateOption", example="2000-01-01"),
|
||||||
"unix_user": dict(opttype="UsernameOption"),
|
"unix_user": dict(opttype="UsernameOption", example="xxx"),
|
||||||
"ip": dict(opttype="IPOption", initkwargs={"allow_reserved": True}),
|
"ip": dict(opttype="IPOption", initkwargs={"allow_reserved": True}, example="1.1.1.1"),
|
||||||
"cidr": dict(opttype="IPOption", initkwargs={"cidr": True}),
|
"cidr": dict(opttype="IPOption", initkwargs={"cidr": True}, example="1.1.1.0/24"),
|
||||||
"netmask": dict(opttype="NetmaskOption"),
|
"netmask": dict(opttype="NetmaskOption", example="255.255.255.0"),
|
||||||
"network": dict(opttype="NetworkOption"),
|
"network": dict(opttype="NetworkOption", example="1.1.1.0"),
|
||||||
"network_cidr": dict(opttype="NetworkOption", initkwargs={"cidr": True}),
|
"network_cidr": dict(opttype="NetworkOption", initkwargs={"cidr": True}, example="1.1.1.0/24"),
|
||||||
"broadcast": dict(opttype="BroadcastOption"),
|
"broadcast": dict(opttype="BroadcastOption", example="1.1.1.255"),
|
||||||
"netbios": dict(
|
"netbios": dict(
|
||||||
opttype="DomainnameOption",
|
opttype="DomainnameOption",
|
||||||
initkwargs={"type": "netbios", "warnings_only": True},
|
initkwargs={"type": "netbios", "warnings_only": True},
|
||||||
|
example="example"
|
||||||
),
|
),
|
||||||
"domainname": dict(
|
"domainname": dict(
|
||||||
opttype="DomainnameOption", initkwargs={"type": "domainname", "allow_ip": False}
|
opttype="DomainnameOption", initkwargs={"type": "domainname", "allow_ip": False},
|
||||||
|
example="example.net"
|
||||||
),
|
),
|
||||||
"hostname": dict(
|
"hostname": dict(
|
||||||
opttype="DomainnameOption", initkwargs={"type": "hostname", "allow_ip": False}
|
opttype="DomainnameOption", initkwargs={"type": "hostname", "allow_ip": False},
|
||||||
|
example="example"
|
||||||
),
|
),
|
||||||
"web_address": dict(
|
"web_address": dict(
|
||||||
opttype="URLOption", initkwargs={"allow_ip": False, "allow_without_dot": True}
|
opttype="URLOption", initkwargs={"allow_ip": False, "allow_without_dot": True},
|
||||||
|
example="https://example.net"
|
||||||
),
|
),
|
||||||
"port": dict(opttype="PortOption", initkwargs={"allow_private": True}),
|
"port": dict(opttype="PortOption", initkwargs={"allow_private": True}, example="111"),
|
||||||
"mac": dict(opttype="MACOption"),
|
"mac": dict(opttype="MACOption", example="00:00:00:00:00"),
|
||||||
"unix_permissions": dict(
|
"unix_permissions": dict(
|
||||||
opttype="PermissionsOption", initkwargs={"warnings_only": True}, func=int
|
opttype="PermissionsOption", initkwargs={"warnings_only": True}, func=int,
|
||||||
|
example="644"
|
||||||
),
|
),
|
||||||
"choice": dict(opttype="ChoiceOption"),
|
"choice": dict(opttype="ChoiceOption", example="xxx"),
|
||||||
#
|
#
|
||||||
"symlink": dict(opttype="SymLinkOption"),
|
"symlink": dict(opttype="SymLinkOption"),
|
||||||
}
|
}
|
||||||
|
@ -164,7 +169,9 @@ class Calculation(BaseModel):
|
||||||
path: str
|
path: str
|
||||||
inside_list: bool
|
inside_list: bool
|
||||||
version: str
|
version: str
|
||||||
namespace: str
|
ori_path: Optional[str]=None
|
||||||
|
default_values: Any=None
|
||||||
|
namespace: Optional[str]
|
||||||
xmlfiles: List[str]
|
xmlfiles: List[str]
|
||||||
|
|
||||||
model_config = ConfigDict(extra="forbid")
|
model_config = ConfigDict(extra="forbid")
|
||||||
|
@ -182,12 +189,17 @@ class Calculation(BaseModel):
|
||||||
for param_obj in self.params:
|
for param_obj in self.params:
|
||||||
param = param_obj.model_dump()
|
param = param_obj.model_dump()
|
||||||
if param.get("type") == "variable":
|
if param.get("type") == "variable":
|
||||||
|
if self.ori_path is None:
|
||||||
|
path = self.path
|
||||||
|
else:
|
||||||
|
path = self.ori_path
|
||||||
variable, suffix = objectspace.paths.get_with_dynamic(
|
variable, suffix = objectspace.paths.get_with_dynamic(
|
||||||
param["variable"], self.path_prefix, self.path, self.version, self.namespace, self.xmlfiles
|
param["variable"], self.path_prefix, path, self.version, self.namespace, self.xmlfiles
|
||||||
)
|
)
|
||||||
if not variable:
|
if not variable:
|
||||||
if not param.get("optional"):
|
if not param.get("optional"):
|
||||||
raise Exception(f"cannot find {param['variable']}")
|
msg = f'cannot find variable "{param["variable"]}" defined attribute in "{self.attribute_name}" for "{self.path}"'
|
||||||
|
raise DictConsistencyError(msg, 22, self.xmlfiles)
|
||||||
continue
|
continue
|
||||||
if not isinstance(variable, objectspace.variable):
|
if not isinstance(variable, objectspace.variable):
|
||||||
raise Exception("pfff it's a family")
|
raise Exception("pfff it's a family")
|
||||||
|
@ -196,8 +208,12 @@ class Calculation(BaseModel):
|
||||||
param["suffix"] = suffix
|
param["suffix"] = suffix
|
||||||
if param.get("type") == "information":
|
if param.get("type") == "information":
|
||||||
if param["variable"]:
|
if param["variable"]:
|
||||||
|
if self.ori_path is None:
|
||||||
|
path = self.path
|
||||||
|
else:
|
||||||
|
path = self.ori_path
|
||||||
variable, suffix = objectspace.paths.get_with_dynamic(
|
variable, suffix = objectspace.paths.get_with_dynamic(
|
||||||
param["variable"], self.path_prefix, self.path, self.version, self.namespace, self.xmlfiles
|
param["variable"], self.path_prefix, path, self.version, self.namespace, self.xmlfiles
|
||||||
)
|
)
|
||||||
if not variable:
|
if not variable:
|
||||||
msg = f'cannot find variable "{param["variable"]}" defined in "{self.attribute_name}" for "{self.path}"'
|
msg = f'cannot find variable "{param["variable"]}" defined in "{self.attribute_name}" for "{self.path}"'
|
||||||
|
@ -219,6 +235,7 @@ class JinjaCalculation(Calculation):
|
||||||
jinja: StrictStr
|
jinja: StrictStr
|
||||||
params: Optional[List[Param]] = None
|
params: Optional[List[Param]] = None
|
||||||
return_type: BASETYPE = None
|
return_type: BASETYPE = None
|
||||||
|
description: Optional[StrictStr] = None
|
||||||
|
|
||||||
def _jinja_to_function(
|
def _jinja_to_function(
|
||||||
self,
|
self,
|
||||||
|
@ -245,14 +262,20 @@ class JinjaCalculation(Calculation):
|
||||||
"__internal_multi": multi,
|
"__internal_multi": multi,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
if self.default_values:
|
||||||
|
default["params"]['__default_value'] = self.default_values
|
||||||
if add_help:
|
if add_help:
|
||||||
default["help"] = function + "_help"
|
default["help"] = function + "_help"
|
||||||
if self.params:
|
if self.params:
|
||||||
default["params"] |= self.get_params(objectspace)
|
default["params"] |= self.get_params(objectspace)
|
||||||
if params:
|
if params:
|
||||||
default["params"] |= params
|
default["params"] |= params
|
||||||
|
if self.ori_path is None:
|
||||||
|
path = self.path
|
||||||
|
else:
|
||||||
|
path = self.ori_path
|
||||||
for sub_variable, suffix, true_path in get_jinja_variable_to_param(
|
for sub_variable, suffix, true_path in get_jinja_variable_to_param(
|
||||||
self.path,
|
path,
|
||||||
self.jinja,
|
self.jinja,
|
||||||
objectspace,
|
objectspace,
|
||||||
variable.xmlfiles,
|
variable.xmlfiles,
|
||||||
|
@ -261,7 +284,12 @@ class JinjaCalculation(Calculation):
|
||||||
self.version,
|
self.version,
|
||||||
self.namespace,
|
self.namespace,
|
||||||
):
|
):
|
||||||
if sub_variable.path in objectspace.variables:
|
if isinstance(sub_variable, dict):
|
||||||
|
default["params"][true_path] = {
|
||||||
|
"type": "value",
|
||||||
|
"value": sub_variable,
|
||||||
|
}
|
||||||
|
else:
|
||||||
default["params"][true_path] = {
|
default["params"][true_path] = {
|
||||||
"type": "variable",
|
"type": "variable",
|
||||||
"variable": sub_variable,
|
"variable": sub_variable,
|
||||||
|
@ -343,8 +371,12 @@ class VariableCalculation(Calculation):
|
||||||
self,
|
self,
|
||||||
objectspace,
|
objectspace,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
|
if self.ori_path is None:
|
||||||
|
path = self.path
|
||||||
|
else:
|
||||||
|
path = self.ori_path
|
||||||
variable, suffix = objectspace.paths.get_with_dynamic(
|
variable, suffix = objectspace.paths.get_with_dynamic(
|
||||||
self.variable, self.path_prefix, self.path, self.version, self.namespace, self.xmlfiles
|
self.variable, self.path_prefix, path, self.version, self.namespace, self.xmlfiles
|
||||||
)
|
)
|
||||||
if not variable:
|
if not variable:
|
||||||
msg = f'Variable not found "{self.variable}" for attribut "{self.attribute_name}" for variable "{self.path}"'
|
msg = f'Variable not found "{self.variable}" for attribut "{self.attribute_name}" for variable "{self.path}"'
|
||||||
|
@ -357,17 +389,20 @@ class VariableCalculation(Calculation):
|
||||||
"variable": variable,
|
"variable": variable,
|
||||||
"propertyerror": self.propertyerror,
|
"propertyerror": self.propertyerror,
|
||||||
}
|
}
|
||||||
if suffix:
|
|
||||||
param["suffix"] = suffix
|
|
||||||
params = {None: [param]}
|
params = {None: [param]}
|
||||||
function = "calc_value"
|
if self.default_values:
|
||||||
help_function = None
|
params['__default_value'] = self.default_values
|
||||||
if self.attribute_name in PROPERTY_ATTRIBUTE:
|
if self.attribute_name in PROPERTY_ATTRIBUTE:
|
||||||
function = "variable_to_property"
|
function = "variable_to_property"
|
||||||
help_function = "variable_to_property"
|
help_function = "variable_to_property"
|
||||||
if variable.type != "boolean":
|
if variable.type != "boolean":
|
||||||
raise Exception("only boolean!")
|
raise Exception("only boolean!")
|
||||||
params[None].insert(0, self.attribute_name)
|
params[None].insert(0, self.attribute_name)
|
||||||
|
else:
|
||||||
|
function = "calc_value"
|
||||||
|
help_function = None
|
||||||
|
if suffix:
|
||||||
|
param["suffix"] = suffix
|
||||||
if self.allow_none:
|
if self.allow_none:
|
||||||
params["allow_none"] = True
|
params["allow_none"] = True
|
||||||
# current variable is a multi
|
# current variable is a multi
|
||||||
|
@ -377,7 +412,16 @@ class VariableCalculation(Calculation):
|
||||||
needs_multi = True
|
needs_multi = True
|
||||||
else:
|
else:
|
||||||
needs_multi = self.path in objectspace.multis
|
needs_multi = self.path in objectspace.multis
|
||||||
calc_variable_is_multi = variable.path in objectspace.multis or (variable.path in objectspace.paths._dynamics and (suffix is None or suffix[-1] is None) and objectspace.paths._dynamics[variable.path] != objectspace.paths._dynamics.get(self.path))
|
calc_variable_is_multi = variable.path in objectspace.multis
|
||||||
|
if not calc_variable_is_multi:
|
||||||
|
if variable.path in objectspace.paths._dynamics and (suffix is None or suffix[-1] is None):
|
||||||
|
self_dyn_path = objectspace.paths._dynamics.get(self.path)
|
||||||
|
if self_dyn_path is not None:
|
||||||
|
var_dyn_path = objectspace.paths._dynamics[variable.path]
|
||||||
|
if self_dyn_path != var_dyn_path and not self_dyn_path.startswith(f'{var_dyn_path}.'):
|
||||||
|
calc_variable_is_multi = True
|
||||||
|
else:
|
||||||
|
calc_variable_is_multi = True
|
||||||
if needs_multi:
|
if needs_multi:
|
||||||
if calc_variable_is_multi:
|
if calc_variable_is_multi:
|
||||||
if self.inside_list:
|
if self.inside_list:
|
||||||
|
@ -410,20 +454,27 @@ class InformationCalculation(Calculation):
|
||||||
self,
|
self,
|
||||||
objectspace,
|
objectspace,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
param = {
|
params = {None: [{
|
||||||
"type": "information",
|
"type": "information",
|
||||||
"information": self.information,
|
"information": self.information,
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
if self.variable:
|
if self.variable:
|
||||||
|
if self.ori_path is None:
|
||||||
|
path = self.path
|
||||||
|
else:
|
||||||
|
path = self.ori_path
|
||||||
variable, suffix = objectspace.paths.get_with_dynamic(
|
variable, suffix = objectspace.paths.get_with_dynamic(
|
||||||
self.variable, self.path_prefix, self.path, self.version, self.namespace, self.xmlfiles
|
self.variable, self.path_prefix, path, self.version, self.namespace, self.xmlfiles
|
||||||
)
|
)
|
||||||
if variable is None or suffix is not None:
|
if variable is None or suffix is not None:
|
||||||
raise Exception("pfff")
|
raise Exception("pfff")
|
||||||
param["variable"] = variable
|
params[None][0]["variable"] = variable
|
||||||
|
if self.default_values:
|
||||||
|
params['__default_value'] = self.default_values
|
||||||
return {
|
return {
|
||||||
"function": "calc_value",
|
"function": "calc_value",
|
||||||
"params": {None: [param]},
|
"params": params,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -480,14 +531,15 @@ class Family(BaseModel):
|
||||||
hidden: Union[bool, Calculation] = False
|
hidden: Union[bool, Calculation] = False
|
||||||
disabled: Union[bool, Calculation] = False
|
disabled: Union[bool, Calculation] = False
|
||||||
namespace: Optional[str]
|
namespace: Optional[str]
|
||||||
|
version: str
|
||||||
xmlfiles: List[str] = []
|
xmlfiles: List[str] = []
|
||||||
|
|
||||||
model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)
|
model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)
|
||||||
|
|
||||||
|
|
||||||
class Dynamic(Family):
|
class Dynamic(Family):
|
||||||
variable: str=None
|
|
||||||
# None only for format 1.0
|
# None only for format 1.0
|
||||||
|
variable: str=None
|
||||||
dynamic: Union[List[Union[StrictStr, Calculation]], Calculation]
|
dynamic: Union[List[Union[StrictStr, Calculation]], Calculation]
|
||||||
|
|
||||||
|
|
||||||
|
@ -510,7 +562,7 @@ class Variable(BaseModel):
|
||||||
mode: Optional[str] = None
|
mode: Optional[str] = None
|
||||||
test: Optional[list] = None
|
test: Optional[list] = None
|
||||||
path: str
|
path: str
|
||||||
namespace: str
|
namespace: Optional[str]
|
||||||
version: str
|
version: str
|
||||||
xmlfiles: List[str] = []
|
xmlfiles: List[str] = []
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ from .utils import normalize_family
|
||||||
|
|
||||||
|
|
||||||
global func
|
global func
|
||||||
func = {'calc_value': calc_value}
|
func = {}
|
||||||
dict_env = {}
|
dict_env = {}
|
||||||
ENV = SandboxedEnvironment(loader=DictLoader(dict_env), undefined=StrictUndefined)
|
ENV = SandboxedEnvironment(loader=DictLoader(dict_env), undefined=StrictUndefined)
|
||||||
ENV.filters = func
|
ENV.filters = func
|
||||||
|
@ -60,7 +60,14 @@ def load_functions(path):
|
||||||
func[function] = getattr(func_, function)
|
func[function] = getattr(func_, function)
|
||||||
|
|
||||||
|
|
||||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
def rougail_calc_value(*args, __default_value=None, **kwargs):
|
||||||
|
values = calc_value(*args, **kwargs)
|
||||||
|
if __default_value is not None and values in [None, []]:
|
||||||
|
return __default_value
|
||||||
|
return values
|
||||||
|
|
||||||
|
|
||||||
|
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, __default_value=None, **kwargs):
|
||||||
global ENV, CONVERT_OPTION
|
global ENV, CONVERT_OPTION
|
||||||
kw = {}
|
kw = {}
|
||||||
for key, value in kwargs.items():
|
for key, value in kwargs.items():
|
||||||
|
@ -75,9 +82,15 @@ def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwa
|
||||||
values = ENV.get_template(__internal_jinja).render(kw, **func).strip()
|
values = ENV.get_template(__internal_jinja).render(kw, **func).strip()
|
||||||
convert = CONVERT_OPTION[__internal_type].get('func', str)
|
convert = CONVERT_OPTION[__internal_type].get('func', str)
|
||||||
if __internal_multi:
|
if __internal_multi:
|
||||||
return [convert(val) for val in values.split()]
|
values = [convert(val) for val in values.split()]
|
||||||
|
if not values and __default_value is not None:
|
||||||
|
return __default_value
|
||||||
|
return values
|
||||||
values = convert(values)
|
values = convert(values)
|
||||||
return values if values != '' and values != 'None' else None
|
values = values if values != '' and values != 'None' else None
|
||||||
|
if values is None and __default_value is not None:
|
||||||
|
return __default_value
|
||||||
|
return values
|
||||||
|
|
||||||
|
|
||||||
def variable_to_property(prop, value):
|
def variable_to_property(prop, value):
|
||||||
|
@ -104,6 +117,7 @@ def valid_with_jinja(warnings_only=False, **kwargs):
|
||||||
raise ValueError(value)
|
raise ValueError(value)
|
||||||
|
|
||||||
|
|
||||||
|
func['calc_value'] = rougail_calc_value
|
||||||
func['jinja_to_function'] = jinja_to_function
|
func['jinja_to_function'] = jinja_to_function
|
||||||
func['jinja_to_property'] = jinja_to_property
|
func['jinja_to_property'] = jinja_to_property
|
||||||
func['jinja_to_property_help'] = jinja_to_property_help
|
func['jinja_to_property_help'] = jinja_to_property_help
|
||||||
|
@ -135,3 +149,12 @@ class ConvertDynOptionDescription(DynOptionDescription):
|
||||||
if "{{ suffix }}" in name:
|
if "{{ suffix }}" in name:
|
||||||
return name.replace("{{ suffix }}", path_suffix)
|
return name.replace("{{ suffix }}", path_suffix)
|
||||||
return name + path_suffix
|
return name + path_suffix
|
||||||
|
|
||||||
|
def impl_get_display_name(
|
||||||
|
self,
|
||||||
|
subconfig,
|
||||||
|
) -> str:
|
||||||
|
display = super().impl_get_display_name(subconfig)
|
||||||
|
if "{{ suffix }}" in display:
|
||||||
|
return display.replace("{{ suffix }}", self.convert_suffix_to_path(self.get_suffixes(subconfig)[-1]))
|
||||||
|
return display
|
||||||
|
|
|
@ -76,11 +76,11 @@ class TiramisuReflector:
|
||||||
"from tiramisu.setting import ALLOWED_LEADER_PROPERTIES",
|
"from tiramisu.setting import ALLOWED_LEADER_PROPERTIES",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
if funcs_paths:
|
|
||||||
if self.rougailconfig["export_with_import"]:
|
if self.rougailconfig["export_with_import"]:
|
||||||
self.text["header"].extend(
|
self.text["header"].extend(
|
||||||
["from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription"]
|
["from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription"]
|
||||||
)
|
)
|
||||||
|
if funcs_paths:
|
||||||
for funcs_path in sorted(funcs_paths, key=sorted_func_name):
|
for funcs_path in sorted(funcs_paths, key=sorted_func_name):
|
||||||
if not isfile(funcs_path):
|
if not isfile(funcs_path):
|
||||||
continue
|
continue
|
||||||
|
@ -111,9 +111,6 @@ class TiramisuReflector:
|
||||||
baseelt,
|
baseelt,
|
||||||
self,
|
self,
|
||||||
)
|
)
|
||||||
# FIXMEif not self.objectspace.paths.has_path_prefix():
|
|
||||||
if 1:
|
|
||||||
# for elt in self.reorder_family(self.objectspace.space):
|
|
||||||
for elt in self.objectspace.paths.get():
|
for elt in self.objectspace.paths.get():
|
||||||
if elt.path in self.objectspace.families:
|
if elt.path in self.objectspace.families:
|
||||||
Family(
|
Family(
|
||||||
|
@ -125,33 +122,33 @@ class TiramisuReflector:
|
||||||
elt,
|
elt,
|
||||||
self,
|
self,
|
||||||
)
|
)
|
||||||
else:
|
# else:
|
||||||
path_prefixes = self.objectspace.paths.get_path_prefixes()
|
# path_prefixes = self.objectspace.paths.get_path_prefixes()
|
||||||
for path_prefix in path_prefixes:
|
# for path_prefix in path_prefixes:
|
||||||
space = self.objectspace.space.variables[path_prefix]
|
# space = self.objectspace.space.variables[path_prefix]
|
||||||
self.set_name(space)
|
# self.set_name(space)
|
||||||
baseprefix = Family(
|
# baseprefix = Family(
|
||||||
space,
|
# space,
|
||||||
self,
|
# self,
|
||||||
)
|
# )
|
||||||
basefamily.add(baseprefix)
|
# basefamily.add(baseprefix)
|
||||||
for elt in self.reorder_family(space):
|
# for elt in self.reorder_family(space):
|
||||||
self.populate_family(
|
# self.populate_family(
|
||||||
baseprefix,
|
# baseprefix,
|
||||||
elt,
|
# elt,
|
||||||
)
|
# )
|
||||||
if not hasattr(baseprefix.elt, "information"):
|
# if not hasattr(baseprefix.elt, "information"):
|
||||||
baseprefix.elt.information = self.objectspace.information(
|
# baseprefix.elt.information = self.objectspace.information(
|
||||||
baseprefix.elt.xmlfiles
|
# baseprefix.elt.xmlfiles
|
||||||
)
|
# )
|
||||||
for key, value in self.objectspace.paths.get_providers_path(
|
# for key, value in self.objectspace.paths.get_providers_path(
|
||||||
path_prefix
|
# path_prefix
|
||||||
).items():
|
# ).items():
|
||||||
setattr(baseprefix.elt.information, key, value)
|
# setattr(baseprefix.elt.information, key, value)
|
||||||
for key, value in self.objectspace.paths.get_suppliers_path(
|
# for key, value in self.objectspace.paths.get_suppliers_path(
|
||||||
path_prefix
|
# path_prefix
|
||||||
).items():
|
# ).items():
|
||||||
setattr(baseprefix.elt.information, key, value)
|
# setattr(baseprefix.elt.information, key, value)
|
||||||
baseelt.name = normalize_family(self.rougailconfig["base_option_name"])
|
baseelt.name = normalize_family(self.rougailconfig["base_option_name"])
|
||||||
baseelt.description = self.rougailconfig["base_option_name"]
|
baseelt.description = self.rougailconfig["base_option_name"]
|
||||||
self.reflector_objects[baseelt.path].get(
|
self.reflector_objects[baseelt.path].get(
|
||||||
|
@ -292,6 +289,8 @@ class Common:
|
||||||
else:
|
else:
|
||||||
value = param
|
value = param
|
||||||
return f"ParamValue({value})"
|
return f"ParamValue({value})"
|
||||||
|
if param["type"] == "value":
|
||||||
|
return f"ParamValue({param['value']})"
|
||||||
if param["type"] == "information":
|
if param["type"] == "information":
|
||||||
if self.elt.multi:
|
if self.elt.multi:
|
||||||
default = []
|
default = []
|
||||||
|
|
|
@ -577,7 +577,7 @@ class RougailUpgrade:
|
||||||
):
|
):
|
||||||
if extra_dstfolder is None:
|
if extra_dstfolder is None:
|
||||||
extra_dstfolder = dstfolder
|
extra_dstfolder = dstfolder
|
||||||
dict_dirs = self.rougailconfig["dictionaries_dir"]
|
dict_dirs = self.rougailconfig["main_dictionaries"]
|
||||||
if not isinstance(dict_dirs, list):
|
if not isinstance(dict_dirs, list):
|
||||||
dict_dirs = [dict_dirs]
|
dict_dirs = [dict_dirs]
|
||||||
for dict_dir in dict_dirs:
|
for dict_dir in dict_dirs:
|
||||||
|
@ -585,7 +585,7 @@ class RougailUpgrade:
|
||||||
dict_dir,
|
dict_dir,
|
||||||
dstfolder,
|
dstfolder,
|
||||||
services_dstfolder,
|
services_dstfolder,
|
||||||
self.rougailconfig["variable_namespace"],
|
normalize_family(self.rougailconfig["main_namespace"]),
|
||||||
)
|
)
|
||||||
for namespace, extra_dirs in self.rougailconfig["extra_dictionaries"].items():
|
for namespace, extra_dirs in self.rougailconfig["extra_dictionaries"].items():
|
||||||
extra_dstsubfolder = join(extra_dstfolder, namespace)
|
extra_dstsubfolder = join(extra_dstfolder, namespace)
|
||||||
|
@ -596,7 +596,7 @@ class RougailUpgrade:
|
||||||
extra_dir,
|
extra_dir,
|
||||||
extra_dstsubfolder,
|
extra_dstsubfolder,
|
||||||
None,
|
None,
|
||||||
namespace,
|
normalize_family(namespace),
|
||||||
)
|
)
|
||||||
|
|
||||||
def _load_dictionaries(
|
def _load_dictionaries(
|
||||||
|
|
|
@ -39,6 +39,8 @@ from jinja2.sandbox import SandboxedEnvironment
|
||||||
from jinja2.parser import Parser
|
from jinja2.parser import Parser
|
||||||
from jinja2.nodes import Getattr
|
from jinja2.nodes import Getattr
|
||||||
|
|
||||||
|
from tiramisu.config import get_common_path
|
||||||
|
|
||||||
from .i18n import _
|
from .i18n import _
|
||||||
from .error import DictConsistencyError
|
from .error import DictConsistencyError
|
||||||
|
|
||||||
|
@ -62,15 +64,16 @@ def normalize_family(family_name: str) -> str:
|
||||||
"""replace space, accent, uppercase, ... by valid character"""
|
"""replace space, accent, uppercase, ... by valid character"""
|
||||||
if not family_name:
|
if not family_name:
|
||||||
return
|
return
|
||||||
|
family_name = family_name.lower()
|
||||||
family_name = family_name.replace("-", "_").replace(" ", "_").replace(".", "_")
|
family_name = family_name.replace("-", "_").replace(" ", "_").replace(".", "_")
|
||||||
nfkd_form = normalize("NFKD", family_name)
|
nfkd_form = normalize("NFKD", family_name)
|
||||||
family_name = "".join([c for c in nfkd_form if not combining(c)])
|
family_name = "".join([c for c in nfkd_form if not combining(c)])
|
||||||
return family_name.lower()
|
return family_name.lower()
|
||||||
|
|
||||||
|
|
||||||
def load_modules(eosfunc_file) -> List[str]:
|
def load_modules(name, module) -> List[str]:
|
||||||
"""list all functions in eosfunc"""
|
"""list all functions in a module"""
|
||||||
loader = SourceFileLoader("eosfunc", eosfunc_file)
|
loader = SourceFileLoader(name, module)
|
||||||
spec = spec_from_loader(loader.name, loader)
|
spec = spec_from_loader(loader.name, loader)
|
||||||
eosfunc = module_from_spec(spec)
|
eosfunc = module_from_spec(spec)
|
||||||
loader.exec_module(eosfunc)
|
loader.exec_module(eosfunc)
|
||||||
|
@ -114,6 +117,8 @@ def get_jinja_variable_to_param(
|
||||||
raise Exception(msg) from err
|
raise Exception(msg) from err
|
||||||
variables = list(variables)
|
variables = list(variables)
|
||||||
variables.sort()
|
variables.sort()
|
||||||
|
founded_variables = {}
|
||||||
|
unknown_variables = []
|
||||||
for variable_path in variables:
|
for variable_path in variables:
|
||||||
variable, suffix = objectspace.paths.get_with_dynamic(
|
variable, suffix = objectspace.paths.get_with_dynamic(
|
||||||
variable_path,
|
variable_path,
|
||||||
|
@ -124,4 +129,14 @@ def get_jinja_variable_to_param(
|
||||||
xmlfiles,
|
xmlfiles,
|
||||||
)
|
)
|
||||||
if variable and variable.path in objectspace.variables:
|
if variable and variable.path in objectspace.variables:
|
||||||
yield variable, suffix, variable_path
|
founded_variables[variable_path] = (suffix, variable)
|
||||||
|
else:
|
||||||
|
unknown_variables.append(variable_path)
|
||||||
|
for variable_path in unknown_variables:
|
||||||
|
for v in founded_variables:
|
||||||
|
if get_common_path(v, variable_path) == v:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
yield {}, None, variable_path.rsplit('.', 1)[0]
|
||||||
|
for variable_path, data in founded_variables.items():
|
||||||
|
yield data[1], data[0], variable_path
|
||||||
|
|
8
tests/dictionaries/00_0empty/tiramisu/no_namespace.py
Normal file
8
tests/dictionaries/00_0empty/tiramisu/no_namespace.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[])
|
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
_version: '1.1'
|
||||||
|
version: # a variable
|
10
tests/dictionaries/00_0version_underscore/tiramisu/base.py
Normal file
10
tests/dictionaries/00_0version_underscore/tiramisu/base.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_2 = StrOption(name="version", doc="a variable", properties=frozenset({"basic", "mandatory"}))
|
||||||
|
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", children=[option_2], properties=frozenset({"basic"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
14
tests/dictionaries/00_0version_underscore/tiramisu/multi.py
Normal file
14
tests/dictionaries/00_0version_underscore/tiramisu/multi.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_3 = StrOption(name="version", doc="a variable", properties=frozenset({"basic", "mandatory"}))
|
||||||
|
optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", children=[option_3], properties=frozenset({"basic"}))
|
||||||
|
optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"basic"}))
|
||||||
|
option_6 = StrOption(name="version", doc="a variable", properties=frozenset({"basic", "mandatory"}))
|
||||||
|
optiondescription_5 = OptionDescription(name="rougail", doc="Rougail", children=[option_6], properties=frozenset({"basic"}))
|
||||||
|
optiondescription_4 = OptionDescription(name="2", doc="2", children=[optiondescription_5], properties=frozenset({"basic"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_4])
|
|
@ -0,0 +1,9 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_1 = StrOption(name="version", doc="a variable", properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])
|
3
tests/dictionaries/00_1empty_variable/makedict/base.json
Normal file
3
tests/dictionaries/00_1empty_variable/makedict/base.json
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"rougail.empty": null
|
||||||
|
}
|
10
tests/dictionaries/00_1empty_variable/tiramisu/base.py
Normal file
10
tests/dictionaries/00_1empty_variable/tiramisu/base.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_2 = StrOption(name="empty", doc="empty", properties=frozenset({"basic", "mandatory"}))
|
||||||
|
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", children=[option_2], properties=frozenset({"basic"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
14
tests/dictionaries/00_1empty_variable/tiramisu/multi.py
Normal file
14
tests/dictionaries/00_1empty_variable/tiramisu/multi.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_3 = StrOption(name="empty", doc="empty", properties=frozenset({"basic", "mandatory"}))
|
||||||
|
optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", children=[option_3], properties=frozenset({"basic"}))
|
||||||
|
optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"basic"}))
|
||||||
|
option_6 = StrOption(name="empty", doc="empty", properties=frozenset({"basic", "mandatory"}))
|
||||||
|
optiondescription_5 = OptionDescription(name="rougail", doc="Rougail", children=[option_6], properties=frozenset({"basic"}))
|
||||||
|
optiondescription_4 = OptionDescription(name="2", doc="2", children=[optiondescription_5], properties=frozenset({"basic"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_4])
|
|
@ -0,0 +1,9 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_1 = StrOption(name="empty", doc="empty", properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
var1: "no" # a first variable
|
||||||
|
var2:
|
||||||
|
description: a second variable
|
||||||
|
multi: true
|
||||||
|
default:
|
||||||
|
type: jinja
|
||||||
|
jinja: |
|
||||||
|
{{ _.var1 }}
|
||||||
|
description: the value of var1
|
12
tests/dictionaries/00_2default_calculated/tiramisu/base.py
Normal file
12
tests/dictionaries/00_2default_calculated/tiramisu/base.py
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
dict_env['default_rougail.var2'] = "{{ _.var1 }}\n"
|
||||||
|
option_2 = StrOption(name="var1", doc="a first variable", default="no", properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_3 = StrOption(name="var2", doc="a second variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_rougail.var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '_.var1': ParamOption(option_2)})), properties=frozenset({"mandatory", "notempty", "standard"}))
|
||||||
|
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", children=[option_2, option_3], properties=frozenset({"standard"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
18
tests/dictionaries/00_2default_calculated/tiramisu/multi.py
Normal file
18
tests/dictionaries/00_2default_calculated/tiramisu/multi.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
dict_env['default_1.rougail.var2'] = "{{ _.var1 }}\n"
|
||||||
|
dict_env['default_2.rougail.var2'] = "{{ _.var1 }}\n"
|
||||||
|
option_3 = StrOption(name="var1", doc="a first variable", default="no", properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_4 = StrOption(name="var2", doc="a second variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_1.rougail.var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '_.var1': ParamOption(option_3)})), properties=frozenset({"mandatory", "notempty", "standard"}))
|
||||||
|
optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", children=[option_3, option_4], properties=frozenset({"standard"}))
|
||||||
|
optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"standard"}))
|
||||||
|
option_7 = StrOption(name="var1", doc="a first variable", default="no", properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_8 = StrOption(name="var2", doc="a second variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_2.rougail.var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '_.var1': ParamOption(option_7)})), properties=frozenset({"mandatory", "notempty", "standard"}))
|
||||||
|
optiondescription_6 = OptionDescription(name="rougail", doc="Rougail", children=[option_7, option_8], properties=frozenset({"standard"}))
|
||||||
|
optiondescription_5 = OptionDescription(name="2", doc="2", children=[optiondescription_6], properties=frozenset({"standard"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_5])
|
|
@ -0,0 +1,11 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
dict_env['default_var2'] = "{{ _.var1 }}\n"
|
||||||
|
option_1 = StrOption(name="var1", doc="a first variable", default="no", properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_2 = StrOption(name="var2", doc="a second variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '_.var1': ParamOption(option_1)})), properties=frozenset({"mandatory", "notempty", "standard"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2])
|
|
@ -0,0 +1,16 @@
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
var1: # a first variable
|
||||||
|
- 'no'
|
||||||
|
- 'yes'
|
||||||
|
- maybe
|
||||||
|
var2:
|
||||||
|
description: a second variable
|
||||||
|
multi: true
|
||||||
|
default:
|
||||||
|
type: jinja
|
||||||
|
jinja: |
|
||||||
|
{% for val in _.var1 %}
|
||||||
|
{{ val }}
|
||||||
|
{% endfor %}
|
||||||
|
description: the value of _.var1
|
|
@ -0,0 +1,12 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
dict_env['default_rougail.var2'] = "{% for val in _.var1 %}\n{{ val }}\n{% endfor %}\n"
|
||||||
|
option_2 = StrOption(name="var1", doc="a first variable", multi=True, default=["no", "yes", "maybe"], default_multi="no", properties=frozenset({"mandatory", "notempty", "standard"}))
|
||||||
|
option_3 = StrOption(name="var2", doc="a second variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_rougail.var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '_.var1': ParamOption(option_2)})), properties=frozenset({"mandatory", "notempty", "standard"}))
|
||||||
|
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", children=[option_2, option_3], properties=frozenset({"standard"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
|
@ -0,0 +1,18 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
dict_env['default_1.rougail.var2'] = "{% for val in _.var1 %}\n{{ val }}\n{% endfor %}\n"
|
||||||
|
dict_env['default_2.rougail.var2'] = "{% for val in _.var1 %}\n{{ val }}\n{% endfor %}\n"
|
||||||
|
option_3 = StrOption(name="var1", doc="a first variable", multi=True, default=["no", "yes", "maybe"], default_multi="no", properties=frozenset({"mandatory", "notempty", "standard"}))
|
||||||
|
option_4 = StrOption(name="var2", doc="a second variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_1.rougail.var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '_.var1': ParamOption(option_3)})), properties=frozenset({"mandatory", "notempty", "standard"}))
|
||||||
|
optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", children=[option_3, option_4], properties=frozenset({"standard"}))
|
||||||
|
optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"standard"}))
|
||||||
|
option_7 = StrOption(name="var1", doc="a first variable", multi=True, default=["no", "yes", "maybe"], default_multi="no", properties=frozenset({"mandatory", "notempty", "standard"}))
|
||||||
|
option_8 = StrOption(name="var2", doc="a second variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_2.rougail.var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '_.var1': ParamOption(option_7)})), properties=frozenset({"mandatory", "notempty", "standard"}))
|
||||||
|
optiondescription_6 = OptionDescription(name="rougail", doc="Rougail", children=[option_7, option_8], properties=frozenset({"standard"}))
|
||||||
|
optiondescription_5 = OptionDescription(name="2", doc="2", children=[optiondescription_6], properties=frozenset({"standard"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_5])
|
|
@ -0,0 +1,11 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
dict_env['default_var2'] = "{% for val in _.var1 %}\n{{ val }}\n{% endfor %}\n"
|
||||||
|
option_1 = StrOption(name="var1", doc="a first variable", multi=True, default=["no", "yes", "maybe"], default_multi="no", properties=frozenset({"mandatory", "notempty", "standard"}))
|
||||||
|
option_2 = StrOption(name="var2", doc="a second variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '_.var1': ParamOption(option_1)})), properties=frozenset({"mandatory", "notempty", "standard"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2])
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
version: '1.0'
|
||||||
|
var1:
|
||||||
|
description: a variable
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
version: "1.0"
|
||||||
|
var2:
|
||||||
|
description: a variable
|
10
tests/dictionaries/00_4load_subfolder/makedict/after.json
Normal file
10
tests/dictionaries/00_4load_subfolder/makedict/after.json
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
}
|
4
tests/dictionaries/00_4load_subfolder/makedict/base.json
Normal file
4
tests/dictionaries/00_4load_subfolder/makedict/base.json
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": null,
|
||||||
|
"rougail.var2": null
|
||||||
|
}
|
10
tests/dictionaries/00_4load_subfolder/makedict/before.json
Normal file
10
tests/dictionaries/00_4load_subfolder/makedict/before.json
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
["rougail.var1", "rougail.var2"]
|
11
tests/dictionaries/00_4load_subfolder/tiramisu/base.py
Normal file
11
tests/dictionaries/00_4load_subfolder/tiramisu/base.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_2 = StrOption(name="var1", doc="a variable", properties=frozenset({"basic", "mandatory"}))
|
||||||
|
option_3 = StrOption(name="var2", doc="a variable", properties=frozenset({"basic", "mandatory"}))
|
||||||
|
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", children=[option_2, option_3], properties=frozenset({"basic"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
16
tests/dictionaries/00_4load_subfolder/tiramisu/multi.py
Normal file
16
tests/dictionaries/00_4load_subfolder/tiramisu/multi.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_3 = StrOption(name="var1", doc="a variable", properties=frozenset({"basic", "mandatory"}))
|
||||||
|
option_4 = StrOption(name="var2", doc="a variable", properties=frozenset({"basic", "mandatory"}))
|
||||||
|
optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", children=[option_3, option_4], properties=frozenset({"basic"}))
|
||||||
|
optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"basic"}))
|
||||||
|
option_7 = StrOption(name="var1", doc="a variable", properties=frozenset({"basic", "mandatory"}))
|
||||||
|
option_8 = StrOption(name="var2", doc="a variable", properties=frozenset({"basic", "mandatory"}))
|
||||||
|
optiondescription_6 = OptionDescription(name="rougail", doc="Rougail", children=[option_7, option_8], properties=frozenset({"basic"}))
|
||||||
|
optiondescription_5 = OptionDescription(name="2", doc="2", children=[optiondescription_6], properties=frozenset({"basic"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_5])
|
|
@ -0,0 +1,10 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_1 = StrOption(name="var1", doc="a variable", properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_2 = StrOption(name="var2", doc="a variable", properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2])
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
version: '1.0'
|
||||||
|
without_type:
|
||||||
|
description: a variable
|
||||||
|
default: non
|
6
tests/dictionaries/00_5load_notype/makedict/after.json
Normal file
6
tests/dictionaries/00_5load_notype/makedict/after.json
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"rougail.without_type": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "non"
|
||||||
|
}
|
||||||
|
}
|
3
tests/dictionaries/00_5load_notype/makedict/base.json
Normal file
3
tests/dictionaries/00_5load_notype/makedict/base.json
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"rougail.without_type": "non"
|
||||||
|
}
|
6
tests/dictionaries/00_5load_notype/makedict/before.json
Normal file
6
tests/dictionaries/00_5load_notype/makedict/before.json
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"rougail.without_type": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "non"
|
||||||
|
}
|
||||||
|
}
|
10
tests/dictionaries/00_5load_notype/tiramisu/base.py
Normal file
10
tests/dictionaries/00_5load_notype/tiramisu/base.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_2 = StrOption(name="without_type", doc="a variable", default="non", properties=frozenset({"mandatory", "standard"}))
|
||||||
|
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", children=[option_2], properties=frozenset({"standard"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
14
tests/dictionaries/00_5load_notype/tiramisu/multi.py
Normal file
14
tests/dictionaries/00_5load_notype/tiramisu/multi.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_3 = StrOption(name="without_type", doc="a variable", default="non", properties=frozenset({"mandatory", "standard"}))
|
||||||
|
optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", children=[option_3], properties=frozenset({"standard"}))
|
||||||
|
optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"standard"}))
|
||||||
|
option_6 = StrOption(name="without_type", doc="a variable", default="non", properties=frozenset({"mandatory", "standard"}))
|
||||||
|
optiondescription_5 = OptionDescription(name="rougail", doc="Rougail", children=[option_6], properties=frozenset({"standard"}))
|
||||||
|
optiondescription_4 = OptionDescription(name="2", doc="2", children=[optiondescription_5], properties=frozenset({"standard"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_4])
|
|
@ -0,0 +1,9 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_1 = StrOption(name="without_type", doc="a variable", default="non", properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])
|
|
@ -0,0 +1,18 @@
|
||||||
|
---
|
||||||
|
version: '1.1'
|
||||||
|
var1: true # the first variable
|
||||||
|
var2:
|
||||||
|
description: the second variable
|
||||||
|
default: true
|
||||||
|
var3:
|
||||||
|
description: the third variable
|
||||||
|
type: boolean
|
||||||
|
default: true
|
||||||
|
var4: false # the forth variable
|
||||||
|
var5:
|
||||||
|
description: the fifth variable
|
||||||
|
default: false
|
||||||
|
var6:
|
||||||
|
description: the sixth variable
|
||||||
|
type: boolean
|
||||||
|
default: false
|
26
tests/dictionaries/00_6boolean/makedict/after.json
Normal file
26
tests/dictionaries/00_6boolean/makedict/after.json
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"rougail.var3": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"rougail.var4": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
|
"rougail.var5": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
|
"rougail.var6": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": false
|
||||||
|
}
|
||||||
|
}
|
8
tests/dictionaries/00_6boolean/makedict/base.json
Normal file
8
tests/dictionaries/00_6boolean/makedict/base.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": true,
|
||||||
|
"rougail.var2": true,
|
||||||
|
"rougail.var3": true,
|
||||||
|
"rougail.var4": false,
|
||||||
|
"rougail.var5": false,
|
||||||
|
"rougail.var6": false
|
||||||
|
}
|
26
tests/dictionaries/00_6boolean/makedict/before.json
Normal file
26
tests/dictionaries/00_6boolean/makedict/before.json
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"rougail.var3": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"rougail.var4": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
|
"rougail.var5": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
|
"rougail.var6": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": false
|
||||||
|
}
|
||||||
|
}
|
15
tests/dictionaries/00_6boolean/tiramisu/base.py
Normal file
15
tests/dictionaries/00_6boolean/tiramisu/base.py
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_2 = BoolOption(name="var1", doc="the first variable", default=True, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_3 = BoolOption(name="var2", doc="the second variable", default=True, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_4 = BoolOption(name="var3", doc="the third variable", default=True, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_5 = BoolOption(name="var4", doc="the forth variable", default=False, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_6 = BoolOption(name="var5", doc="the fifth variable", default=False, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_7 = BoolOption(name="var6", doc="the sixth variable", default=False, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", children=[option_2, option_3, option_4, option_5, option_6, option_7], properties=frozenset({"standard"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
24
tests/dictionaries/00_6boolean/tiramisu/multi.py
Normal file
24
tests/dictionaries/00_6boolean/tiramisu/multi.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_3 = BoolOption(name="var1", doc="the first variable", default=True, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_4 = BoolOption(name="var2", doc="the second variable", default=True, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_5 = BoolOption(name="var3", doc="the third variable", default=True, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_6 = BoolOption(name="var4", doc="the forth variable", default=False, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_7 = BoolOption(name="var5", doc="the fifth variable", default=False, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_8 = BoolOption(name="var6", doc="the sixth variable", default=False, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", children=[option_3, option_4, option_5, option_6, option_7, option_8], properties=frozenset({"standard"}))
|
||||||
|
optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"standard"}))
|
||||||
|
option_11 = BoolOption(name="var1", doc="the first variable", default=True, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_12 = BoolOption(name="var2", doc="the second variable", default=True, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_13 = BoolOption(name="var3", doc="the third variable", default=True, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_14 = BoolOption(name="var4", doc="the forth variable", default=False, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_15 = BoolOption(name="var5", doc="the fifth variable", default=False, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_16 = BoolOption(name="var6", doc="the sixth variable", default=False, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
optiondescription_10 = OptionDescription(name="rougail", doc="Rougail", children=[option_11, option_12, option_13, option_14, option_15, option_16], properties=frozenset({"standard"}))
|
||||||
|
optiondescription_9 = OptionDescription(name="2", doc="2", children=[optiondescription_10], properties=frozenset({"standard"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_9])
|
14
tests/dictionaries/00_6boolean/tiramisu/no_namespace.py
Normal file
14
tests/dictionaries/00_6boolean/tiramisu/no_namespace.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_1 = BoolOption(name="var1", doc="the first variable", default=True, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_2 = BoolOption(name="var2", doc="the second variable", default=True, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_3 = BoolOption(name="var3", doc="the third variable", default=True, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_4 = BoolOption(name="var4", doc="the forth variable", default=False, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_5 = BoolOption(name="var5", doc="the fifth variable", default=False, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_6 = BoolOption(name="var6", doc="the sixth variable", default=False, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2, option_3, option_4, option_5, option_6])
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
version: '1.1'
|
||||||
|
variable:
|
||||||
|
description: a variable
|
||||||
|
type: boolean
|
||||||
|
mandatory: false
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"rougail.variable": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": true
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"rougail.variable": true
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"rougail.variable": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": true
|
||||||
|
}
|
||||||
|
}
|
10
tests/dictionaries/00_6boolean_no_mandatory/tiramisu/base.py
Normal file
10
tests/dictionaries/00_6boolean_no_mandatory/tiramisu/base.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_2 = BoolOption(name="variable", doc="a variable", default=True, properties=frozenset({"standard"}))
|
||||||
|
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", children=[option_2], properties=frozenset({"standard"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
|
@ -0,0 +1,14 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_3 = BoolOption(name="variable", doc="a variable", default=True, properties=frozenset({"standard"}))
|
||||||
|
optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", children=[option_3], properties=frozenset({"standard"}))
|
||||||
|
optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"standard"}))
|
||||||
|
option_6 = BoolOption(name="variable", doc="a variable", default=True, properties=frozenset({"standard"}))
|
||||||
|
optiondescription_5 = OptionDescription(name="rougail", doc="Rougail", children=[option_6], properties=frozenset({"standard"}))
|
||||||
|
optiondescription_4 = OptionDescription(name="2", doc="2", children=[optiondescription_5], properties=frozenset({"standard"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_4])
|
|
@ -0,0 +1,9 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_1 = BoolOption(name="variable", doc="a variable", default=True, properties=frozenset({"standard"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])
|
|
@ -0,0 +1,42 @@
|
||||||
|
---
|
||||||
|
version: '1.1'
|
||||||
|
var1:
|
||||||
|
description: the first variable
|
||||||
|
choices:
|
||||||
|
- a
|
||||||
|
- b
|
||||||
|
- c
|
||||||
|
var2:
|
||||||
|
description: the second variable
|
||||||
|
choices:
|
||||||
|
- a
|
||||||
|
- b
|
||||||
|
- c
|
||||||
|
var3:
|
||||||
|
description: the third variable
|
||||||
|
choices:
|
||||||
|
- a
|
||||||
|
- b
|
||||||
|
- c
|
||||||
|
mandatory: false
|
||||||
|
var4:
|
||||||
|
description: the forth variable
|
||||||
|
choices:
|
||||||
|
- null
|
||||||
|
- b
|
||||||
|
- c
|
||||||
|
mandatory: false
|
||||||
|
var5:
|
||||||
|
description: the fifth variable
|
||||||
|
choices:
|
||||||
|
- a
|
||||||
|
- b
|
||||||
|
- c
|
||||||
|
default: a
|
||||||
|
var6:
|
||||||
|
description: the sixth variable
|
||||||
|
choices:
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
- 3
|
||||||
|
default: 1
|
26
tests/dictionaries/00_6choice/makedict/after.json
Normal file
26
tests/dictionaries/00_6choice/makedict/after.json
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
"rougail.var3": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
"rougail.var4": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
"rougail.var5": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "a"
|
||||||
|
},
|
||||||
|
"rougail.var6": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": 1
|
||||||
|
}
|
||||||
|
}
|
8
tests/dictionaries/00_6choice/makedict/base.json
Normal file
8
tests/dictionaries/00_6choice/makedict/base.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": null,
|
||||||
|
"rougail.var2": null,
|
||||||
|
"rougail.var3": null,
|
||||||
|
"rougail.var4": null,
|
||||||
|
"rougail.var5": "a",
|
||||||
|
"rougail.var6": 1
|
||||||
|
}
|
26
tests/dictionaries/00_6choice/makedict/before.json
Normal file
26
tests/dictionaries/00_6choice/makedict/before.json
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
"rougail.var3": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
"rougail.var4": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
"rougail.var5": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "a"
|
||||||
|
},
|
||||||
|
"rougail.var6": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": 1
|
||||||
|
}
|
||||||
|
}
|
1
tests/dictionaries/00_6choice/makedict/mandatory.json
Normal file
1
tests/dictionaries/00_6choice/makedict/mandatory.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
["rougail.var1", "rougail.var2"]
|
15
tests/dictionaries/00_6choice/tiramisu/base.py
Normal file
15
tests/dictionaries/00_6choice/tiramisu/base.py
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_2 = ChoiceOption(name="var1", doc="the first variable", values=("a", "b", "c"), properties=frozenset({"basic", "mandatory"}))
|
||||||
|
option_3 = ChoiceOption(name="var2", doc="the second variable", values=("a", "b", "c"), properties=frozenset({"basic", "mandatory"}))
|
||||||
|
option_4 = ChoiceOption(name="var3", doc="the third variable", values=("a", "b", "c", None), properties=frozenset({"standard"}))
|
||||||
|
option_5 = ChoiceOption(name="var4", doc="the forth variable", values=(None, "b", "c"), properties=frozenset({"standard"}))
|
||||||
|
option_6 = ChoiceOption(name="var5", doc="the fifth variable", values=("a", "b", "c"), default="a", properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_7 = ChoiceOption(name="var6", doc="the sixth variable", values=(1, 2, 3), default=1, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", children=[option_2, option_3, option_4, option_5, option_6, option_7], properties=frozenset({"basic"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
24
tests/dictionaries/00_6choice/tiramisu/multi.py
Normal file
24
tests/dictionaries/00_6choice/tiramisu/multi.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_3 = ChoiceOption(name="var1", doc="the first variable", values=("a", "b", "c"), properties=frozenset({"basic", "mandatory"}))
|
||||||
|
option_4 = ChoiceOption(name="var2", doc="the second variable", values=("a", "b", "c"), properties=frozenset({"basic", "mandatory"}))
|
||||||
|
option_5 = ChoiceOption(name="var3", doc="the third variable", values=("a", "b", "c", None), properties=frozenset({"standard"}))
|
||||||
|
option_6 = ChoiceOption(name="var4", doc="the forth variable", values=(None, "b", "c"), properties=frozenset({"standard"}))
|
||||||
|
option_7 = ChoiceOption(name="var5", doc="the fifth variable", values=("a", "b", "c"), default="a", properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_8 = ChoiceOption(name="var6", doc="the sixth variable", values=(1, 2, 3), default=1, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", children=[option_3, option_4, option_5, option_6, option_7, option_8], properties=frozenset({"basic"}))
|
||||||
|
optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"basic"}))
|
||||||
|
option_11 = ChoiceOption(name="var1", doc="the first variable", values=("a", "b", "c"), properties=frozenset({"basic", "mandatory"}))
|
||||||
|
option_12 = ChoiceOption(name="var2", doc="the second variable", values=("a", "b", "c"), properties=frozenset({"basic", "mandatory"}))
|
||||||
|
option_13 = ChoiceOption(name="var3", doc="the third variable", values=("a", "b", "c", None), properties=frozenset({"standard"}))
|
||||||
|
option_14 = ChoiceOption(name="var4", doc="the forth variable", values=(None, "b", "c"), properties=frozenset({"standard"}))
|
||||||
|
option_15 = ChoiceOption(name="var5", doc="the fifth variable", values=("a", "b", "c"), default="a", properties=frozenset({"mandatory", "standard"}))
|
||||||
|
option_16 = ChoiceOption(name="var6", doc="the sixth variable", values=(1, 2, 3), default=1, properties=frozenset({"mandatory", "standard"}))
|
||||||
|
optiondescription_10 = OptionDescription(name="rougail", doc="Rougail", children=[option_11, option_12, option_13, option_14, option_15, option_16], properties=frozenset({"basic"}))
|
||||||
|
optiondescription_9 = OptionDescription(name="2", doc="2", children=[optiondescription_10], properties=frozenset({"basic"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_9])
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue