Compare commits
3 commits
4660a65303
...
5ff71c5ecb
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ff71c5ecb | |||
| 84e36d57e4 | |||
| 728e53e16e |
279 changed files with 1106 additions and 63 deletions
13
CHANGELOG.md
Normal file
13
CHANGELOG.md
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
## 1.0.2 (2024-01-28)
|
||||
|
||||
### Fix
|
||||
|
||||
- 2023 => 2024
|
||||
- correction for calculated variable with a variable in a dynamic family
|
||||
|
||||
## 1.0.1 (2024-01-28)
|
||||
|
||||
### Feat
|
||||
|
||||
- documentation
|
||||
- new format 1.0
|
||||
40
pyproject.toml
Normal file
40
pyproject.toml
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
[build-system]
|
||||
build-backend = "flit_core.buildapi"
|
||||
requires = ["flit_core >=3.8.0,<4"]
|
||||
|
||||
[project]
|
||||
name = "rougail"
|
||||
version = "1.0.2"
|
||||
authors = [
|
||||
{name = "Emmanuel Garette", email = "gnunux@gnunux.info"},
|
||||
]
|
||||
description = "A consistency handling system that was initially designed in the configuration management"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.8"
|
||||
classifiers = [
|
||||
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Operating System :: OS Independent",
|
||||
"Natural Language :: English",
|
||||
"Natural Language :: French",
|
||||
|
||||
]
|
||||
dependencies = [
|
||||
"pyyaml ~= 6.0.1",
|
||||
"pydantic ~= 2.5.2",
|
||||
"jinja2 ~= 3.1.2",
|
||||
]
|
||||
[project.optional-dependancies]
|
||||
dev = [
|
||||
"pylint ~= 3.0.3",
|
||||
]
|
||||
|
||||
[tool.commitizen]
|
||||
name = "cz_conventional_commits"
|
||||
tag_format = "$version"
|
||||
version_scheme = "semver"
|
||||
version_provider = "pep621"
|
||||
update_changelog_on_bump = true
|
||||
|
|
@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2023
|
||||
Copyright (C) 2022-2024
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2023
|
||||
Copyright (C) 2022-2024
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2023
|
||||
Copyright (C) 2022-2024
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2023
|
||||
Copyright (C) 2022-2024
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2023
|
||||
Copyright (C) 2022-2024
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2023
|
||||
Copyright (C) 2022-2024
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2023
|
||||
Copyright (C) 2022-2024
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2023
|
||||
Copyright (C) 2022-2024
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
|
@ -47,6 +47,7 @@ import logging
|
|||
from pathlib import Path
|
||||
from typing import Optional, Union, get_type_hints, Any, Literal, List, Dict, Iterator, Tuple
|
||||
from itertools import chain
|
||||
from re import findall
|
||||
|
||||
from yaml import safe_load
|
||||
from pydantic import ValidationError
|
||||
|
|
@ -124,9 +125,28 @@ class Paths:
|
|||
) -> Any:
|
||||
suffix = None
|
||||
dynamic_path = None
|
||||
dynamic_variable_path = None
|
||||
if not path in self._data:
|
||||
for dynamic in self._dynamics:
|
||||
if path.startswith(dynamic):
|
||||
if "{{ suffix }}" in dynamic:
|
||||
regexp = "^" + dynamic.replace('{{ suffix }}', '(.*)') + '.'
|
||||
finded = findall(regexp, path)
|
||||
if len(finded) != 1:
|
||||
continue
|
||||
splitted_dynamic = dynamic.split('.')
|
||||
splitted_path = path.split('.')
|
||||
for idx, s in enumerate(splitted_dynamic):
|
||||
if '{{ suffix }}' in s:
|
||||
break
|
||||
|
||||
suffix_path = '.'.join(splitted_path[idx + 1:])
|
||||
if suffix_path:
|
||||
suffix_path = "." + suffix_path
|
||||
suffix = splitted_path[idx] + suffix_path
|
||||
dynamic_path = dynamic
|
||||
dynamic_variable_path = dynamic + suffix_path
|
||||
break
|
||||
elif path.startswith(dynamic):
|
||||
subpaths = path[len(dynamic) :].split(".", 1)
|
||||
if (
|
||||
subpaths[0]
|
||||
|
|
@ -136,15 +156,16 @@ class Paths:
|
|||
suffix = (
|
||||
dynamic.rsplit(".", 1)[-1] + subpaths[0] + "." + subpaths[1]
|
||||
)
|
||||
dynamic_path = dynamic + "." + subpaths[1]
|
||||
break
|
||||
if suffix:
|
||||
dynamic_path = dynamic
|
||||
dynamic_variable_path = dynamic + "." + subpaths[1]
|
||||
break
|
||||
if suffix is None and not path in self._data:
|
||||
return None, None
|
||||
if suffix and dynamic_path:
|
||||
path = dynamic_path
|
||||
return self._data[path], suffix
|
||||
return None, None, None
|
||||
dynamic = None
|
||||
if suffix and dynamic_variable_path:
|
||||
path = dynamic_variable_path
|
||||
dynamic = self._data[dynamic_path]
|
||||
return self._data[path], suffix, dynamic
|
||||
|
||||
def __getitem__(
|
||||
self,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2023
|
||||
Copyright (C) 2022-2024
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2023
|
||||
Copyright (C) 2022-2024
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
"""Rougail object model
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2023
|
||||
Copyright (C) 2023-2024
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ class Calculation(BaseModel):
|
|||
param = param_obj.model_dump()
|
||||
if param.get("type") == "variable":
|
||||
variable_path = self.get_realpath(param["variable"])
|
||||
variable, suffix = objectspace.paths.get_with_dynamic(variable_path)
|
||||
variable, suffix, dynamic = objectspace.paths.get_with_dynamic(variable_path)
|
||||
if not variable:
|
||||
if not param.get("optional"):
|
||||
raise Exception(f"cannot find {variable_path}")
|
||||
|
|
@ -95,6 +95,7 @@ class Calculation(BaseModel):
|
|||
param["variable"] = variable
|
||||
if suffix:
|
||||
param["suffix"] = suffix
|
||||
param["dynamic"] = dynamic
|
||||
if param.get("type") == "information":
|
||||
if param["variable"]:
|
||||
variable_path = self.get_realpath(param["variable"])
|
||||
|
|
@ -147,7 +148,7 @@ class JinjaCalculation(Calculation):
|
|||
default["params"] |= self.get_params(objectspace)
|
||||
if params:
|
||||
default["params"] |= params
|
||||
for sub_variable, suffix, true_path in get_jinja_variable_to_param(
|
||||
for sub_variable, suffix, true_path, dynamic in get_jinja_variable_to_param(
|
||||
self.jinja,
|
||||
objectspace,
|
||||
variable.xmlfiles,
|
||||
|
|
@ -161,6 +162,7 @@ class JinjaCalculation(Calculation):
|
|||
}
|
||||
if suffix:
|
||||
default["params"][true_path]["suffix"] = suffix
|
||||
default["params"][true_path]["dynamic"] = dynamic
|
||||
return default
|
||||
|
||||
def to_function(
|
||||
|
|
@ -230,7 +232,7 @@ class VariableCalculation(Calculation):
|
|||
objectspace,
|
||||
) -> dict:
|
||||
variable_path = self.get_realpath(self.variable)
|
||||
variable, suffix = objectspace.paths.get_with_dynamic(variable_path)
|
||||
variable, suffix, dynamic = objectspace.paths.get_with_dynamic(variable_path)
|
||||
if not variable:
|
||||
raise Exception(f"pffff {variable_path}")
|
||||
if not isinstance(variable, objectspace.variable):
|
||||
|
|
@ -242,6 +244,7 @@ class VariableCalculation(Calculation):
|
|||
}
|
||||
if suffix:
|
||||
param["suffix"] = suffix
|
||||
param["dynamic"] = dynamic
|
||||
params = {None: [param]}
|
||||
function = "calc_value"
|
||||
help_function = None
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2023
|
||||
Copyright (C) 2022-2024
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2023
|
||||
Copyright (C) 2022-2024
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2023
|
||||
Copyright (C) 2022-2024
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2023
|
||||
Copyright (C) 2022-2024
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
|
@ -393,6 +393,7 @@ class Common:
|
|||
param["variable"],
|
||||
param.get("propertyerror", True),
|
||||
param.get("suffix"),
|
||||
param.get("dynamic"),
|
||||
)
|
||||
if param["type"] == "any":
|
||||
if isinstance(param["value"], str):
|
||||
|
|
@ -407,6 +408,7 @@ class Common:
|
|||
param,
|
||||
propertyerror,
|
||||
suffix: Optional[str],
|
||||
dynamic,
|
||||
) -> str:
|
||||
"""build variable parameters"""
|
||||
if param.path == self.elt.path:
|
||||
|
|
@ -417,7 +419,7 @@ class Common:
|
|||
params = [f"{option_name}"]
|
||||
if suffix is not None:
|
||||
param_type = "ParamDynOption"
|
||||
family = self.tiramisu.reflector_objects[param.path.rsplit(".", 1)[0]].get(
|
||||
family = self.tiramisu.reflector_objects[dynamic.path].get(
|
||||
self.calls, self.elt.path
|
||||
)
|
||||
params.extend([f"'{suffix}'", f"{family}"])
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2023
|
||||
Copyright (C) 2022-2024
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2023
|
||||
Copyright (C) 2022-2024
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
|
@ -112,8 +112,8 @@ def get_jinja_variable_to_param(
|
|||
variables = list(variables)
|
||||
variables.sort()
|
||||
for variable_path in variables:
|
||||
variable, suffix = objectspace.paths.get_with_dynamic(
|
||||
variable, suffix, dynamic = objectspace.paths.get_with_dynamic(
|
||||
get_realpath(variable_path, path_prefix)
|
||||
)
|
||||
if variable and variable.path in objectspace.variables:
|
||||
yield variable, suffix, variable_path
|
||||
yield variable, suffix, variable_path, dynamic
|
||||
|
|
|
|||
1
tests/dictionaries/00empty/makedict/mandatory.json
Normal file
1
tests/dictionaries/00empty/makedict/mandatory.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
["rougail.empty"]
|
||||
1
tests/dictionaries/00load_notype/makedict/mandatory.json
Normal file
1
tests/dictionaries/00load_notype/makedict/mandatory.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
1
tests/dictionaries/00load_save/makedict/mandatory.json
Normal file
1
tests/dictionaries/00load_save/makedict/mandatory.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
1
tests/dictionaries/01base_float/makedict/mandatory.json
Normal file
1
tests/dictionaries/01base_float/makedict/mandatory.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
1
tests/dictionaries/01base_multi/makedict/mandatory.json
Normal file
1
tests/dictionaries/01base_multi/makedict/mandatory.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
1
tests/dictionaries/01test/makedict/mandatory.json
Normal file
1
tests/dictionaries/01test/makedict/mandatory.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
1
tests/dictionaries/01test_multi/makedict/mandatory.json
Normal file
1
tests/dictionaries/01test_multi/makedict/mandatory.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
1
tests/dictionaries/10check_base/makedict/mandatory.json
Normal file
1
tests/dictionaries/10check_base/makedict/mandatory.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
["rougail.general.adresse_ip_eth0", "rougail.general.adresse_netmask_eth0", "rougail.general.adresse_ip"]
|
||||
|
|
@ -0,0 +1 @@
|
|||
["rougail.general.adresse_ip_eth0", "rougail.general.adresse_ip"]
|
||||
|
|
@ -0,0 +1 @@
|
|||
["rougail.general.adresse_ip_eth0", "rougail.general.adresse_netmask_eth0"]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
1
tests/dictionaries/10fill/makedict/mandatory.json
Normal file
1
tests/dictionaries/10fill/makedict/mandatory.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
1
tests/dictionaries/10fill_quote/makedict/mandatory.json
Normal file
1
tests/dictionaries/10fill_quote/makedict/mandatory.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
["rougail.general.leader.leader"]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue