Compare commits
3 commits
4c6f451045
...
a7b3a4aff0
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a7b3a4aff0 | ||
![]() |
75bf8c791e | ||
![]() |
28a89e6b28 |
538 changed files with 496 additions and 1647 deletions
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -1,13 +0,0 @@
|
|||
## 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
|
|
@ -140,54 +140,3 @@ Let's execute `script.py`:
|
|||
{'rougail.my_variable': 'my_value', 'rougail.my_variable_jinja': 'no', 'example.my_variable_extra': 'my_value_extra'}
|
||||
|
||||
The value of the `my_variable_extra` variable is calculated, and it's value comes from the :func:`return_no` function.
|
||||
|
||||
|
||||
Create your own type
|
||||
----------------------
|
||||
|
||||
A variable has a type. This type enables the variable to define the values that are accepted by this variable.
|
||||
|
||||
There is a series of default types, but obviously not all cases are taken.
|
||||
|
||||
It's possible to create your own type.
|
||||
|
||||
Here an example to a lipogram option (in a string, we cannot use "e" character):
|
||||
|
||||
.. code-block:: python
|
||||
:caption: the `lipogram.py` file content
|
||||
|
||||
from tiramisu import StrOption
|
||||
class LipogramOption(StrOption):
|
||||
__slots__ = tuple()
|
||||
_type = 'lipogram'
|
||||
|
||||
def validate(self,
|
||||
value):
|
||||
super().validate(value)
|
||||
# verify that there is any 'e' in the sentense
|
||||
if 'e' in value:
|
||||
raise ValueError('Perec wrote a book without any "e", you could not do it in a simple sentence?')
|
||||
|
||||
To add the new lipogram type in Rougail:
|
||||
|
||||
.. code-block:: python
|
||||
>>> from rougail import Rougail, RougailConfig
|
||||
>>> RougailConfig['dictionaries_dir'] = ['dict']
|
||||
>>> RougailConfig['custom_types']['lipogram'] = LipogramOption
|
||||
|
||||
Now, we can use lipogram type.
|
||||
Here is a :file:`dict/00-base.yml` dictionary:
|
||||
|
||||
.. code-block:: yaml
|
||||
---
|
||||
version: '1.0'
|
||||
var:
|
||||
type: lipogram
|
||||
|
||||
.. code-block:: python
|
||||
>>> rougail = Rougail()
|
||||
>>> config = rougail.get_config()
|
||||
>>> config.option('rougail.var').value.set('blah')
|
||||
>>> config.option('rougail.var').value.set('I just want to add a quality string that has no bad characters')
|
||||
[...]
|
||||
tiramisu.error.ValueOptionError: "I just want to add a quality string that has no bad characters" is an invalid lipogram for "var", Perec wrote a book without any "e", you could not do it in a simple sentence?
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
[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-2024
|
||||
Copyright (C) 2022-2023
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
@ -28,12 +28,10 @@ along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
"""
|
||||
from tiramisu import Config
|
||||
from copy import copy
|
||||
|
||||
from .convert import RougailConvert
|
||||
from .config import RougailConfig
|
||||
from .update import RougailUpgrade
|
||||
from .object_model import CONVERT_OPTION
|
||||
|
||||
|
||||
def tiramisu_display_name(kls) -> str:
|
||||
|
@ -48,7 +46,7 @@ class Rougail:
|
|||
|
||||
def __init__(
|
||||
self,
|
||||
rougailconfig=None,
|
||||
rougailconfig = None,
|
||||
) -> None:
|
||||
if rougailconfig is None:
|
||||
rougailconfig = RougailConfig
|
||||
|
@ -68,8 +66,7 @@ class Rougail:
|
|||
if not self.config:
|
||||
tiram_obj = self.converted.save(self.rougailconfig["tiramisu_cache"])
|
||||
optiondescription = {}
|
||||
custom_types = {custom.__name__: custom for custom in self.rougailconfig["custom_types"].values()}
|
||||
exec(tiram_obj, custom_types, optiondescription) # pylint: disable=W0122
|
||||
exec(tiram_obj, None, optiondescription) # pylint: disable=W0122
|
||||
self.config = Config(
|
||||
optiondescription["option_0"],
|
||||
display_name=tiramisu_display_name,
|
||||
|
@ -78,4 +75,4 @@ class Rougail:
|
|||
return self.config
|
||||
|
||||
|
||||
__ALL__ = ("Rougail", "RougailConfig", "RougailUpgrade")
|
||||
__ALL__ = ("Rougail", "RougailConvert", "RougailConfig", "RougailUpgrade")
|
||||
|
|
|
@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2024
|
||||
Copyright (C) 2022-2023
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
@ -27,12 +27,27 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
"""
|
||||
from .variable import CONVERT_OPTION
|
||||
import importlib.resources
|
||||
from os.path import isfile
|
||||
from ..utils import load_modules
|
||||
|
||||
|
||||
ANNOTATORS = None
|
||||
#
|
||||
#
|
||||
# if not 'files' in dir(importlib.resources):
|
||||
# # old python version
|
||||
# class fake_files:
|
||||
# def __init__(self, package):
|
||||
# self.mod = []
|
||||
# dir_package = dirname(importlib.resources._get_package(package).__file__)
|
||||
# for mod in importlib.resources.contents(package):
|
||||
# self.mod.append(join(dir_package, mod))
|
||||
#
|
||||
# def iterdir(self):
|
||||
# return self.mod
|
||||
# importlib.resources.files = fake_files
|
||||
|
||||
|
||||
def get_level(module):
|
||||
|
@ -86,4 +101,4 @@ class SpaceAnnotator: # pylint: disable=R0903
|
|||
annotator(objectspace)
|
||||
|
||||
|
||||
__all__ = ("SpaceAnnotator",)
|
||||
__all__ = ("SpaceAnnotator", "CONVERT_OPTION")
|
||||
|
|
|
@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2024
|
||||
Copyright (C) 2022-2023
|
||||
|
||||
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-2024
|
||||
Copyright (C) 2022-2023
|
||||
|
||||
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-2024
|
||||
Copyright (C) 2022-2023
|
||||
|
||||
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-2024
|
||||
Copyright (C) 2022-2023
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
@ -33,6 +33,58 @@ from rougail.error import DictConsistencyError
|
|||
from rougail.object_model import Calculation
|
||||
|
||||
|
||||
def convert_boolean(value: str) -> bool:
|
||||
"""Boolean coercion. The Rougail XML may contain srings like `True` or `False`"""
|
||||
if isinstance(value, bool):
|
||||
return value
|
||||
value = value.lower()
|
||||
if value == "true":
|
||||
return True
|
||||
elif value == "false":
|
||||
return False
|
||||
raise Exception(f"unknown boolean value {value}")
|
||||
|
||||
|
||||
CONVERT_OPTION = {
|
||||
"string": dict(opttype="StrOption"),
|
||||
"number": dict(opttype="IntOption", func=int),
|
||||
"float": dict(opttype="FloatOption", func=float),
|
||||
"boolean": dict(opttype="BoolOption", func=convert_boolean),
|
||||
"secret": dict(opttype="PasswordOption"),
|
||||
"mail": dict(opttype="EmailOption"),
|
||||
"unix_filename": dict(opttype="FilenameOption"),
|
||||
"date": dict(opttype="DateOption"),
|
||||
"unix_user": dict(opttype="UsernameOption"),
|
||||
"ip": dict(opttype="IPOption", initkwargs={"allow_reserved": True}),
|
||||
"cidr": dict(opttype="IPOption", initkwargs={"cidr": True}),
|
||||
"netmask": dict(opttype="NetmaskOption"),
|
||||
"network": dict(opttype="NetworkOption"),
|
||||
"network_cidr": dict(opttype="NetworkOption", initkwargs={"cidr": True}),
|
||||
"broadcast": dict(opttype="BroadcastOption"),
|
||||
"netbios": dict(
|
||||
opttype="DomainnameOption",
|
||||
initkwargs={"type": "netbios", "warnings_only": True},
|
||||
),
|
||||
"domainname": dict(
|
||||
opttype="DomainnameOption", initkwargs={"type": "domainname", "allow_ip": False}
|
||||
),
|
||||
"hostname": dict(
|
||||
opttype="DomainnameOption", initkwargs={"type": "hostname", "allow_ip": False}
|
||||
),
|
||||
"web_address": dict(
|
||||
opttype="URLOption", initkwargs={"allow_ip": False, "allow_without_dot": True}
|
||||
),
|
||||
"port": dict(opttype="PortOption", initkwargs={"allow_private": True}),
|
||||
"mac": dict(opttype="MACOption"),
|
||||
"unix_permissions": dict(
|
||||
opttype="PermissionsOption", initkwargs={"warnings_only": True}, func=int
|
||||
),
|
||||
"choice": dict(opttype="ChoiceOption"),
|
||||
#
|
||||
"symlink": dict(opttype="SymLinkOption"),
|
||||
}
|
||||
|
||||
|
||||
class Walk:
|
||||
"""Walk to objectspace to find variable or family"""
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2024
|
||||
Copyright (C) 2022-2023
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
@ -77,5 +77,4 @@ RougailConfig = {
|
|||
"force_convert_dyn_option_description": False,
|
||||
"suffix": "",
|
||||
"tiramisu_cache": None,
|
||||
"custom_types": {},
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
"""Takes a bunch of Rougail YAML dispatched in differents folders
|
||||
"""Takes a bunch of Rougail XML dispatched in differents folders
|
||||
as an input and outputs a Tiramisu's file.
|
||||
|
||||
Created by:
|
||||
|
@ -10,7 +10,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2024
|
||||
Copyright (C) 2022-2023
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
@ -27,22 +27,26 @@ GNU General Public License for more details.
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sample usage::
|
||||
|
||||
>>> from rougail import RougailConvert
|
||||
>>> rougail = RougailConvert()
|
||||
>>> tiramisu = rougail.save('tiramisu.py')
|
||||
|
||||
The Rougail
|
||||
|
||||
- loads the XML into an internal RougailObjSpace representation
|
||||
- visits/annotates the objects
|
||||
- dumps the object space as Tiramisu string
|
||||
|
||||
The visit/annotation stage is a complex step that corresponds to the Rougail
|
||||
procedures.
|
||||
"""
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import (
|
||||
Optional,
|
||||
Union,
|
||||
get_type_hints,
|
||||
Any,
|
||||
Literal,
|
||||
List,
|
||||
Dict,
|
||||
Iterator,
|
||||
Tuple,
|
||||
)
|
||||
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
|
||||
|
@ -52,15 +56,13 @@ from .annotator import SpaceAnnotator
|
|||
from .tiramisureflector import TiramisuReflector
|
||||
from .utils import get_realpath
|
||||
from .object_model import (
|
||||
CONVERT_OPTION,
|
||||
Family,
|
||||
Dynamic,
|
||||
_Variable,
|
||||
Variable,
|
||||
Choice,
|
||||
SymLink,
|
||||
CALCULATION_TYPES,
|
||||
Calculation,
|
||||
VariableCalculation,
|
||||
PARAM_TYPES,
|
||||
AnyParam,
|
||||
)
|
||||
|
@ -98,7 +100,7 @@ class Property:
|
|||
|
||||
class Paths:
|
||||
def __init__(self) -> None:
|
||||
self._data: Dict[str, Union[_Variable, Family]] = {}
|
||||
self._data: Dict[str, Union[Variable, Family]] = {}
|
||||
self._dynamics: List[str] = []
|
||||
self.path_prefix = None
|
||||
|
||||
|
@ -122,28 +124,9 @@ class Paths:
|
|||
) -> Any:
|
||||
suffix = None
|
||||
dynamic_path = None
|
||||
dynamic_variable_path = None
|
||||
if not path in self._data:
|
||||
for dynamic in self._dynamics:
|
||||
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):
|
||||
if path.startswith(dynamic):
|
||||
subpaths = path[len(dynamic) :].split(".", 1)
|
||||
if (
|
||||
subpaths[0]
|
||||
|
@ -153,21 +136,20 @@ class Paths:
|
|||
suffix = (
|
||||
dynamic.rsplit(".", 1)[-1] + subpaths[0] + "." + subpaths[1]
|
||||
)
|
||||
dynamic_path = dynamic
|
||||
dynamic_variable_path = dynamic + "." + subpaths[1]
|
||||
dynamic_path = dynamic + "." + subpaths[1]
|
||||
break
|
||||
if suffix:
|
||||
break
|
||||
if suffix is None and not path in self._data:
|
||||
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
|
||||
return None, None
|
||||
if suffix and dynamic_path:
|
||||
path = dynamic_path
|
||||
return self._data[path], suffix
|
||||
|
||||
def __getitem__(
|
||||
self,
|
||||
path: str,
|
||||
) -> Union[Family, _Variable]:
|
||||
) -> Union[Family, Variable]:
|
||||
if not path in self._data:
|
||||
raise AttributeError(f"cannot find variable or family {path}")
|
||||
return self._data[path]
|
||||
|
@ -235,6 +217,7 @@ class ParserVariable:
|
|||
#
|
||||
self.family = Family
|
||||
self.dynamic = Dynamic
|
||||
self.variable = Variable
|
||||
self.choice = Choice
|
||||
#
|
||||
self.exclude_imports = []
|
||||
|
@ -246,23 +229,13 @@ class ParserVariable:
|
|||
self.is_init = False
|
||||
super().__init__()
|
||||
|
||||
def get_variable(self):
|
||||
convert_options = list(CONVERT_OPTION)
|
||||
convert_options.extend(self.rougailconfig["custom_types"])
|
||||
|
||||
class Variable(_Variable):
|
||||
type: Literal[*convert_options] = convert_options[0]
|
||||
|
||||
return Variable
|
||||
|
||||
def init(self):
|
||||
if self.is_init:
|
||||
return
|
||||
self.variable = self.get_variable()
|
||||
hint = get_type_hints(self.dynamic)
|
||||
self.family_types = hint["type"].__args__ # pylint: disable=W0201
|
||||
self.family_attrs = frozenset( # pylint: disable=W0201
|
||||
set(hint) - {"name", "path", "xmlfiles"} | {"redefine"}
|
||||
set(hint) | {"redefine"} - {"name", "path", "xmlfiles"}
|
||||
)
|
||||
self.family_calculations = self.search_calculation( # pylint: disable=W0201
|
||||
hint
|
||||
|
@ -273,7 +246,7 @@ class ParserVariable:
|
|||
#
|
||||
hint = get_type_hints(self.choice)
|
||||
self.choice_attrs = frozenset( # pylint: disable=W0201
|
||||
set(hint) - {"name", "path", "xmlfiles"} | {"redefine", "exists"}
|
||||
set(hint) | {"redefine", "exists"} - {"name", "path", "xmlfiles"}
|
||||
)
|
||||
self.choice_calculations = self.search_calculation( # pylint: disable=W0201
|
||||
hint
|
||||
|
@ -317,7 +290,7 @@ class ParserVariable:
|
|||
if isinstance(value, dict) and not self.is_calculation(
|
||||
key,
|
||||
value,
|
||||
self.choice_calculations,
|
||||
"variable",
|
||||
False,
|
||||
):
|
||||
break
|
||||
|
@ -383,7 +356,8 @@ class ParserVariable:
|
|||
family_is_leadership: bool = False,
|
||||
family_is_dynamic: bool = False,
|
||||
) -> None:
|
||||
"""Parse a family"""
|
||||
""" Parse a family
|
||||
"""
|
||||
if obj is None:
|
||||
return
|
||||
family_obj = {}
|
||||
|
@ -397,11 +371,10 @@ class ParserVariable:
|
|||
else:
|
||||
subfamily_obj[key] = value
|
||||
if path in self.paths:
|
||||
# it's just for modify subfamily or subvariable, do not redefine
|
||||
if family_obj:
|
||||
if not obj.pop("redefine", False):
|
||||
raise Exception(
|
||||
f"The family {path} already exists and she is not redefined in {filemane}"
|
||||
"The family {path} already exists and she is not redefined"
|
||||
)
|
||||
self.paths.add(
|
||||
path,
|
||||
|
@ -456,7 +429,8 @@ class ParserVariable:
|
|||
self,
|
||||
obj: Dict[str, Any],
|
||||
) -> Iterator[str]:
|
||||
"""List attributes"""
|
||||
""" List attributes
|
||||
"""
|
||||
force_to_variable = []
|
||||
for key, value in obj.items():
|
||||
if key in force_to_variable:
|
||||
|
@ -472,7 +446,7 @@ class ParserVariable:
|
|||
if isinstance(value, dict) and not self.is_calculation(
|
||||
key,
|
||||
value,
|
||||
self.family_calculations,
|
||||
"family",
|
||||
False,
|
||||
):
|
||||
# it's a dict, so a new variables!
|
||||
|
@ -488,7 +462,8 @@ class ParserVariable:
|
|||
filenames: Union[str, List[str]],
|
||||
family_is_dynamic: bool,
|
||||
) -> None:
|
||||
"""Add a new family"""
|
||||
""" Add a new family
|
||||
"""
|
||||
family["path"] = path
|
||||
if not isinstance(filenames, list):
|
||||
filenames = [filenames]
|
||||
|
@ -508,7 +483,7 @@ class ParserVariable:
|
|||
if not self.is_calculation(
|
||||
key,
|
||||
value,
|
||||
self.family_calculations,
|
||||
"family",
|
||||
False,
|
||||
):
|
||||
continue
|
||||
|
@ -553,7 +528,8 @@ class ParserVariable:
|
|||
family_is_leadership: bool = False,
|
||||
family_is_dynamic: bool = False,
|
||||
) -> None:
|
||||
"""Parse variable"""
|
||||
""" Parse variable
|
||||
"""
|
||||
if obj is None:
|
||||
obj = {}
|
||||
extra_attrs = set(obj) - self.choice_attrs
|
||||
|
@ -569,9 +545,7 @@ class ParserVariable:
|
|||
return
|
||||
if not obj.pop("redefine", False):
|
||||
raise Exception(f'Variable "{path}" already exists')
|
||||
self.paths.add(
|
||||
path, self.paths[path].model_copy(update=obj), False, force=True
|
||||
)
|
||||
self.paths.add(path, self.paths[path].model_copy(update=obj), False, force=True)
|
||||
self.paths[path].xmlfiles.append(filename)
|
||||
else:
|
||||
if "exists" in obj and obj.pop("exists"):
|
||||
|
@ -602,7 +576,7 @@ class ParserVariable:
|
|||
if self.is_calculation(
|
||||
key,
|
||||
value,
|
||||
self.choice_calculations,
|
||||
"variable",
|
||||
False,
|
||||
):
|
||||
try:
|
||||
|
@ -623,7 +597,7 @@ class ParserVariable:
|
|||
if not self.is_calculation(
|
||||
key,
|
||||
val,
|
||||
self.choice_calculations,
|
||||
"variable",
|
||||
True,
|
||||
):
|
||||
continue
|
||||
|
@ -643,7 +617,8 @@ class ParserVariable:
|
|||
) from err
|
||||
|
||||
def parse_params(self, path, obj):
|
||||
"""Parse variable params"""
|
||||
""" Parse variable params
|
||||
"""
|
||||
if "params" not in obj:
|
||||
return
|
||||
if not isinstance(obj["params"], dict):
|
||||
|
@ -653,9 +628,7 @@ class ParserVariable:
|
|||
try:
|
||||
params.append(AnyParam(key=key, value=val, type="any"))
|
||||
except ValidationError as err:
|
||||
raise Exception(
|
||||
f'"{key}" has an invalid "params" for {path}: {err}'
|
||||
) from err
|
||||
raise Exception(f'"{key}" has an invalid "params" for {path}: {err}') from err
|
||||
obj["params"] = params
|
||||
|
||||
def add_variable(
|
||||
|
@ -708,7 +681,7 @@ class ParserVariable:
|
|||
###############################################################################################
|
||||
def set_name(
|
||||
self,
|
||||
obj: Union[_Variable, Family],
|
||||
obj: Union[Variable, Family],
|
||||
option_prefix: str,
|
||||
):
|
||||
"""Set Tiramisu object name"""
|
||||
|
@ -724,10 +697,14 @@ class ParserVariable:
|
|||
self,
|
||||
attribute: str,
|
||||
value: dict,
|
||||
calculations: list,
|
||||
typ: Literal["variable", "family"],
|
||||
inside_list: bool,
|
||||
):
|
||||
"""Check if it's a calculation"""
|
||||
if typ == "variable":
|
||||
calculations = self.choice_calculations
|
||||
else:
|
||||
calculations = self.family_calculations
|
||||
if inside_list:
|
||||
calculations = calculations[0]
|
||||
else:
|
||||
|
@ -809,9 +786,7 @@ class RougailConvert(ParserVariable):
|
|||
inside_list = []
|
||||
outside_list = []
|
||||
for key, value in hint.items():
|
||||
if "Union" in value.__class__.__name__ and (
|
||||
Calculation in value.__args__ or VariableCalculation in value.__args__
|
||||
):
|
||||
if "Union" in value.__class__.__name__ and Calculation in value.__args__:
|
||||
outside_list.append(key)
|
||||
if (
|
||||
"Union" in value.__class__.__name__
|
||||
|
@ -939,9 +914,7 @@ class RougailConvert(ParserVariable):
|
|||
f"pffff version ... {version} not in {self.supported_version}"
|
||||
)
|
||||
|
||||
def annotate(
|
||||
self,
|
||||
):
|
||||
def annotate(self):
|
||||
"""Apply annotation"""
|
||||
if not self.paths.has_value():
|
||||
self.parse_directories()
|
||||
|
@ -967,7 +940,7 @@ class RougailConvert(ParserVariable):
|
|||
|
||||
def save(
|
||||
self,
|
||||
filename: str,
|
||||
filename: None,
|
||||
):
|
||||
"""Return tiramisu object declaration as a string"""
|
||||
self.annotate()
|
||||
|
@ -976,5 +949,5 @@ class RougailConvert(ParserVariable):
|
|||
if filename:
|
||||
with open(filename, "w", encoding="utf-8") as tiramisu:
|
||||
tiramisu.write(output)
|
||||
# print(output)
|
||||
# print(output)
|
||||
return output
|
||||
|
|
|
@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2024
|
||||
Copyright (C) 2022-2023
|
||||
|
||||
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-2024
|
||||
Copyright (C) 2022-2023
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Rougail object model
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2023-2024
|
||||
Copyright (C) 2023
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
@ -21,77 +21,16 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||
"""
|
||||
|
||||
from typing import Optional, Union, get_type_hints, Any, Literal, List, Dict, Iterator
|
||||
from pydantic import (
|
||||
BaseModel,
|
||||
StrictBool,
|
||||
StrictInt,
|
||||
StrictFloat,
|
||||
StrictStr,
|
||||
ConfigDict,
|
||||
)
|
||||
from pydantic import BaseModel, StrictBool, StrictInt, StrictFloat, StrictStr
|
||||
from .utils import get_jinja_variable_to_param, get_realpath
|
||||
|
||||
|
||||
BASETYPE = Union[StrictBool, StrictInt, StrictFloat, StrictStr, None]
|
||||
|
||||
|
||||
def convert_boolean(value: str) -> bool:
|
||||
"""Boolean coercion. The Rougail XML may contain srings like `True` or `False`"""
|
||||
if isinstance(value, bool):
|
||||
return value
|
||||
value = value.lower()
|
||||
if value == "true":
|
||||
return True
|
||||
elif value == "false":
|
||||
return False
|
||||
raise Exception(f"unknown boolean value {value}")
|
||||
|
||||
|
||||
CONVERT_OPTION = {
|
||||
"string": dict(opttype="StrOption"),
|
||||
"number": dict(opttype="IntOption", func=int),
|
||||
"float": dict(opttype="FloatOption", func=float),
|
||||
"boolean": dict(opttype="BoolOption", func=convert_boolean),
|
||||
"secret": dict(opttype="PasswordOption"),
|
||||
"mail": dict(opttype="EmailOption"),
|
||||
"unix_filename": dict(opttype="FilenameOption"),
|
||||
"date": dict(opttype="DateOption"),
|
||||
"unix_user": dict(opttype="UsernameOption"),
|
||||
"ip": dict(opttype="IPOption", initkwargs={"allow_reserved": True}),
|
||||
"cidr": dict(opttype="IPOption", initkwargs={"cidr": True}),
|
||||
"netmask": dict(opttype="NetmaskOption"),
|
||||
"network": dict(opttype="NetworkOption"),
|
||||
"network_cidr": dict(opttype="NetworkOption", initkwargs={"cidr": True}),
|
||||
"broadcast": dict(opttype="BroadcastOption"),
|
||||
"netbios": dict(
|
||||
opttype="DomainnameOption",
|
||||
initkwargs={"type": "netbios", "warnings_only": True},
|
||||
),
|
||||
"domainname": dict(
|
||||
opttype="DomainnameOption", initkwargs={"type": "domainname", "allow_ip": False}
|
||||
),
|
||||
"hostname": dict(
|
||||
opttype="DomainnameOption", initkwargs={"type": "hostname", "allow_ip": False}
|
||||
),
|
||||
"web_address": dict(
|
||||
opttype="URLOption", initkwargs={"allow_ip": False, "allow_without_dot": True}
|
||||
),
|
||||
"port": dict(opttype="PortOption", initkwargs={"allow_private": True}),
|
||||
"mac": dict(opttype="MACOption"),
|
||||
"unix_permissions": dict(
|
||||
opttype="PermissionsOption", initkwargs={"warnings_only": True}, func=int
|
||||
),
|
||||
"choice": dict(opttype="ChoiceOption"),
|
||||
#
|
||||
"symlink": dict(opttype="SymLinkOption"),
|
||||
}
|
||||
|
||||
|
||||
class Param(BaseModel):
|
||||
key: str
|
||||
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
|
||||
class AnyParam(Param):
|
||||
type: str
|
||||
|
@ -131,9 +70,6 @@ PARAM_TYPES = {
|
|||
class Calculation(BaseModel):
|
||||
path_prefix: Optional[str]
|
||||
path: str
|
||||
inside_list: bool
|
||||
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
def get_realpath(
|
||||
self,
|
||||
|
@ -149,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, dynamic = objectspace.paths.get_with_dynamic(variable_path)
|
||||
variable, suffix = objectspace.paths.get_with_dynamic(variable_path)
|
||||
if not variable:
|
||||
if not param.get("optional"):
|
||||
raise Exception(f"cannot find {variable_path}")
|
||||
|
@ -159,7 +95,6 @@ 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"])
|
||||
|
@ -179,6 +114,7 @@ class JinjaCalculation(Calculation):
|
|||
jinja: StrictStr
|
||||
params: Optional[List[Param]] = None
|
||||
return_type: BASETYPE = None
|
||||
inside_list: bool
|
||||
|
||||
def _jinja_to_function(
|
||||
self,
|
||||
|
@ -211,21 +147,20 @@ class JinjaCalculation(Calculation):
|
|||
default["params"] |= self.get_params(objectspace)
|
||||
if params:
|
||||
default["params"] |= params
|
||||
for sub_variable, suffix, true_path, dynamic in get_jinja_variable_to_param(
|
||||
for sub_variable, suffix, true_path in get_jinja_variable_to_param(
|
||||
self.jinja,
|
||||
objectspace,
|
||||
variable.xmlfiles,
|
||||
objectspace.functions,
|
||||
self.path_prefix,
|
||||
):
|
||||
if sub_variable.path in objectspace.variables:
|
||||
if isinstance(sub_variable, objectspace.variable):
|
||||
default["params"][true_path] = {
|
||||
"type": "variable",
|
||||
"variable": sub_variable,
|
||||
}
|
||||
if suffix:
|
||||
default["params"][true_path]["suffix"] = suffix
|
||||
default["params"][true_path]["dynamic"] = dynamic
|
||||
return default
|
||||
|
||||
def to_function(
|
||||
|
@ -288,13 +223,14 @@ class VariableCalculation(Calculation):
|
|||
]
|
||||
variable: StrictStr
|
||||
propertyerror: bool = True
|
||||
inside_list: bool
|
||||
|
||||
def to_function(
|
||||
self,
|
||||
objectspace,
|
||||
) -> dict:
|
||||
variable_path = self.get_realpath(self.variable)
|
||||
variable, suffix, dynamic = objectspace.paths.get_with_dynamic(variable_path)
|
||||
variable, suffix = objectspace.paths.get_with_dynamic(variable_path)
|
||||
if not variable:
|
||||
raise Exception(f"pffff {variable_path}")
|
||||
if not isinstance(variable, objectspace.variable):
|
||||
|
@ -306,7 +242,6 @@ class VariableCalculation(Calculation):
|
|||
}
|
||||
if suffix:
|
||||
param["suffix"] = suffix
|
||||
param["dynamic"] = dynamic
|
||||
params = {None: [param]}
|
||||
function = "calc_value"
|
||||
help_function = None
|
||||
|
@ -316,6 +251,10 @@ class VariableCalculation(Calculation):
|
|||
if variable.type != "boolean":
|
||||
raise Exception("only boolean!")
|
||||
params[None].insert(0, self.attribute_name)
|
||||
elif (
|
||||
self.attribute_name != "default" and variable.path not in objectspace.multis
|
||||
):
|
||||
raise Exception("pffff")
|
||||
if not self.inside_list and self.path in objectspace.multis:
|
||||
if (
|
||||
not objectspace.paths.is_dynamic(variable_path)
|
||||
|
@ -338,6 +277,7 @@ class InformationCalculation(Calculation):
|
|||
attribute_name: Literal["default"]
|
||||
information: StrictStr
|
||||
variable: Optional[StrictStr]
|
||||
inside_list: bool
|
||||
|
||||
def to_function(
|
||||
self,
|
||||
|
@ -406,15 +346,43 @@ class Family(BaseModel):
|
|||
xmlfiles: List[str] = []
|
||||
path: str
|
||||
|
||||
model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)
|
||||
class ConfigDict:
|
||||
arbitrary_types_allowed = True
|
||||
|
||||
|
||||
class Dynamic(Family):
|
||||
variable: str
|
||||
|
||||
|
||||
class _Variable(BaseModel):
|
||||
class Variable(BaseModel):
|
||||
name: str
|
||||
type: Literal[
|
||||
"number",
|
||||
"float",
|
||||
"string",
|
||||
"password",
|
||||
"secret",
|
||||
"mail",
|
||||
"boolean",
|
||||
"unix_filename",
|
||||
"date",
|
||||
"unix_user",
|
||||
"ip",
|
||||
"local_ip",
|
||||
"netmask",
|
||||
"network",
|
||||
"broadcast",
|
||||
"netbios",
|
||||
"domainname",
|
||||
"hostname",
|
||||
"web_address",
|
||||
"port",
|
||||
"mac",
|
||||
"cidr",
|
||||
"network_cidr",
|
||||
"choice",
|
||||
"unix_permissions",
|
||||
] = "string"
|
||||
description: Optional[str] = None
|
||||
default: Union[List[BASETYPE_CALC], BASETYPE_CALC] = None
|
||||
params: Optional[List[Param]] = None
|
||||
|
@ -431,19 +399,17 @@ class _Variable(BaseModel):
|
|||
xmlfiles: List[str] = []
|
||||
path: str
|
||||
|
||||
model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)
|
||||
class ConfigDict:
|
||||
arbitrary_types_allowed = True
|
||||
|
||||
|
||||
class Choice(_Variable):
|
||||
type: Literal["choice"] = "choice"
|
||||
class Choice(Variable):
|
||||
choices: Union[List[BASETYPE_CALC], Calculation]
|
||||
|
||||
|
||||
class SymLink(BaseModel):
|
||||
name: str
|
||||
type: Literal["symlink"] = "symlink"
|
||||
opt: _Variable
|
||||
type: str = "symlink"
|
||||
opt: Variable
|
||||
xmlfiles: List[str] = []
|
||||
path: str
|
||||
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
|
|
@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2024
|
||||
Copyright (C) 2022-2023
|
||||
|
||||
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-2024
|
||||
Copyright (C) 2022-2023
|
||||
|
||||
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-2024
|
||||
Copyright (C) 2022-2023
|
||||
|
||||
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-2024
|
||||
Copyright (C) 2022-2023
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
@ -33,9 +33,10 @@ from json import dumps
|
|||
from os.path import isfile, basename
|
||||
|
||||
from .i18n import _
|
||||
from .annotator import CONVERT_OPTION
|
||||
from .error import DictConsistencyError
|
||||
from .utils import normalize_family
|
||||
from .object_model import Calculation, CONVERT_OPTION
|
||||
from .object_model import Calculation
|
||||
|
||||
|
||||
class BaseElt: # pylint: disable=R0903
|
||||
|
@ -121,7 +122,7 @@ class TiramisuReflector:
|
|||
[
|
||||
"from jinja2 import StrictUndefined, DictLoader",
|
||||
"from jinja2.sandbox import SandboxedEnvironment",
|
||||
"from rougail import CONVERT_OPTION",
|
||||
"from rougail.annotator.variable import CONVERT_OPTION",
|
||||
"from tiramisu.error import ValueWarning",
|
||||
"def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):",
|
||||
" global ENV, CONVERT_OPTION",
|
||||
|
@ -392,7 +393,6 @@ class Common:
|
|||
param["variable"],
|
||||
param.get("propertyerror", True),
|
||||
param.get("suffix"),
|
||||
param.get("dynamic"),
|
||||
)
|
||||
if param["type"] == "any":
|
||||
if isinstance(param["value"], str):
|
||||
|
@ -407,7 +407,6 @@ class Common:
|
|||
param,
|
||||
propertyerror,
|
||||
suffix: Optional[str],
|
||||
dynamic,
|
||||
) -> str:
|
||||
"""build variable parameters"""
|
||||
if param.path == self.elt.path:
|
||||
|
@ -418,7 +417,7 @@ class Common:
|
|||
params = [f"{option_name}"]
|
||||
if suffix is not None:
|
||||
param_type = "ParamDynOption"
|
||||
family = self.tiramisu.reflector_objects[dynamic.path].get(
|
||||
family = self.tiramisu.reflector_objects[param.path.rsplit(".", 1)[0]].get(
|
||||
self.calls, self.elt.path
|
||||
)
|
||||
params.extend([f"'{suffix}'", f"{family}"])
|
||||
|
@ -470,10 +469,7 @@ class Variable(Common):
|
|||
tiramisu,
|
||||
):
|
||||
super().__init__(elt, tiramisu)
|
||||
if elt.type in self.tiramisu.objectspace.rougailconfig['custom_types']:
|
||||
self.object_type = self.tiramisu.objectspace.rougailconfig['custom_types'][elt.type].__name__
|
||||
else:
|
||||
self.object_type = CONVERT_OPTION[elt.type]["opttype"]
|
||||
self.object_type = CONVERT_OPTION[elt.type]["opttype"]
|
||||
|
||||
def _populate_attrib(
|
||||
self,
|
||||
|
@ -532,7 +528,7 @@ class Variable(Common):
|
|||
else:
|
||||
validators.append(val)
|
||||
keys["validators"] = "[" + ", ".join(validators) + "]"
|
||||
for key, value in CONVERT_OPTION.get(self.elt.type, {}).get("initkwargs", {}).items():
|
||||
for key, value in CONVERT_OPTION[self.elt.type].get("initkwargs", {}).items():
|
||||
if isinstance(value, str):
|
||||
value = f"'{value}'"
|
||||
keys[key] = value
|
||||
|
|
|
@ -4,7 +4,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2024
|
||||
Copyright (C) 2022-2023
|
||||
|
||||
distribued with GPL-2 or later license
|
||||
|
||||
|
@ -42,7 +42,7 @@ from .error import UpgradeError
|
|||
|
||||
from .utils import normalize_family
|
||||
from .config import RougailConfig
|
||||
from .object_model import CONVERT_OPTION
|
||||
from .annotator.variable import CONVERT_OPTION
|
||||
|
||||
|
||||
VERSIONS = ["0.10", "1.0"]
|
||||
|
|
|
@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2024
|
||||
Copyright (C) 2022-2023
|
||||
|
||||
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, dynamic = objectspace.paths.get_with_dynamic(
|
||||
variable, suffix = objectspace.paths.get_with_dynamic(
|
||||
get_realpath(variable_path, path_prefix)
|
||||
)
|
||||
if variable and variable.path in objectspace.variables:
|
||||
yield variable, suffix, variable_path, dynamic
|
||||
yield variable, suffix, variable_path
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
from os import environ
|
||||
environ['TIRAMISU_LOCALE'] = 'en'
|
||||
from tiramisu import StrOption
|
||||
|
||||
|
||||
class CustomOption(StrOption):
|
||||
pass
|
|
@ -1 +0,0 @@
|
|||
[]
|
|
@ -1 +0,0 @@
|
|||
["rougail.empty"]
|
|
@ -1 +0,0 @@
|
|||
[]
|
|
@ -1 +0,0 @@
|
|||
[]
|
|
@ -1 +0,0 @@
|
|||
[]
|
|
@ -1,4 +0,0 @@
|
|||
---
|
||||
version: '1.0'
|
||||
custom:
|
||||
type: custom
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"rougail.custom": {
|
||||
"owner": "default",
|
||||
"value": null
|
||||
}
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"rougail.custom": null
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"rougail.custom": {
|
||||
"owner": "default",
|
||||
"value": null
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
from tiramisu import *
|
||||
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||
from importlib.machinery import SourceFileLoader as _SourceFileLoader
|
||||
from importlib.util import spec_from_loader as _spec_from_loader, module_from_spec as _module_from_spec
|
||||
global func
|
||||
func = {'calc_value': calc_value}
|
||||
|
||||
def _load_functions(path):
|
||||
global _SourceFileLoader, _spec_from_loader, _module_from_spec, func
|
||||
loader = _SourceFileLoader('func', path)
|
||||
spec = _spec_from_loader(loader.name, loader)
|
||||
func_ = _module_from_spec(spec)
|
||||
loader.exec_module(func_)
|
||||
for function in dir(func_):
|
||||
if function.startswith('_'):
|
||||
continue
|
||||
func[function] = getattr(func_, function)
|
||||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
option_2 = CustomOption(name="custom", doc="custom", 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])
|
|
@ -1,28 +0,0 @@
|
|||
from tiramisu import *
|
||||
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||
from importlib.machinery import SourceFileLoader as _SourceFileLoader
|
||||
from importlib.util import spec_from_loader as _spec_from_loader, module_from_spec as _module_from_spec
|
||||
global func
|
||||
func = {'calc_value': calc_value}
|
||||
|
||||
def _load_functions(path):
|
||||
global _SourceFileLoader, _spec_from_loader, _module_from_spec, func
|
||||
loader = _SourceFileLoader('func', path)
|
||||
spec = _spec_from_loader(loader.name, loader)
|
||||
func_ = _module_from_spec(spec)
|
||||
loader.exec_module(func_)
|
||||
for function in dir(func_):
|
||||
if function.startswith('_'):
|
||||
continue
|
||||
func[function] = getattr(func_, function)
|
||||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
option_3 = CustomOption(name="custom", doc="custom", 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 = CustomOption(name="custom", doc="custom", 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])
|
|
@ -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 +0,0 @@
|
|||
[]
|
|
@ -1 +0,0 @@
|
|||
[]
|
|
@ -1 +0,0 @@
|
|||
[]
|
|
@ -1 +0,0 @@
|
|||
[]
|
|
@ -1 +0,0 @@
|
|||
[]
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
[]
|
|
@ -1 +0,0 @@
|
|||
[]
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
[]
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
[]
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
[]
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
["rougail.general.adresse_ip_eth0", "rougail.general.adresse_netmask_eth0", "rougail.general.adresse_ip"]
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
["rougail.general.adresse_ip_eth0", "rougail.general.adresse_ip"]
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
["rougail.general.adresse_ip_eth0", "rougail.general.adresse_netmask_eth0"]
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
[]
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
[]
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
[]
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
[]
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
[]
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
|
@ -21,7 +21,7 @@ def _load_functions(path):
|
|||
_load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
from jinja2 import StrictUndefined, DictLoader
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from rougail.annotator.variable import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
global ENV, CONVERT_OPTION
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue