This commit is contained in:
egarette@silique.fr 2023-10-12 08:17:30 +02:00
parent 940b20f5d9
commit 4fc32c7624
2926 changed files with 49970 additions and 14561 deletions

View file

@ -58,7 +58,7 @@ def get_annotators(annotators, module_name):
annotators[module_name] = []
for pathobj in importlib.resources.files(module_name).iterdir():
path = str(pathobj)
if path.endswith('__') or path.endswith('__.py'):
if not path.endswith('.py') or path.endswith('__.py'):
continue
module = load_modules(path)
if 'Annotator' not in dir(module):
@ -84,13 +84,17 @@ class SpaceAnnotator: # pylint: disable=R0903
for extra_annotator in objectspace.rougailconfig['extra_annotators']:
annotators.extend(ANNOTATORS[extra_annotator])
annotators = sorted(annotators, key=get_level)
functions = []
functions = {}
functions_files = objectspace.rougailconfig['functions_file']
if not isinstance(functions_files, list):
functions_files = [functions_files]
for functions_file in functions_files:
if isfile(functions_file):
functions.extend(dir(load_modules(functions_file)))
loaded_modules = load_modules(functions_file)
for function in dir(loaded_modules):
if function.startswith('_'):
continue
functions[function] = getattr(loaded_modules, function)
for annotator in annotators:
annotator(objectspace,
functions,

View file

@ -48,6 +48,7 @@ class Annotator(TargetAnnotator, ParamAnnotator):
functions,
*args,
):
return
self.objectspace = objectspace
self.only_variable = True
self.target_is_uniq = False

View file

@ -52,24 +52,22 @@ class Annotator(TargetAnnotator, ParamAnnotator, Walk):
*args,
):
self.objectspace = objectspace
self.target_is_uniq = False
self.only_variable = False
self.allow_function = False
self.force_service_value = {}
if hasattr(objectspace.space, 'variables'):
self.convert_auto_freeze()
for path_prefix, constraints in self.get_constraints():
if not hasattr(constraints, 'condition'):
continue
self.convert_target(constraints.condition, path_prefix)
self.check_condition_optional(constraints, path_prefix)
self.convert_condition_source(constraints, path_prefix)
self.convert_param(constraints.condition, path_prefix)
self.check_source_target(constraints)
self.convert_xxxlist(constraints, path_prefix)
self.check_choice_option_condition(constraints, path_prefix)
self.remove_condition_with_empty_target(constraints)
self.convert_condition(constraints, path_prefix)
# self.target_is_uniq = False
# self.only_variable = False
# self.allow_function = False
# self.force_service_value = {}
#for path_prefix, constraints in self.get_constraints():
# if not hasattr(constraints, 'condition'):
# continue
# self.convert_target(constraints.condition, path_prefix)
# self.check_condition_optional(constraints, path_prefix)
# self.convert_condition_source(constraints, path_prefix)
# self.convert_param(constraints.condition, path_prefix)
# self.check_source_target(constraints)
# self.convert_xxxlist(constraints, path_prefix)
# self.check_choice_option_condition(constraints, path_prefix)
# self.remove_condition_with_empty_target(constraints)
# self.convert_condition(constraints, path_prefix)
def valid_type_validation(self,
obj,
@ -78,47 +76,6 @@ class Annotator(TargetAnnotator, ParamAnnotator, Walk):
return None
return obj.source.type
def convert_auto_freeze(self):
"""convert auto_freeze
only if auto_freeze_variable is True this variable is frozen
"""
for variable in self.get_variables():
if not variable.auto_freeze and not variable.auto_save:
continue
#if variable.namespace != self.objectspace.rougailconfig['variable_namespace']:
# msg = _(f'auto_freeze is not allowed in extra "{variable.namespace}"')
# raise DictConsistencyError(msg, 49, variable.xmlfiles)
variable.force_store_value = True
if variable.auto_save:
continue
auto_freeze_variable = self.objectspace.rougailconfig['auto_freeze_variable']
if not self.objectspace.paths.path_is_defined(auto_freeze_variable,
self.objectspace.rougailconfig['variable_namespace'],
variable.path_prefix,
):
msg = _(f'the variable "{variable.name}" is auto_freeze but there is no variable "{auto_freeze_variable}"')
raise DictConsistencyError(msg, 81, variable.xmlfiles)
new_condition = self.objectspace.condition(variable.xmlfiles)
new_condition.name = 'auto_frozen_if_in'
new_condition.namespace = variable.namespace
new_condition.source = auto_freeze_variable
new_param = self.objectspace.param(variable.xmlfiles)
new_param.text = True
new_condition.param = [new_param]
new_target = self.objectspace.target(variable.xmlfiles)
new_target.type = 'variable'
path = variable.path
if variable.path_prefix:
path = path.split('.', 1)[-1]
new_target.name = path
new_condition.target = [new_target]
path_prefix, constraints = next(self.get_constraints(create=True,
path_prefix=variable.path_prefix,
))
if not hasattr(constraints, 'condition'):
constraints.condition = []
constraints.condition.append(new_condition)
def check_source_target(self, constraints):
"""verify that source != target in condition
"""
@ -404,7 +361,7 @@ class Annotator(TargetAnnotator, ParamAnnotator, Walk):
main_action,
)
if isinstance(leader_or_variable, self.objectspace.variable) and \
(leader_or_variable.auto_save or leader_or_variable.auto_freeze) and \
leader_or_variable.auto_save and \
'force_default_on_freeze' in actions:
continue
for action in actions[1:]:

View file

@ -54,8 +54,9 @@ class Annotator(Walk):
objectspace,
*args,
):
self.mode_auto = []
self.objectspace = objectspace
if not hasattr(self.objectspace.space, 'variables'):
if not self.objectspace.paths:
return
self.modes = {name: Mode(idx) for idx, name in enumerate(self.objectspace.rougailconfig['modes_level'])}
self.remove_empty_families()
@ -67,34 +68,34 @@ class Annotator(Walk):
def remove_empty_families(self) -> None:
"""Remove all families without any variable
"""
removed_families = {}
for family, parent in self.get_families(with_parent=True):
if isinstance(family, self.objectspace.family) and not self._has_variable(family):
removed_families.setdefault(parent, []).append(family)
for parent, families in removed_families.items():
for family in families:
del parent.variable[family.name]
removed_families = []
for family in self.get_families():
if isinstance(family, self.objectspace.family) and not self._has_variable(family.path):
if '.' in family.path:
removed_families.append(family.path)
removed_families.reverse()
for family in removed_families:
self.objectspace.del_family(family)
def _has_variable(self,
family: 'self.objectspace.family',
family: str,
) -> bool:
if hasattr(family, 'variable'):
for variable in family.variable.values():
if isinstance(variable, self.objectspace.family):
if self._has_variable(variable):
return True
else:
for variable in self.objectspace.parents[family]:
if variable in self.objectspace.families:
if self._has_variable(variable):
return True
else:
return True
return False
def family_names(self) -> None:
"""Set doc, path, ... to family
"""
for family in self.get_families():
if not hasattr(family, 'description'):
if not family.description:
family.description = family.name
family.doc = family.description
del family.description
# family.doc = family.description
# del family.description
def change_modes(self):
"""change the mode of variables
@ -130,17 +131,21 @@ class Annotator(Walk):
def _set_default_mode(self,
family: 'self.objectspace.family',
) -> None:
if not hasattr(family, 'variable'):
children = self.objectspace.parents[family.path]
if not children:
return
if self._has_mode(family):
family_mode = family.mode
else:
family_mode = None
leader = None
for variable in family.variable.values():
if leader is None and hasattr(family, 'leadership') and family.leadership:
for variable_path in children:
variable = self.objectspace.paths[variable_path]
if variable.type == 'symlink':
continue
if leader is None and family.type == 'leadership':
leader = variable
if isinstance(variable, self.objectspace.family):
if variable_path in self.objectspace.families:
# set default mode a subfamily
if family_mode and not self._has_mode(variable):
self._set_auto_mode(variable, family_mode)
@ -154,32 +159,33 @@ class Annotator(Walk):
# here because follower can change leader mode
self._set_auto_mode(family, leader.mode)
@staticmethod
def _has_mode(obj) -> bool:
return 'mode' in vars(obj) and not hasattr(obj, 'mode_auto')
def _has_mode(self, obj) -> bool:
return obj.mode and not obj.path in self.mode_auto
def _set_default_mode_variable(self,
variable: 'self.objectspace.variable',
family_mode: str,
) -> None:
# auto_save or auto_freeze variable is set to 'basic' mode
# auto_save variable is set to 'basic' mode
# if its mode is not defined by the user
if not self._has_mode(variable) and \
(variable.auto_save is True or variable.auto_freeze is True):
variable.auto_save is True:
variable.mode = self.objectspace.rougailconfig['modes_level'][0]
# mandatory variable without value is a basic variable
elif not self._has_mode(variable) and \
variable.mandatory is True and \
not hasattr(variable, 'default') and \
not hasattr(variable, 'default_multi'):
variable.default is None and \
variable.path not in self.objectspace.default_multi:
variable.mode = self.objectspace.rougailconfig['modes_level'][0]
elif family_mode and not self._has_mode(variable):
self._set_auto_mode(variable, family_mode)
@staticmethod
def _set_auto_mode(obj, mode: str) -> None:
def _set_auto_mode(self,
obj,
mode: str,
) -> None:
obj.mode = mode
obj.mode_auto = True
self.mode_auto.append(obj.path)
def _set_default_mode_leader(self,
leader: 'self.objectspace.variable',
@ -188,12 +194,9 @@ class Annotator(Walk):
if follower.auto_save is True:
msg = _(f'leader/followers "{follower.name}" could not be auto_save')
raise DictConsistencyError(msg, 29, follower.xmlfiles)
if follower.auto_freeze is True:
msg = f'leader/followers "{follower.name}" could not be auto_freeze'
raise DictConsistencyError(_(msg), 30, follower.xmlfiles)
if leader == follower:
# it's a leader
if not hasattr(leader, 'mode'):
if not leader.mode:
self._set_auto_mode(leader, self.objectspace.rougailconfig['default_variable_mode'])
return
if self._has_mode(follower):
@ -215,44 +218,42 @@ class Annotator(Walk):
def _change_family_mode(self,
family: 'self.objectspace.family',
) -> None:
if hasattr(family, 'mode'):
if family.mode:
family_mode = family.mode
else:
family_mode = self.objectspace.rougailconfig['default_family_mode']
min_variable_mode = self.objectspace.rougailconfig['modes_level'][-1]
# change variable mode, but not if variables are not in a family
is_leadership = hasattr(family, 'leadership') and family.leadership
if hasattr(family, 'variable'):
for idx, variable in enumerate(family.variable.values()):
if isinstance(variable, self.objectspace.family):
if not hasattr(variable, 'mode'):
is_leadership = family.type == 'leadership'
if family.path in self.objectspace.parents:
for idx, variable_path in enumerate(self.objectspace.parents[family.path]):
variable = self.objectspace.paths[variable_path]
if variable.type == 'symlink':
continue
if variable_path in self.objectspace.families:
if not variable.mode:
variable.mode = self.objectspace.rougailconfig['default_family_mode']
#elif idx == 0 and is_leadership:
# variable.mode = None
# if variable.path == 'general.piwigo.users.piwigo_users':
# print(variable.path)
# continue
else:
self._change_variable_mode(variable, family_mode, is_leadership)
if self.modes[min_variable_mode] > self.modes[variable.mode]:
min_variable_mode = variable.mode
if not isinstance(family, (self.objectspace.family, self.objectspace.variables)):
# it's Variable, Service, ...
return
if not hasattr(family, 'mode'):
#FIXME if not isinstance(family, (self.objectspace.family, self.objectspace.variables)):
# # it's Variable, Service, ...
# return
if not family.mode:
# set the lower variable mode to family
self._set_auto_mode(family, min_variable_mode)
if not is_leadership and family.mode != min_variable_mode:
msg = _(f'the family "{family.name}" is in "{family.mode}" mode but variables and '
f'families inside have the higher modes "{min_variable_mode}"')
raise DictConsistencyError(msg, 62, family.xmlfiles)
#FIXME if not is_leadership and family.mode != min_variable_mode:
#FIXME msg = _(f'the family "{family.name}" is in "{family.mode}" mode but variables and '
#FIXME f'families inside have the higher modes "{min_variable_mode}"')
#FIXME raise DictConsistencyError(msg, 62, family.xmlfiles)
def _change_variable_mode(self,
variable,
family_mode: str,
is_follower: bool,
) -> None:
if hasattr(variable, 'mode'):
if variable.mode:
variable_mode = variable.mode
else:
variable_mode = self.objectspace.rougailconfig['default_variable_mode']
@ -263,28 +264,21 @@ class Annotator(Walk):
f'but family has the higher family mode "{family_mode}"')
raise DictConsistencyError(msg, 61, variable.xmlfiles)
self._set_auto_mode(variable, family_mode)
if not hasattr(variable, 'mode'):
if not variable.mode:
variable.mode = variable_mode
def dynamic_families(self):
"""link dynamic families to object
"""
for family in self.get_families():
if 'dynamic' not in vars(family):
if family.type != 'dynamic':
continue
family.suffixes = self.objectspace.paths.get_variable(family.dynamic,
family.namespace,
xmlfiles=family.xmlfiles,
allow_variable_namespace=True,
force_path_prefix=family.path_prefix,
add_path_prefix=True,
)
del family.dynamic
if not family.suffixes.multi:
family.variable = self.objectspace.paths[family.variable]
if not family.variable.multi:
msg = _(f'dynamic family "{family.name}" must be linked '
f'to multi variable')
raise DictConsistencyError(msg, 16, family.xmlfiles)
for variable in family.variable.values():
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)
@ -293,9 +287,7 @@ class Annotator(Walk):
"""Convert variable help
"""
for family in self.get_families():
if not hasattr(family, 'help'):
if not family.help:
continue
if not hasattr(family, 'information'):
family.information = self.objectspace.information(family.xmlfiles)
family.information.help = family.help
self.objectspace.informations.add(family.path, 'help', family.help)
del family.help

View file

@ -41,14 +41,13 @@ from jinja2.utils import missing
class CollectUndefined(Undefined):
def __init__(
self,
hint=None,
obj=missing,
name=None,
exc=UndefinedError,
subname=None,
) -> None:
def __init__(self,
hint=None,
obj=missing,
name=None,
exc=UndefinedError,
subname=None,
) -> None:
self._undefined_hint = hint
self._undefined_obj = obj
self._undefined_name = name
@ -67,42 +66,51 @@ class CollectUndefined(Undefined):
def get_jinja_variable_to_param(jinja_text,
objectspace,
obj,
xmlfiles,
path_prefix,
functions,
variable_name,
variable_path,
):
CollectUndefined.variables = set()
try:
SandboxedEnvironment(loader=DictLoader({'tmpl': jinja_text}), undefined=CollectUndefined).get_template('tmpl').render()
env = SandboxedEnvironment(loader=DictLoader({'tmpl': jinja_text}), undefined=CollectUndefined)
#add functions as filters
env.filters = functions
# and functions
env.get_template('tmpl').render(**functions)
except UndefinedError as err:
msg = _(f'error in jinja "{jinja_text}": {err}')
raise DictConsistencyError(msg, 91, obj.xmlfiles) from err
raise DictConsistencyError(msg, 91, xmlfiles) from err
variables = list(CollectUndefined.variables)
variables.sort()
for variable in variables:
new_param = objectspace.param(obj.xmlfiles)
if variable in [variable_name, variable_path]:
new_param.name = '__internal_key'
new_param.type = 'string'
new_param.text = variable
else:
new_param.name = variable
new_param.text = variable
try:
set_variable_to_param(new_param,
objectspace,
None,
obj.namespace,
path_prefix,
None,
)
except DictConsistencyError as err:
if err.errno != 42:
raise err from err
continue
new_param.type = 'variable'
obj.param.append(new_param)
#new_param = objectspace.param(obj.xmlfiles)
#if variable in [variable_name, variable_path]:
# new_param.name = '__internal_key'
# new_param.type = 'string'
# new_param.text = variable
#else:
if variable in ['__suffix', '__index']:
yield variable
if variable in objectspace.variables:
yield objectspace.paths[variable]
#new_param.name = variable
#new_param.text = variable
#try:
# set_variable_to_param(new_param,
# objectspace,
# None,
# obj.namespace,
# path_prefix,
# None,
# )
#except DictConsistencyError as err:
# if err.errno != 42:
# raise err from err
# continue
#new_param.type = 'variable'
#obj.param.append(new_param)
CALC_MULTI = ('calc_value',
@ -130,6 +138,7 @@ class Annotator(TargetAnnotator, ParamAnnotator):
functions,
*args,
):
return
self.objectspace = objectspace
self.functions = copy(functions)
self.functions.extend(self.objectspace.rougailconfig['internal_functions'])

View file

@ -1,85 +0,0 @@
"""Annotate group
Created by:
EOLE (http://eole.orion.education.fr)
Copyright (C) 2005-2018
Forked by:
Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021
Silique (https://www.silique.fr)
Copyright (C) 2022-2023
distribued with GPL-2 or later license
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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
"""
from rougail.i18n import _
from rougail.error import DictConsistencyError
from rougail.utils import normalize_family
from rougail.annotator.variable import Walk
class Annotator(Walk):
"""Annotate group
"""
level = 10
def __init__(self,
objectspace,
*args,
):
if not hasattr(objectspace.space, 'variables'):
return
self.objectspace = objectspace
self.convert_groups()
def convert_groups(self): # pylint: disable=C0111
"""convert groups
"""
# store old leaders family name
for family in self.get_families():
if not isinstance(family, self.objectspace.family):
continue
if not family.leadership:
continue
if hasattr(family, 'dynamic'):
msg = _(f'the family "{family.name}" cannot be leadership and dynamic together')
raise DictConsistencyError(msg, 31, family.xmlfiles)
if not hasattr(family, 'variable'):
continue
for idx, variable in enumerate(family.variable.values()):
if idx == 0:
# it's a leader
if variable.multi is not True:
msg = _(f'the variable "{variable.name}" in a leadership must be multi')
raise DictConsistencyError(msg, 32, variable.xmlfiles)
if variable.hidden:
family.hidden = variable.hidden
elif family.hidden:
variable.hidden = family.hidden
if variable.hidden:
variable.frozen = True
variable.force_default_on_freeze = True
variable.hidden = None
else:
# it's a follower
if family.hidden:
variable.frozen = True
variable.force_default_on_freeze = True
if variable.multi is True:
variable.multi = 'submulti'
else:
variable.multi = True

View file

@ -45,88 +45,87 @@ class Annotator(Walk):
*args
) -> None:
self.objectspace = objectspace
services = []
if not self.objectspace.paths.has_path_prefix() and hasattr(self.objectspace.space, 'services'):
services.append(self.objectspace.space.services)
elif hasattr(self.objectspace.space, 'variables'):
for path_prefix in self.objectspace.paths.get_path_prefixes():
if path_prefix in self.objectspace.space.variables and \
hasattr(self.objectspace.space.variables[path_prefix], 'services'):
services.append(self.objectspace.space.variables[path_prefix].services)
for service in services:
self.convert_services(service)
if hasattr(self.objectspace.space, 'variables'):
# services = []
# if not self.objectspace.paths.has_path_prefix() and hasattr(self.objectspace.space, 'services'):
# services.append(self.objectspace.space.services)
# elif hasattr(self.objectspace.space, 'variables'):
# for path_prefix in self.objectspace.paths.get_path_prefixes():
# if path_prefix in self.objectspace.space.variables and \
# hasattr(self.objectspace.space.variables[path_prefix], 'services'):
# services.append(self.objectspace.space.variables[path_prefix].services)
if self.objectspace.paths:
for family in self.get_families():
#if family.path != 'services' and not family.path.startswith('services.'):
if family.path != 'services':
continue
self.convert_services(family)
self.convert_family()
self.convert_variable()
def convert_property(self,
variable,
) -> None:
"""convert properties
"""
# hidden variable is also frozen
if isinstance(variable, self.objectspace.variable) and variable.hidden is True and \
variable.name != self.objectspace.rougailconfig['auto_freeze_variable']:
if not variable.auto_freeze and \
not hasattr(variable, 'provider') and not hasattr(variable, 'supplier'):
variable.frozen = True
if not variable.auto_save and \
not variable.auto_freeze and \
'force_default_on_freeze' not in vars(variable) and \
not hasattr(variable, 'provider') and not hasattr(variable, 'supplier'):
variable.force_default_on_freeze = True
if not hasattr(variable, 'properties'):
variable.properties = []
if 'mandatory' in vars(variable) and not variable.mandatory and variable.multi:
# a multi could not have "None" has value
# to permit it, just add mandatory="False"
variable.properties.append('notempty')
for prop in PROPERTIES:
if hasattr(variable, prop):
if getattr(variable, prop) is True:
# for subprop in CONVERT_PROPERTIES.get(prop, [prop]):
variable.properties.append(prop)
setattr(variable, prop, None)
if hasattr(variable, 'unique') and variable.unique != 'nil':
if variable.unique == 'False' or variable.unique is False:
variable.properties.append('notunique')
else:
variable.properties.append('unique')
if hasattr(variable, 'mode') and variable.mode:
variable.properties.append(variable.mode)
variable.mode = None
if 'force_store_value' in variable.properties and \
'force_default_on_freeze' in variable.properties: # pragma: no cover
# should not appened
msg = _('cannot have auto_freeze or auto_save with the hidden '
f'variable "{variable.name}"')
raise DictConsistencyError(msg, 50, variable.xmlfiles)
if not variable.properties:
del variable.properties
def convert_services(self, services) -> None:
"""convert services
"""
self.convert_property(services)
for services_ in services.service.values():
self.convert_property(services_)
for service in vars(services_).values():
if not isinstance(service, self.objectspace.family):
continue
self.convert_property(service)
for family in service.family:
self.convert_property(family)
for variable in family.variable:
self.convert_property(variable)
self._convert_property(services)
def convert_family(self) -> None:
"""convert families
"""
for family in self.get_families():
self.convert_property(family)
if family.path == 'services' or family.path.startswith('services.'):
continue
self._convert_property(family)
def convert_variable(self) -> None:
"""convert variables
"""
for variable in self.get_variables():
self.convert_property(variable)
if variable.path.startswith('services.'):
continue
if variable.type == 'symlink':
continue
self._convert_variable_property(variable)
def _convert_variable_property(self,
variable: dict,
) -> None:
"""convert properties
"""
path = variable.path
# hidden variable is also frozen
if variable.hidden is True:
if variable.provider is None and \
variable.supplier is None:
self.objectspace.properties.append(variable.path, 'frozen')
if not variable.auto_save and \
'force_default_on_freeze' not in self.objectspace.properties[path] and \
variable.provider is None and variable.supplier is None:
self.objectspace.properties.append(path, 'force_default_on_freeze')
if not variable.mandatory and variable.multi:
# a multi could not have "None" has value
# to permit it, just add mandatory="False"
self.objectspace.properties.append(path, 'notempty')
if variable.unique is not None:
if variable.unique is False:
self.objectspace.properties.append(path, 'notunique')
else:
self.objectspace.properties.append(path, 'unique')
if variable.auto_save:
self.objectspace.properties.append(variable.path, 'force_store_value')
if 'force_store_value' in self.objectspace.properties[path] and \
'force_default_on_freeze' in self.objectspace.properties[path]: # pragma: no cover
# should not appened
msg = _('cannot have auto_save with the hidden '
f'variable "{variable.name}"')
raise DictConsistencyError(msg, 50, variable.xmlfiles)
self._convert_property(variable)
def _convert_property(self,
obj: dict,
) -> None:
for prop in PROPERTIES:
if hasattr(obj, prop) and getattr(obj, prop) is True:
self.objectspace.properties.append(obj.path, prop)
if obj.mode:
self.objectspace.properties.append(obj.path, obj.mode)

View file

@ -33,7 +33,8 @@ from typing import Tuple
from rougail.i18n import _
from rougail.utils import normalize_family
from rougail.error import DictConsistencyError
from rougail.annotator.variable import CONVERT_OPTION
#from rougail.annotator.variable import CONVERT_OPTION
from tiramisu import PermissionsOption, UsernameOption
try:
import tiramisu4 as tiramisu
except ModuleNotFoundError:
@ -48,13 +49,6 @@ FORCE_INFORMATIONS = ['mode']
class Annotator:
"""Manage service's object
for example::
<services>
<service name="test">
<service_access service='ntp'>
</service_access>
</service>
</services>
"""
level = 20
def __init__(self,
@ -63,238 +57,373 @@ class Annotator:
) -> None:
self.objectspace = objectspace
self.uniq_overrides = {}
if 'network_type' not in self.objectspace.types:
self.objectspace.types['network_type'] = self.objectspace.types['ip_type']
#if 'network_type' not in self.objectspace.types:
# self.objectspace.types['network_type'] = self.objectspace.types['ip_type']
services = []
if not self.objectspace.paths.has_path_prefix():
if 1:
#FIXME if not self.objectspace.paths.has_path_prefix():
self.uniq_overrides[None] = []
if hasattr(self.objectspace.space, 'services'):
if not hasattr(self.objectspace.space.services, 'service'):
del self.objectspace.space.services
else:
services.append((None, 'services', self.objectspace.space.services))
elif hasattr(self.objectspace.space, 'variables'):
for path_prefix in self.objectspace.paths.get_path_prefixes():
self.uniq_overrides[path_prefix] = []
root_path = f'{path_prefix}.services'
if not path_prefix in self.objectspace.space.variables or \
not hasattr(self.objectspace.space.variables[path_prefix], 'services'):
continue
if not hasattr(self.objectspace.space.variables[path_prefix].services, 'service'):
del self.objectspace.space.variables[path_prefix].services
else:
services.append((path_prefix, root_path, self.objectspace.space.variables[path_prefix].services))
for path_prefix, root_path, service in services:
self.convert_services(path_prefix, root_path, service)
# if hasattr(self.objectspace.space, 'services'):
if self.objectspace.services:
services.append((None, 'services', self.objectspace.services))
#elif hasattr(self.objectspace.space, 'variables'):
# for path_prefix in self.objectspace.paths.get_path_prefixes():
# self.uniq_overrides[path_prefix] = []
# root_path = f'{path_prefix}.services'
# if not path_prefix in self.objectspace.space.variables or \
# not hasattr(self.objectspace.space.variables[path_prefix], 'services'):
# continue
# if not hasattr(self.objectspace.space.variables[path_prefix].services, 'service'):
# del self.objectspace.space.variables[path_prefix].services
# else:
# services.append((path_prefix, root_path, self.objectspace.space.variables[path_prefix].services))
if services:
self.objectspace.add_family('.',
'services',
'services',
{'doc': 'services',
'hidden': True,
},
[]
)
for path_prefix, root_path, service in services:
self.convert_services(path_prefix, root_path, service)
def convert_services(self, path_prefix, root_path, services):
"""convert services to variables
"""
services.hidden = True
services.name = 'services'
services.doc = 'services'
services.path = root_path
for service_name, service in services.service.items():
service.name = normalize_family(service_name)
activate_obj = self._generate_element('boolean',
None,
None,
'activate',
not service.disabled,
service,
f'{root_path}.{service.name}',
path_prefix,
)
service.disabled = None
dico = dict(vars(service))
if 'type' not in dico:
if service.manage:
dico['type'] = service.type
for service_name, service in services.items():
n_service_name = normalize_family(service_name)
path = f'{root_path}.{n_service_name}'
self.objectspace.add_family(root_path,
path,
n_service_name,
{'doc': service_name},
service.xmlfiles,
)
for typ in ['ip', 'certificates', 'files']:
if typ == 'ip':
obj_typ = 'ips'
else:
dico['type'] = 'none'
for elttype, values in dico.items():
if elttype == 'servicelist':
self.objectspace.paths.list_conditions[path_prefix].setdefault('servicelist',
{}).setdefault(
values,
[]).append(activate_obj)
continue
obj_typ = typ
values = getattr(self.objectspace, obj_typ)
if path in values:
obj_path = f'{path}.{typ}'
if obj_path not in self.objectspace.paths:
self.objectspace.add_family(path,
obj_path,
typ,
{},
service.xmlfiles,
)
function = getattr(self, f'convert_service_{typ}')
for obj in values[path]:
function(obj,
obj_path,
n_service_name,
path_prefix,
)
self._generate_element('boolean',
None,
None,
'activate',
not service.disabled,
service,
path,
path_prefix,
)
for elttype, values in service:
if elttype in ERASED_ATTRIBUTES:
continue
if not service.manage and elttype not in ALLOW_ATTRIBUT_NOT_MANAGE and (elttype != 'type' or values != 'none'):
if not service.manage and elttype not in ALLOW_ATTRIBUT_NOT_MANAGE and (elttype != 'type' or values is not None):
msg = _(f'unmanage service cannot have "{elttype}"')
raise DictConsistencyError(msg, 66, service.xmlfiles)
if isinstance(values, (dict, list)):
if elttype != 'ip':
eltname = elttype + 's'
else:
eltname = elttype
if hasattr(service, 'servicelist'):
if isinstance(values, dict):
for key, value in values.items():
setattr(value, 'servicelist', service.servicelist)
family = self._gen_family(eltname,
f'{root_path}.{service.name}',
service.xmlfiles,
path_prefix,
with_informations=False,
)
if isinstance(values, dict):
values = list(values.values())
family.family = self.make_group_from_elts(service_name,
elttype,
values,
f'{root_path}.{service.name}.{eltname}',
root_path,
path_prefix,
)
setattr(service, elttype, family)
else:
if not hasattr(service, 'information'):
service.information = self.objectspace.information(service.xmlfiles)
setattr(service.information, elttype, values)
service.path = f'{root_path}.{service.name}'
manage = self._generate_element('boolean',
None,
None,
'manage',
service.manage,
service,
f'{root_path}.{service.name}',
path_prefix,
)
service.variable = [activate_obj, manage]
service.doc = service_name
def make_group_from_elts(self,
service_name,
elttype,
elts,
path,
root_path,
path_prefix,
):
"""Splits each objects into a group (and `OptionDescription`, in tiramisu terms)
and build elements and its attributes (the `Options` in tiramisu terms)
"""
families = []
listname = '{}list'.format(elttype)
for elt in elts:
# try to launch _update_xxxx() function
update_elt = '_update_' + elttype
if hasattr(self, update_elt):
getattr(self, update_elt)(elt,
service_name,
path_prefix,
if values:
self.objectspace.informations.add(path, elttype, values)
self.objectspace.add_variable(path,
f'{path}.manage',
'manage',
{'type': 'boolean',
'default': True,
},
service.xmlfiles,
)
c_name, subpath = self._get_name_path(elt,
path,
root_path,
path_prefix,
)
family = self._gen_family(c_name,
subpath.rsplit('.', 1)[0],
elt.xmlfiles,
path_prefix,
def convert_service_ip(self,
ip: dict,
subpath: str,
service_name: str,
path_prefix: str,
) -> None:
variable = self.objectspace.paths[ip.name]
if variable.type not in ['ip', 'network', 'network_cidr']:
msg = _(f'ip cannot be linked to "{variable.type}" variable "{ip.name}"')
raise DictConsistencyError(msg, 70, ip.xmlfiles)
if variable.type in ['ip', 'network_cidr'] and ip.netmask:
msg = _(f'ip with ip_type "{variable.type}" must not have netmask')
raise DictConsistencyError(msg, 59, ip.xmlfiles)
if variable.type == 'network' and not ip.netmask:
msg = _(f'ip with ip_type "{variable.type}" must have netmask')
raise DictConsistencyError(msg, 64, ip.xmlfiles)
if ip.netmask:
netmask = self.objectspace.paths[ip.netmask]
if netmask.type != 'netmask':
msg = _(f'netmask in ip must have type "netmask", not "{netmask.type}"')
raise DictConsistencyError(msg, 65, ip.xmlfiles)
name = normalize_family(ip.name)
path = f'{subpath}.{name}'
self.objectspace.add_family(subpath,
path,
name,
{'doc': ip.name},
ip.xmlfiles,
)
self.objectspace.add_variable(path,
f'{path}.name',
'name',
{'type': 'symlink',
'opt': variable,
},
ip.xmlfiles,
)
family.variable = []
if hasattr(elt, 'disabled'):
disabled = elt.disabled
else:
disabled = False
activate_obj = self._generate_element('boolean',
None,
None,
'activate',
not disabled,
elt,
subpath,
path_prefix,
)
for key in dir(elt):
if key.startswith('_') or key.endswith('_type') or key in ERASED_ATTRIBUTES2:
continue
value = getattr(elt, key)
if key in [listname, 'servicelist']:
self.objectspace.paths.list_conditions[path_prefix].setdefault(key,
{}).setdefault(
value,
[]).append(activate_obj)
continue
if key == 'name':
dtd_key_type = elttype + '_type'
else:
dtd_key_type = key + '_type'
elt_type = getattr(elt, dtd_key_type, None)
if elt_type:
try:
value = CONVERT_OPTION.get(elt_type, {}).get('func', str)(value)
except ValueError as err:
msg = _(f'"{value}" is not a valid "{elttype}": {err}')
raise DictConsistencyError(msg, 93, elt.xmlfiles)
if key not in FORCE_INFORMATIONS and elt_type:
if elt_type == 'variable':
elt_type = 'symlink'
family.variable.append(self._generate_element(elt_type,
dtd_key_type,
elttype,
key,
value,
elt,
subpath,
path_prefix,
))
else:
setattr(family.information, key, value)
family.variable.append(activate_obj)
families.append(family)
return families
def _get_name_path(self,
elt,
path: str,
root_path: str,
path_prefix: str,
) -> Tuple[str, str]:
# create element name, if already exists, add _xx to be uniq
if hasattr(elt, 'source') and elt.source:
name = elt.source
else:
name = elt.name
idx = 0
while True:
c_name = name
if idx:
c_name += f'_{idx}'
subpath = '{}.{}'.format(path, normalize_family(c_name))
try:
self.objectspace.paths.get_family(subpath, root_path, path_prefix)
except DictConsistencyError as err:
if err.errno == 42:
return c_name, subpath
idx += 1
def _gen_family(self,
name,
subpath,
xmlfiles,
path_prefix,
with_informations=True,
):
family = self.objectspace.family(xmlfiles)
family.name = normalize_family(name)
family.doc = name
family.mode = None
self.objectspace.paths.add_family('services',
subpath,
family,
False,
force_path_prefix=path_prefix,
if ip.netmask:
self.objectspace.add_variable(path,
f'{path}.netmask',
'netmask',
{'type': 'symlink',
'opt': self.objectspace.paths[ip.netmask],
},
ip.xmlfiles,
)
if with_informations:
family.information = self.objectspace.information(xmlfiles)
return family
self._generate_element('boolean',
None,
None,
'activate',
True,
#not service.disabled,
ip,
path,
path_prefix,
)
def convert_service_certificates(self,
certificate: dict,
subpath: str,
service_name: str,
path_prefix: str,
) -> None:
if isinstance(certificate.name, dict):
variable = self.objectspace.paths[certificate.name['name']]
if variable.type != 'filename':
msg = _(f'certificate cannot be linked to "{variable.type}" variable "{ip.name}"')
raise Exception(msg)
# raise DictConsistencyError(msg, 70, ip.xmlfiles)
name_obj = {'type': 'symlink',
'opt': variable,
}
else:
name = certificate.name
name_obj = {'default': name}
name = normalize_family(name)
path = f'{subpath}.{name}'
self.objectspace.add_family(subpath,
path,
name,
{'doc': name},
certificate.xmlfiles,
)
self.objectspace.add_variable(path,
f'{path}.name',
'name',
name_obj,
certificate.xmlfiles,
)
self.objectspace.informations.add(path, 'authority', certificate.authority)
for typ in ['provider', 'format', 'type']:
value = getattr(certificate, typ)
if value:
self.objectspace.informations.add(path, typ, value)
if certificate.mode:
PermissionsOption('', '', default=certificate.mode)
self.objectspace.informations.add(path, 'mode', certificate.mode)
#
for typ in ['owner', 'group']:
value = getattr(certificate, typ)
if value is None:
continue
if isinstance(value, str):
UsernameOption('', '', default=value)
new_variable = {'type': 'unix_user',
'default': value}
else:
new_variable = {'type': 'symlink',
'opt': self.objectspace.paths[value['name']],
}
self.objectspace.add_variable(path,
f'{path}.{typ}',
typ,
new_variable,
certificate.xmlfiles,
)
#
if certificate.domain is None:
certificate.domain = self.objectspace.rougailconfig['default_certificate_domain']
for typ in ['server', 'domain']:
value = getattr(certificate, typ)
if value is None:
continue
value = {'type': 'symlink',
'opt': self.objectspace.paths[value],
}
self.objectspace.add_variable(path,
f'{path}.{typ}',
typ,
value,
certificate.xmlfiles,
)
self._generate_element('boolean',
None,
None,
'activate',
True,
#not service.disabled,
certificate,
path,
path_prefix,
)
def convert_service_files(self,
file: dict,
subpath: str,
service_name: str,
path_prefix: str,
) -> None:
if isinstance(file.source, dict):
if file.source['type'] != 'variable':
raise Exception('pfff')
source_obj = {'type': 'symlink',
'opt': self.objectspace.paths[file.source['name']],
}
else:
source_obj = {'type': 'filename',
'default': file.name,
}
if not file.variable:
if not file.source:
file.source = basename(file.name)
elif not file.source:
msg = _(f'attribute "source" is mandatory for the file "{file.name}" in '
f'"({service_name})"')
raise DictConsistencyError(msg, 34, file_.xmlfiles)
name, path = self.get_name_path(file, subpath)
self.objectspace.add_family(subpath,
path,
name,
{'doc': name},
file.xmlfiles,
)
self.objectspace.add_variable(path,
f'{path}.name',
'name',
{'type': 'filename',
'default': file.name,
},
file.xmlfiles,
)
#
self.objectspace.add_variable(path,
f'{path}.source',
'source',
source_obj,
file.xmlfiles,
)
#
if file.mode:
PermissionsOption('', '', default=file.mode)
self.objectspace.informations.add(path, 'mode', file.mode)
#
if file.engine:
self.objectspace.informations.add(path, 'engine', file.engine)
#
if file.included != 'no':
self.objectspace.informations.add(path, 'included', file.included)
#
for typ in ['owner', 'group']:
value = getattr(file, typ)
if value is None:
continue
if isinstance(value, str):
UsernameOption('', '', default=value)
new_variable = {'type': 'unix_user',
'default': value}
else:
new_variable = {'type': 'symlink',
'opt': self.objectspace.paths[value['name']],
}
self.objectspace.add_variable(path,
f'{path}.{typ}',
typ,
new_variable,
file.xmlfiles,
)
#
self._generate_element('boolean',
None,
None,
'activate',
True,
#not service.disabled,
file,
path,
path_prefix,
)
def convert_service_overrides(self,
override: dict,
subpath: str,
service_name: str,
path_prefix: str,
) -> None:
name, path = self.get_name_path(override, subpath)
self.objectspace.add_family(subpath,
path,
name,
{'doc': name},
override.xmlfiles,
)
self.objectspace.add_variable(path,
f'{path}.name',
'name',
{'type': 'filename',
'default': override.name,
},
override.xmlfiles,
)
#
if override.source:
self.objectspace.add_variable(path,
f'{path}.source',
'source',
{'type': 'filename',
'default': override.source,
},
override.xmlfiles,
)
#
#
if override.engine:
self.objectspace.informations.add(path, 'engine', override.engine)
#
self._generate_element('boolean',
None,
None,
'activate',
True,
#not service.disabled,
override,
path,
path_prefix,
)
def _generate_element(self,
type_,
@ -303,13 +432,13 @@ class Annotator:
key,
value,
elt,
path,
subpath,
path_prefix,
): # pylint: disable=R0913
variable = self.objectspace.variable(elt.xmlfiles)
variable.name = normalize_family(key)
variable.mode = None
variable.type = type_
name = normalize_family(key)
variable_obj = {'type': type_,
'xmlfiles': elt.xmlfiles
}
if type_ == 'symlink':
variable.opt = self.objectspace.paths.get_variable(value,
self.objectspace.rougailconfig['variable_namespace'],
@ -325,15 +454,21 @@ class Annotator:
raise DictConsistencyError(msg, 58, elt.xmlfiles)
else:
variable.doc = key
variable.default = value
variable.namespace = 'services'
self.objectspace.paths.add_variable('services',
path,
variable,
force_path_prefix=path_prefix
)
return variable
variable_obj['description'] = key
variable_obj['default'] = value
path = f'{subpath}.{name}'
self.objectspace.add_variable(subpath,
path,
name,
variable_obj,
elt.xmlfiles,
)
# self.objectspace.paths.add_variable('services',
# path,
# variable,
# force_path_prefix=path_prefix
# )
return self.objectspace.paths[path]
def _update_override(self,
override,
@ -363,37 +498,6 @@ class Annotator:
f'"({service_name})"')
raise DictConsistencyError(msg, 34, file_.xmlfiles)
def _update_ip(self,
ip,
service_name,
path_prefix,
) -> None:
variable = self.objectspace.paths.get_variable(ip.name,
ip.namespace,
xmlfiles=ip.xmlfiles,
force_path_prefix=path_prefix,
add_path_prefix=True,
)
if variable.type not in ['ip', 'network', 'network_cidr']:
msg = _(f'ip cannot be linked to "{variable.type}" variable "{ip.name}"')
raise DictConsistencyError(msg, 70, ip.xmlfiles)
if variable.type in ['ip', 'network_cidr'] and hasattr(ip, 'netmask'):
msg = _(f'ip with ip_type "{variable.type}" must not have netmask')
raise DictConsistencyError(msg, 59, ip.xmlfiles)
if variable.type == 'network' and not hasattr(ip, 'netmask'):
msg = _(f'ip with ip_type "{variable.type}" must have netmask')
raise DictConsistencyError(msg, 64, ip.xmlfiles)
if hasattr(ip, 'netmask'):
netmask = self.objectspace.paths.get_variable(ip.netmask,
ip.namespace,
xmlfiles=ip.xmlfiles,
force_path_prefix=path_prefix,
add_path_prefix=True,
)
if netmask.type != 'netmask':
msg = _(f'netmask in ip must have type "netmask", not "{netmask.type}"')
raise DictConsistencyError(msg, 65, ip.xmlfiles)
def _update_certificate(self,
certificate,
certificate_name,
@ -418,3 +522,25 @@ class Annotator:
if variable.type != 'domainname':
msg = _(f'the certificate "{certificate.name}" has an attribute "domain" linked with a "{variable.type}" variable ("{certificate.domain}"), but must be a "domainename" variable')
raise DictConsistencyError(msg, 94, certificate.xmlfiles)
def get_name_path(self,
elt,
subpath: str,
) -> Tuple[str, str]:
# create element name, if already exists, add _xx to be uniq
if hasattr(elt, 'source') and elt.source:
name = elt.source
if isinstance(name, dict):
name = name['name']
else:
name = elt.name
name = normalize_family(name)
idx = 0
while True:
c_name = name
if idx:
c_name += f'_{idx}'
path = f'{subpath}.{c_name}'
if path not in self.objectspace.families:
return c_name, path
idx += 1

View file

@ -31,6 +31,8 @@ from rougail.annotator.variable import Walk
from rougail.i18n import _
from rougail.error import DictConsistencyError
from rougail.annotator.fill import get_jinja_variable_to_param
class Annotator(Walk): # pylint: disable=R0903
"""Annotate value
@ -38,10 +40,12 @@ class Annotator(Walk): # pylint: disable=R0903
level = 70
def __init__(self,
objectspace,
functions,
*args,
) -> None:
if not hasattr(objectspace.space, 'variables'):
if not objectspace.paths:
return
self.functions = functions
self.objectspace = objectspace
self.convert_value()
self.add_choice_nil()
@ -50,52 +54,79 @@ class Annotator(Walk): # pylint: disable=R0903
"""convert value
"""
for variable in self.get_variables():
if variable.type == 'symlink':
continue
self._convert_value(variable)
def _convert_value(self,
variable,
variable: dict,
) -> None:
multi = self.objectspace.multis.get(variable.path, False)
# a boolean must have value, the default value is "True"
if not hasattr(variable, 'value') and variable.type == 'boolean':
new_value = self.objectspace.value(variable.xmlfiles)
new_value.name = True
new_value.type = 'boolean'
variable.value = [new_value]
# if the variable is mandatory and doesn't have any value
# then the variable's mode is set to 'basic'
# variable with default value is mandatory
if hasattr(variable, 'value') and variable.value:
has_value = True
for value in variable.value:
if value.type == 'calculation' or value.type == 'nil':
has_value = False
break
if has_value and 'mandatory' not in vars(variable):
# if has value without any calculation
variable.mandatory = True
if not hasattr(variable, 'value'):
if variable.type == 'boolean' and \
multi is False and \
variable.default is None:
variable.default = True
if variable.default is None:
return
if variable.value[0].type == 'calculation':
variable.default = variable.value[0]
elif variable.multi:
if self.objectspace.paths.is_follower(variable):
if variable.multi != 'submulti' and len(variable.value) != 1:
has_value = False
if isinstance(variable.default, dict):
if variable.default['type'] == 'jinja':
path_prefix = None
default = {'type': 'jinja',
'jinja': variable.default['jinja'],
'params': {'__internal_jinja': variable.path,
'__internal_type': variable.type,
'__internal_multi': multi,
},
}
for sub_variable in get_jinja_variable_to_param(variable.default['jinja'],
self.objectspace,
variable.xmlfiles,
path_prefix,
self.functions,
None,
None,
):
if isinstance(sub_variable, self.objectspace.variable):
default['params'][sub_variable.path] = sub_variable
elif sub_variable == '__suffix':
default['params'][sub_variable] = self.objectspace.param(type='suffix')
elif sub_variable == '__index':
default['params'][sub_variable] = self.objectspace.param(type='index')
else:
default['params'][sub_variable] = sub_variable
variable.default = default
else:
raise Exception('pfff')
elif isinstance(variable.default, list):
if not multi:
raise Exception('pfff')
if variable.path in self.objectspace.followers:
if multi != 'submulti' and len(variable.default) != 1:
msg = _(f'the follower "{variable.name}" without multi attribute can only have one value')
raise DictConsistencyError(msg, 87, variable.xmlfiles)
else:
variable.default = [value.name for value in variable.value]
if not self.objectspace.paths.is_leader(variable):
if variable.multi == 'submulti':
variable.default_multi = [value.name for value in variable.value]
# else:
# variable.default = [value.name for value in variable.default]
if variable.path not in self.objectspace.leaders:
if multi == 'submulti':
self.objectspace.default_multi[variable.path] = variable.default #[value.name for value in variable.value]
else:
variable.default_multi = variable.value[0].name
self.objectspace.default_multi[variable.path] = variable.default[0] #.name
has_value = True
elif variable.multi:
#msg = _(f'the none multi variable "{variable.name}" cannot have '
# 'more than one value')
#raise DictConsistencyError(msg, 68, variable.xmlfiles)
raise Exception('pfff')
else:
if len(variable.value) > 1:
msg = _(f'the none multi variable "{variable.name}" cannot have '
'more than one value')
raise DictConsistencyError(msg, 68, variable.xmlfiles)
variable.default = variable.value[0].name
del variable.value
has_value = True
# variable with default value is mandatory
if has_value and variable.mandatory is None:
# if has value without any calculation
variable.mandatory = True
def add_choice_nil(self) -> None:
"""A variable with type "Choice" that is not mandatory must has "nil" value
@ -104,11 +135,9 @@ class Annotator(Walk): # pylint: disable=R0903
if variable.type != 'choice':
continue
is_none = False
for choice in variable.choice:
if choice.type == 'nil':
for choice in variable.choices:
if choice is None:
is_none = True
break
if not variable.mandatory and not is_none:
choice = self.objectspace.choice(variable.xmlfiles)
choice.name = None
choice.type = 'nil'
variable.choice.append(choice)
variable.choices.append(None)

View file

@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from rougail.i18n import _
from rougail.error import DictConsistencyError
from rougail.objspace import convert_boolean, get_variables
from rougail.objspace import convert_boolean #, get_variables
CONVERT_OPTION = {'number': dict(opttype="IntOption", func=int),
@ -75,56 +75,58 @@ class Walk:
def get_variables(self):
"""Iter all variables from the objectspace
"""
yield from get_variables(self.objectspace)
for path in self.objectspace.variables:
yield self.objectspace.paths[path]
# yield from get_variables(self.objectspace)
def get_families(self,
with_parent: bool=False,
):
def get_families(self):
"""Iter all families from the objectspace
"""
for family in self.objectspace.space.variables.values():
yield from self._get_families(family, None, with_parent)
def _get_families(self,
family: 'self.objectspace.family',
old_family: 'self.objectspace.family',
with_parent: bool,
):
if with_parent:
yield family, old_family,
if hasattr(family, 'variable'):
if not with_parent:
yield family
for fam in family.variable.values():
if isinstance(fam, self.objectspace.family):
yield from self._get_families(fam, family, with_parent)
if hasattr(family, 'variables'):
for fam in family.variables.values():
yield from self._get_families(fam, family, with_parent)
def get_constraints(self,
create: bool=False,
path_prefix: str=None,
):
if not self.objectspace.paths.has_path_prefix():
if hasattr(self.objectspace.space, 'constraints'):
yield None, self.objectspace.space.constraints
elif create:
self.objectspace.space.constraints = self.objectspace.constraints(None)
yield None, self.objectspace.space.constraints
else:
if path_prefix:
path_prefixes = [path_prefix]
else:
path_prefixes = self.objectspace.paths.get_path_prefixes()
for path_prefix in path_prefixes:
if hasattr(self.objectspace.space, 'variables') and \
path_prefix in self.objectspace.space.variables and \
hasattr(self.objectspace.space.variables[path_prefix], 'constraints'):
yield path_prefix, self.objectspace.space.variables[path_prefix].constraints
elif create:
self.objectspace.space.variables[path_prefix].constraints = self.objectspace.constraints(None)
yield path_prefix, self.objectspace.space.variables[path_prefix].constraints
for path in self.objectspace.families:
yield self.objectspace.paths[path]
# for family in self.objectspace.space.variables.values():
# yield from self._get_families(family, None, with_parent)
#
# def _get_families(self,
# family: 'self.objectspace.family',
# old_family: 'self.objectspace.family',
# with_parent: bool,
# ):
# if with_parent:
# yield family, old_family,
# if hasattr(family, 'variable'):
# if not with_parent:
# yield family
# for fam in family.variable.values():
# if isinstance(fam, self.objectspace.family):
# yield from self._get_families(fam, family, with_parent)
# if hasattr(family, 'variables'):
# for fam in family.variables.values():
# yield from self._get_families(fam, family, with_parent)
#
# def get_constraints(self,
# create: bool=False,
# path_prefix: str=None,
# ):
# if not self.objectspace.paths.has_path_prefix():
# if hasattr(self.objectspace.space, 'constraints'):
# yield None, self.objectspace.space.constraints
# elif create:
# self.objectspace.space.constraints = self.objectspace.constraints(None)
# yield None, self.objectspace.space.constraints
# else:
# if path_prefix:
# path_prefixes = [path_prefix]
# else:
# path_prefixes = self.objectspace.paths.get_path_prefixes()
# for path_prefix in path_prefixes:
# if hasattr(self.objectspace.space, 'variables') and \
# path_prefix in self.objectspace.space.variables and \
# hasattr(self.objectspace.space.variables[path_prefix], 'constraints'):
# yield path_prefix, self.objectspace.space.variables[path_prefix].constraints
# elif create:
# self.objectspace.space.variables[path_prefix].constraints = self.objectspace.constraints(None)
# yield path_prefix, self.objectspace.space.variables[path_prefix].constraints
class Annotator(Walk): # pylint: disable=R0903
@ -135,7 +137,7 @@ class Annotator(Walk): # pylint: disable=R0903
objectspace,
*args,
):
if not hasattr(objectspace.space, 'variables'):
if not objectspace.paths:
return
self.objectspace = objectspace
self.forbidden_name = ['services', self.objectspace.rougailconfig['variable_namespace']]
@ -149,83 +151,107 @@ class Annotator(Walk): # pylint: disable=R0903
"""convert variable
"""
for variable in self.get_variables():
if variable.type == 'symlink':
continue
self._convert_variable(variable)
def _convert_variable(self,
variable,
variable: dict,
) -> None:
if variable.namespace == self.objectspace.rougailconfig['variable_namespace'] and \
variable.name in self.forbidden_name:
msg = _(f'the name of the variable "{variable.name}" cannot be the same as the name'
' of a namespace')
raise DictConsistencyError(msg, 54, variable.xmlfiles)
if variable.type != 'symlink' and not hasattr(variable, 'description'):
# variable without description: description is the name
if not variable.description:
variable.description = variable.name
if hasattr(variable, 'value'):
for idx, value in enumerate(variable.value):
if not hasattr(value, 'name') and not hasattr(value, 'type'):
msg = f'variable "{variable.name}" has a value without text, if you want the value None, set value type to nil'
raise DictConsistencyError(msg, 95, value.xmlfiles)
if not hasattr(value, 'type'):
value.type = variable.type
if hasattr(value, 'name'):
try:
value.name = CONVERT_OPTION.get(value.type, {}).get('func', str)(value.name)
except Exception as err:
msg = _(f'the variable "{variable.name}" has an incorrect value "{value.name}" with "{variable.type}" type')
raise DictConsistencyError(msg, 88, variable.xmlfiles)
else:
value.name = None
if not variable.value:
del variable.value
if hasattr(variable, 'choice'):
if variable.path in self.objectspace.followers:
if not variable.multi:
self.objectspace.multis[variable.path] = True
else:
self.objectspace.multis[variable.path] = 'submulti'
if self.objectspace.paths[variable.path.rsplit('.', 1)[0]].hidden:
self.objectspace.properties.append(variable.path, 'frozen')
self.objectspace.properties.append(variable.path, 'force_default_on_freeze')
elif variable.multi:
self.objectspace.multis[variable.path] = True
if variable.path in self.objectspace.leaders:
if not self.objectspace.multis.get(variable.path, False):
msg = _(f'the variable "{variable.name}" in a leadership must be multi')
raise DictConsistencyError(msg, 32, variable.xmlfiles)
family = self.objectspace.paths[variable.path.rsplit('.', 1)[0]]
if variable.hidden:
family.hidden = variable.hidden
elif family.hidden:
variable.hidden = family.hidden
if variable.hidden:
self.objectspace.properties.append(variable.path, 'frozen')
self.objectspace.properties.append(variable.path, 'force_default_on_freeze')
variable.hidden = None
#for idx, value in enumerate(variable.default):
# if not hasattr(value, 'name') and not hasattr(value, 'type'):
# msg = f'variable "{variable.name}" has a value without text, if you want the value None, set value type to nil'
# raise DictConsistencyError(msg, 95, value.xmlfiles)
# if not hasattr(value, 'type'):
# value.type = variable.type
# if hasattr(value, 'name'):
# try:
# value.name = CONVERT_OPTION.get(value.type, {}).get('func', str)(value.name)
# except Exception as err:
# msg = _(f'the variable "{variable.name}" has an incorrect value "{value.name}" with "{variable.type}" type')
# raise DictConsistencyError(msg, 88, variable.xmlfiles)
# else:
# value.name = None
#if not variable.value:
# del variable.value
if variable.choices is not None:
if variable.type != 'choice':
msg = _(f'choice for the variable "{variable.name}" not allowed with "{variable.type}" type')
raise DictConsistencyError(msg, 3, variable.xmlfiles)
values = []
choice_type = None
for choice in variable.choice:
if choice_type == 'variable':
msg = _(f'only one "variable" choice is allowed '
f'the variable "{variable.name}"')
raise DictConsistencyError(msg, 5, choice.xmlfiles)
if choice.type == 'nil':
choice.name = None
elif choice.type == 'space':
choice.name = ' '
elif choice.type == 'variable':
choice.name = self.objectspace.paths.get_variable(choice.name,
variable.namespace,
force_path_prefix=variable.path_prefix,
)
if not choice.name.multi:
msg = _(f'only multi "variable" is allowed for a choice '
f'of variable "{variable.name}"')
raise DictConsistencyError(msg, 6, choice.xmlfiles)
else:
if not hasattr(choice, 'name'):
msg = _(f'choice for variable "{variable.name}" must have a value')
raise DictConsistencyError(msg, 14, choice.xmlfiles)
choice.name = CONVERT_OPTION.get(choice.type, {}).get('func', str)(choice.name)
if choice_type is None:
choice_type = choice.type
values.append(choice.name)
if choice_type not in ['function', 'variable'] and hasattr(variable, 'value'):
for value in variable.value:
if value.name not in values:
msg = _(f'value "{value.name}" of variable "{variable.name}" is not in list '
f'of all expected values ({values})')
raise DictConsistencyError(msg, 15, value.xmlfiles)
ref_choice = variable.choice[0]
self.objectspace.paths.set_valid_enums(variable.path,
values,
variable.path_prefix,
)
for choice in variable.choices:
#if choice_type == 'variable':
# msg = _(f'only one "variable" choice is allowed '
# f'the variable "{variable.name}"')
# raise DictConsistencyError(msg, 5, choice.xmlfiles)
#if choice.type == 'nil':
# choice.name = None
#elif choice.type == 'space':
# choice.name = ' '
if isinstance(choice, dict):
if choice['type'] == 'variable':
obj = self.objectspace.paths[choice['variable']]
#FIXME?
if not obj.multi:
msg = _(f'only multi "variable" is allowed for a choice '
f'of variable "{variable.name}"')
raise DictConsistencyError(msg, 6, choice['xmlfiles'])
#values.append(obj)
choice['variable'] = obj
elif choice['type'] != 'jinja':
raise Exception('hu?')
# else:
# if not hasattr(choice, 'name'):
# msg = _(f'choice for variable "{variable.name}" must have a value')
# raise DictConsistencyError(msg, 14, choice.xmlfiles)
# choice.name = CONVERT_OPTION.get(choice.type, {}).get('func', str)(choice.name)
#if choice_type is None:
# choice_type = choice.type
# else:
# values.append(choice)
# FIXME if variable.values:
# FIXME for value in variable.values:
# FIXME if value not in values:
# FIXME msg = _(f'value "{value.name}" of variable "{variable.name}" is not in list '
# FIXME f'of all expected values ({values})')
# FIXME raise DictConsistencyError(msg, 15, value.xmlfiles)
#ref_choice = variable.choices[0]
self.objectspace.choices.append(variable.path,
values,
)
elif variable.type == 'choice':
msg = _(f'choice is mandatory for the variable "{variable.name}" with choice type')
raise DictConsistencyError(msg, 4, variable.xmlfiles)
variable.doc = variable.description
del variable.description
# variable.doc = variable.description
# del variable.description
def convert_test(self):
"""Convert variable tests value
@ -241,17 +267,13 @@ class Annotator(Walk): # pylint: disable=R0903
else:
value = CONVERT_OPTION.get(variable.type, {}).get('func', str)(value)
new_values.append(value)
if not hasattr(variable, 'information'):
variable.information = self.objectspace.information(variable.xmlfiles)
variable.information.test = tuple(new_values)
self.objectspace.informations.add(variable.path, 'test', tuple(new_values))
def convert_help(self):
"""Convert variable help
"""
for variable in self.get_variables():
if not hasattr(variable, 'help'):
if not hasattr(variable, 'help') or not variable.help:
continue
if not hasattr(variable, 'information'):
variable.information = self.objectspace.information(variable.xmlfiles)
variable.information.help = variable.help
self.objectspace.informations.add(variable.path, 'help', variable.help)
del variable.help

View file

@ -36,6 +36,7 @@ DTDDIR = join(dirname(abspath(__file__)), 'data')
RougailConfig = {'dictionaries_dir': [join(ROUGAILROOT, 'dictionaries')],
'services_dir': [join(ROUGAILROOT, 'services')],
'extra_dictionaries': {},
'patches_dir': join(ROUGAILROOT, 'patches'),
'templates_dir': join(ROUGAILROOT, 'templates'),
@ -62,14 +63,14 @@ RougailConfig = {'dictionaries_dir': [join(ROUGAILROOT, 'dictionaries')],
'modes_level': ['basic', 'normal', 'expert'],
'default_family_mode': 'basic',
'default_variable_mode': 'normal',
'default_files_engine': 'cheetah',
'default_files_engine': 'jinja',
'default_files_mode': 644,
'default_files_owner': 'root',
'default_files_group': 'root',
'default_files_included': 'no',
'default_overrides_engine': 'cheetah',
'default_overrides_engine': 'jinja',
'default_service_names_engine': 'none',
'default_certificate_domain': 'server_name',
'default_certificate_domain': 'rougail.server_name',
'base_option_name': 'baseoption',
'export_with_import': True,
'force_convert_dyn_option_description': False,

View file

@ -54,7 +54,7 @@ from .reflector import Reflector
from .tiramisureflector import TiramisuReflector
from .annotator import SpaceAnnotator
from .error import DictConsistencyError
from .providersupplier import provider_supplier
#from .providersupplier import provider_supplier
from .utils import normalize_family
@ -97,10 +97,10 @@ class RougailConvert:
extra_dir,
path_prefix,
)
if hasattr(self.rougailobjspace.space, 'variables'):
provider_supplier(self.rougailobjspace,
path_prefix,
)
# if hasattr(self.rougailobjspace.space, 'variables'):
# provider_supplier(self.rougailobjspace,
# path_prefix,
# )
self.dictionaries = True
def _load_dictionaries(self,

653
src/rougail/new_test.py Normal file
View file

@ -0,0 +1,653 @@
from typing import Optional, Union, get_type_hints, Any, Literal, List, Dict
from pydantic import BaseModel
from yaml import safe_load
from os import listdir
from os.path import join, isdir
from .annotator import SpaceAnnotator
from .tiramisureflector import TiramisuReflector
from .utils import normalize_family
class Family(BaseModel):
name: str
description: Optional[str]=None
type: Literal['family', 'leadership', 'dynamic']='family'
help: Optional[str]=None
mode: Optional[str]=None
hidden: Union[bool, str]=False
disabled: Union[bool, str]=False
xmlfiles: List[str]=[]
path: str
class Dynamic(Family):
variable: str
class Variable(BaseModel):
name: str
type: Literal['number', 'float', 'string', 'password', 'secret', 'mail', 'boolean', '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: Any=None
choices: Any=None
validators: Any=None
multi: bool=False
unique: Optional[bool]=None
help: Optional[str]=None
hidden: Union[bool, str]=False
disabled: Union[bool, str]=False
mandatory: Union[None, bool, str]=None
auto_save: bool=False
mode: Optional[str]=None
provider: Optional[str]=None
supplier: Optional[str]=None
test: Any=None
xmlfiles: List[str]=[]
path: str
class SymLink(BaseModel):
name: str
type: str='symlink'
opt: Variable
xmlfiles: List[str]=[]
path: str
class Service(BaseModel):
name: str
manage: bool=True
type: Literal['service', 'mount', 'swap', 'timer', 'target']='service'
disabled: Union[bool, str]=False
engine: Optional[str]=None
target: Optional[str]=None
undisable: bool=False
xmlfiles: List[str]=[]
class IP(BaseModel):
name: str
netmask: Optional[str]=None
disabled: Union[bool, str]=False
xmlfiles: List[str]=[]
class Certificate(BaseModel):
name: str
authority: str
mode: Optional[int]=None
owner: Union[None, str, Dict[str, str]]=None
group: Union[None, str, Dict[str, str]]=None
server: Union[None, str, Dict[str, str]]=None
domain: Union[None, str, Dict[str, str]]=None
provider: Optional[str]=None
format: Literal['cert_key', 'pem']='cert_key'
type: Literal['client', 'server']='client'
disabled: Union[bool, str]=False
xmlfiles: List[str]=[]
class File(BaseModel):
name: str
type: Literal['string', 'variable']='string'
mode: Optional[int]=None
owner: Union[None, str, Dict[str, str]]=None
group: Union[None, str, Dict[str, str]]=None
source: Union[None, str, Dict[str, str]]=None
engine: Optional[str]=None
variable: Optional[str]=None
included: Literal['no', 'name', 'content']='no'
disabled: Union[bool, str]=False
xmlfiles: List[str]=[]
class Override(BaseModel):
name: str
type: Literal['string', 'variable']='string'
source: Optional[str]=None
engine: Optional[str]=None
xmlfiles: List[str]=[]
class Param(BaseModel):
type: str
class Appendable:
def __init__(self) -> None:
self._data = {}
def append(self,
path: str,
data: str,
) -> None:
if path not in self._data:
self._data[path] = []
self._data[path].append(data)
def __getitem__(self,
path: str,
) -> list:
return self._data.get(path, [])
def __contains__(self,
path: str,
) -> bool:
return path in self._data
class Paths:
def __init__(self) -> None:
self._data = {}
def add(self,
path: str,
data: str,
force: bool=False,
) -> None:
if not force and path in self._data:
raise Exception('pfff')
self._data[path] = data
def __getitem__(self,
path: str,
) -> dict:
if not path in self._data:
raise Exception(f'cannot find variable or family {path}')
return self._data[path]
def __contains__(self,
path: str,
) -> bool:
return path in self._data
def __delitem__(self,
path: str,
) -> None:
del self._data[path]
def get(self):
return self._data.values()
class Informations:
def __init__(self) -> None:
self._data = {}
def add(self,
path: str,
key: str,
data: Any,
) -> None:
if data is None:
raise Exception('connard')
if path not in self._data:
self._data[path] = {}
if key in self._data[path]:
raise Exception(f'already key {key} in {path}')
self._data[path][key] = data
def get(self,
path: str,
) -> List[str]:
return self._data.get(path, [])
class ParserVariable:
def __init__(self):
self.paths = Paths()
self.families = []
self.variables = []
self.parents = {'.': []}
self.index = 0
self.reflector_names = {}
self.leaders = []
self.followers = []
self.dynamics = []
self.multis = {}
#
self.family = Family
self.dynamic = Dynamic
self.variable = Variable
self.param = Param
#FIXME
self.exclude_imports = []
self.informations = Informations()
self.properties = Appendable()
self.choices = Appendable()
self.default_multi = {}
super().__init__()
def load(self):
hint_family = get_type_hints(self.dynamic)
self.family_types = hint_family['type'].__args__
self.family_attrs = frozenset(set(hint_family) | {'redefine'} - {'name', 'path', 'xmlfiles'})
hint_variable = get_type_hints(self.variable)
self.variable_types = hint_variable['type'].__args__
self.variable_attrs = frozenset(set(hint_variable) | {'redefine', 'exists'} - {'name', 'path', 'xmlfiles'})
super().load()
def parse_variable_file(self,
filename: str,
namespace: str,
# description: str,
) -> None:
with open(filename) as o:
objects = safe_load(o)
self.validate_file_version(objects)
self.parse_family(filename, namespace, '.', namespace, {})
for name, obj in objects.items():
self.family_or_variable(filename,
name,
namespace,
obj,
)
def family_or_variable(self,
filename: str,
name: str,
subpath: str,
obj: dict,
first_variable: bool=False,
family_is_leadership: bool=False,
family_is_dynamic: bool=False,
) -> None:
if subpath:
path = f'{subpath}.{name}'
else:
path = name
if 'type' in obj:
if obj['type'] in self.family_types:
typ = 'family'
elif obj['type'] in self.variable_types:
typ = 'variable'
else:
raise Exception('hu.')
else:
if path in self.paths:
if path in self.families:
typ = 'family'
else:
typ = 'variable'
else:
extra_keys = set(obj) - self.family_attrs
typ = 'family'
for key in extra_keys:
value = obj[key]
if not isinstance(value, dict):
typ = 'variable'
break
if typ == 'variable' and set(obj) - self.variable_attrs:
raise Exception('cannot found type of {obj}')
if typ == 'family':
parser = self.parse_family
else:
parser = self.parse_variable
parser(filename,
name,
subpath,
path,
obj,
first_variable,
family_is_leadership,
family_is_dynamic,
)
def parse_family(self,
filename: str,
name: str,
subpath: str,
path: str,
family: dict,
first_variable: bool=False,
family_is_leadership: bool=False,
family_is_dynamic: bool=False,
) -> None:
family_obj = {}
subfamily_obj = {}
for key, value in family.items():
if key.startswith('_'):
key = key[1:]
if key in self.family_attrs and not isinstance(value, dict):
family_obj[key] = value
else:
subfamily_obj[key] = value
if path in self.paths:
if family_obj:
if not family.pop('redefine', False):
raise Exception('pfff')
self.paths.add(path, self.paths[path].copy(update=family), force=True)
self.paths[path].xmlfiles.append(filename)
force_not_first = True
else:
extra_attrs = set(family_obj) - self.family_attrs
if extra_attrs:
raise Exception(f'extra attrs ... {extra_attrs}')
self.add_family(subpath,
path,
name,
family_obj,
filename,
)
if family_is_dynamic:
self.dynamics.append(path)
force_not_first = False
if self.paths[path].type == 'dynamic':
family_is_dynamic = True
elif self.paths[path].type == 'leadership':
family_is_leadership = True
for idx, key in enumerate(subfamily_obj):
value = subfamily_obj[key]
if not isinstance(value, dict):
raise Exception(f'pfff {key}')
first_variable = not force_not_first and idx == 0
self.family_or_variable(filename,
key,
path,
value,
first_variable,
family_is_leadership,
family_is_dynamic,
)
def add_family(self,
subpath: str,
path: str,
name: str,
family: dict,
filename: str,
) -> None:
family['path'] = path
if not isinstance(filename, list):
filename = [filename]
family['xmlfiles'] = filename
if family.get('type', 'family') == 'dynamic':
family_obj = self.dynamic
else:
family_obj = self.family
self.paths.add(path, family_obj(name=name, **family))
self.set_name(self.paths[path], 'optiondescription_')
self.parents[subpath].append(path)
self.parents[path] = []
self.families.append(path)
def parse_variable(self,
filename: str,
name: str,
subpath: str,
path: str,
variable: dict,
first_variable: bool,
family_is_leadership: bool,
family_is_dynamic: bool,
) -> None:
extra_attrs = set(variable) - self.variable_attrs
if extra_attrs:
raise Exception(f'extra attrs ... {extra_attrs}')
if path in self.paths:
if 'exists' in variable and not variable['exists']:
return
if not variable.pop('redefine', False):
raise Exception('pfff')
self.paths.add(path, self.paths[path].copy(update=variable), force=True)
self.paths[path].xmlfiles.append(filename)
else:
if 'exists' in variable and variable.pop('exists'):
# this variable must exist
# but it's not the case
# so do nothing
return
if 'redefine' in variable and variable['redefine']:
raise Exception('cannot redefine!')
self.add_variable(subpath,
path,
name,
variable,
filename,
)
if family_is_leadership:
if first_variable:
self.leaders.append(path)
else:
self.followers.append(path)
if family_is_dynamic:
self.dynamics.append(path)
def add_variable(self,
subpath: str,
path: str,
name: str,
variable: dict,
filename: str,
) -> None:
variable['path'] = path
if not isinstance(filename, list):
filename = [filename]
variable['xmlfiles'] = filename
if variable.get('type') == 'symlink':
variable_obj = SymLink(name=name, **variable)
else:
variable_obj = self.variable(name=name, **variable)
self.paths.add(path, variable_obj)
self.variables.append(path)
self.parents[subpath].append(path)
self.set_name(variable_obj, 'option_')
def del_family(self,
path: str,
) -> None:
del self.paths[path]
self.families.remove(path)
del self.parents[path]
parent = path.rsplit('.', 1)[0]
self.parents[parent].remove(path)
class ParserService:
def __init__(self):
self.service = Service
self.ip = IP
self.certificate = Certificate
self.file = File
self.override = Override
self.services = {}
self.ips = {}
self.certificates = {}
self.files = {}
self.overrides = {}
def load(self):
self.service_attrs = frozenset(set(get_type_hints(self.service)) | {'redefine', 'type'} - {'name', 'xmlfiles'})
self.ip_attrs = frozenset(set(get_type_hints(self.ip)) - {'name', 'xmlfiles'})
self.certificate_attrs = frozenset(set(get_type_hints(self.certificate)) | {'redefine'} - {'name', 'xmlfiles'})
self.file_attrs = frozenset(set(get_type_hints(self.file)) | {'redefine'} - {'name', 'xmlfiles'})
self.override_attrs = frozenset(set(get_type_hints(self.override)) - {'name', 'xmlfiles'})
def parse_service_file(self,
filename: str,
) -> None:
with open(filename) as o:
objects = safe_load(o)
self.validate_file_version(objects)
for name, obj in objects.items():
self.parse_service(filename,
name,
obj,
)
def parse_service(self,
filename: str,
name: str,
service: dict,
) -> None:
service_obj = {}
subservice_obj = {}
for key, value in service.items():
if key.startswith('_'):
key = key[1:]
if key in self.service_attrs and not isinstance(value, dict):
service_obj[key] = value
else:
subservice_obj[key] = value
if name in self.services:
if service_obj:
if not service.pop('redefine', False):
raise Exception('pfff')
self.services[name] = self.services[name].copy(update=service)
else:
if '.' not in name:
raise Exception('pffff')
extra_attrs = set(service_obj) - self.service_attrs
if extra_attrs:
raise Exception(f'extra attrs ... {extra_attrs}')
service_obj['type'] = name.rsplit('.')[1]
self.services[name] = self.service(name=name, **service_obj)
self.services[name].xmlfiles.append(filename)
for key, value in subservice_obj.items():
if key == 'override':
getattr(self, f'parse_service_{key}')(key, value, f'services.{normalize_family(name)}', filename)
else:
if not isinstance(value, dict):
raise Exception(f'pfff {key}')
for subname, subvalue in value.items():
getattr(self, f'parse_service_{key}')(subname, subvalue, f'services.{normalize_family(name)}', filename)
def parse_service_ip(self,
name: str,
ip: dict,
path: str,
filename: str,
) -> None:
extra_attrs = set(ip) - self.ip_attrs
if extra_attrs:
raise Exception(f'extra attrs ... {extra_attrs}')
self.ips.setdefault(path, []).append(self.ip(name=name, **ip))
self.ips[path][-1].xmlfiles.append(filename)
def parse_service_certificates(self,
name: str,
certificate: dict,
path: str,
filename: str,
) -> None:
extra_attrs = set(certificate) - self.certificate_attrs
if extra_attrs:
raise Exception(f'extra attrs ... {extra_attrs}')
self.certificates.setdefault(path, []).append(self.certificate(name=name, **certificate))
self.certificates[path][-1].xmlfiles.append(filename)
def parse_service_files(self,
name: str,
file: dict,
path: str,
filename: str,
) -> None:
extra_attrs = set(file) - self.file_attrs
if extra_attrs:
raise Exception(f'extra attrs ... {extra_attrs}')
self.files.setdefault(path, []).append(self.file(name=name, **file))
self.files[path][-1].xmlfiles.append(filename)
def parse_service_override(self,
name: str,
override: dict,
path: str,
filename: str,
) -> None:
if override:
extra_attrs = set(override) - self.override_attrs
if extra_attrs:
raise Exception(f'extra attrs ... {extra_attrs}')
self.overrides.setdefault(path, []).append(self.override(name=name, **override))
else:
self.overrides.setdefault(path, []).append(self.override(name=name))
self.overrides[path][-1].xmlfiles.append(filename)
class Parser(ParserVariable, ParserService):
supported_version = ['1.0']
def __init__(self,
rougailconfig: 'RougailConfig'
) -> None:
# FIXME useful?
self.annotator = False
self.rougailconfig = rougailconfig
super().__init__()
def load(self):
super().load()
self.parse_directories()
self.annotate()
self.reflect()
def parse_directories(self) -> None:
for filename in self.get_sorted_filename(self.rougailconfig['dictionaries_dir']):
namespace = self.rougailconfig['variable_namespace']
self.parse_variable_file(filename,
namespace,
# self.rougailconfig['variable_namespace_description'],
)
for namespace, extra_dirs in self.rougailconfig['extra_dictionaries'].items():
for filename in self.get_sorted_filename(extra_dirs):
self.parse_variable_file(filename,
namespace,
# namespace,
)
for filename in self.get_sorted_filename(self.rougailconfig['services_dir']):
self.parse_service_file(filename)
def get_sorted_filename(self,
directories: Union[str, List[str]],
) -> List[str]:
filenames = {}
if not isinstance(directories, list):
directories = [directories]
for directory in directories:
if not isdir(directory):
continue
for filename in listdir(directory):
if not filename.endswith('.yml'):
continue
full_filename = join(directory, filename)
if filename in filenames:
raise DictConsistencyError(_(f'duplicate dictionary file name {filename}'), 78, [filenames[filename][1], full_filename])
filenames[filename] = full_filename
for filename in sorted(filenames):
yield filenames[filename]
def validate_file_version(self,
obj: dict,
) -> None:
if 'version' not in obj:
raise Exception('version ...')
version = obj.pop('version')
if version not in self.supported_version:
raise Exception(f'pffff version ... {version} not in {self.supported_version}')
def set_name(self,
obj,
option_prefix,
):
self.index += 1
self.reflector_names[obj.path] = f'{option_prefix}{self.index}{self.rougailconfig["suffix"]}'
def annotate(self):
if self.annotator:
raise DictConsistencyError(_('Cannot execute annotate multiple time'), 85, None)
SpaceAnnotator(self)
self.annotator = True
def reflect(self):
functions_file = self.rougailconfig['functions_file']
if not isinstance(functions_file, list):
functions_file = [functions_file]
functions_file = [func for func in functions_file if func not in self.exclude_imports]
self.reflector = TiramisuReflector(self,
functions_file,
)
def get(self):
return self.reflector.get_text()

View file

@ -587,24 +587,24 @@ class RougailObjSpace:
getattr(space, child.tag).append(variableobj)
else:
setattr(space, child.tag, variableobj)
def get_variables(objectspace):
"""Iter all variables from the objectspace
"""
if not hasattr(objectspace.space, 'variables'):
return
for family in objectspace.space.variables.values():
yield from _get_variables(family, objectspace.family)
def _get_variables(family, family_type):
if hasattr(family, 'variable'):
for variable in family.variable.values():
if isinstance(variable, family_type):
yield from _get_variables(variable, family_type)
else:
yield variable
if hasattr(family, 'variables'):
for family in family.variables.values():
yield from _get_variables(family, family_type)
#
#
#def get_variables(objectspace):
# """Iter all variables from the objectspace
# """
# if not hasattr(objectspace.space, 'variables'):
# return
# for family in objectspace.space.variables.values():
# yield from _get_variables(family, objectspace.family)
#
#
#def _get_variables(family, family_type):
# if hasattr(family, 'variable'):
# for variable in family.variable.values():
# if isinstance(variable, family_type):
# yield from _get_variables(variable, family_type)
# else:
# yield variable
# if hasattr(family, 'variables'):
# for family in family.variables.values():
# yield from _get_variables(family, family_type)

View file

@ -16,26 +16,26 @@ 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 rougail.objspace import get_variables
from rougail.utils import normalize_family
def provider_supplier(objectspace,
path_prefix,
):
n_path_prefix = normalize_family(path_prefix)
for variable in get_variables(objectspace):
if variable.path_prefix != n_path_prefix:
continue
if hasattr(variable, 'provider'):
family_name, variable.name = variable.path.rsplit('.', 1)
objectspace.paths.set_provider(variable,
variable.name,
family_name,
)
if hasattr(variable, 'supplier'):
family_name, variable.name = variable.path.rsplit('.', 1)
objectspace.paths.set_supplier(variable,
variable.name,
family_name,
)
#from rougail.objspace import get_variables
#from rougail.utils import normalize_family
#
#
#def provider_supplier(objectspace,
# path_prefix,
# ):
# n_path_prefix = normalize_family(path_prefix)
# for variable in get_variables(objectspace):
# if variable.path_prefix != n_path_prefix:
# continue
# if hasattr(variable, 'provider'):
# family_name, variable.name = variable.path.rsplit('.', 1)
# objectspace.paths.set_provider(variable,
# variable.name,
# family_name,
# )
# if hasattr(variable, 'supplier'):
# family_name, variable.name = variable.path.rsplit('.', 1)
# objectspace.paths.set_supplier(variable,
# variable.name,
# family_name,
# )

View file

@ -1,4 +1,20 @@
from . import none, cheetah, jinja, creole_legacy
__all__ = ('none', 'cheetah', 'jinja', 'creole_legacy')
MODULES = ['none']
from . import none
try:
from . import cheetah
MODULES.append('cheetah')
except ImportError:
pass
try:
from . import creole_legacy
MODULES.append('creole_legacy')
except ImportError:
pass
try:
from . import jinja
MODULES.append('jinja')
except ImportError:
pass
__all__ = tuple(MODULES)

View file

@ -42,6 +42,7 @@ class BaseElt: # pylint: disable=R0903
"""Base element
"""
path = '.'
type = 'family'
def sorted_func_name(func_name):
@ -56,17 +57,15 @@ class TiramisuReflector:
def __init__(self,
objectspace,
funcs_paths,
internal_functions,
cfg,
):
self.cfg = cfg
self.rougailconfig = objectspace.rougailconfig
self.jinja_added = False
self.reflector_objects = {}
self.text = {'header': [],
'option': [],
'optiondescription': [],
}
if funcs_paths:
if self.cfg['export_with_import']:
if self.rougailconfig['export_with_import']:
self.text['header'].extend(["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",
"class func:",
@ -87,9 +86,9 @@ class TiramisuReflector:
if not isfile(funcs_path):
continue
self.text['header'].append(f"_load_functions('{funcs_path}')")
if self.cfg['export_with_import']:
if internal_functions:
for func in internal_functions:
if self.rougailconfig['export_with_import']:
if self.rougailconfig['internal_functions']:
for func in self.rougailconfig['internal_functions']:
self.text['header'].append(f"setattr(func, '{func}', {func})")
self.text['header'].extend(["try:",
" from tiramisu4 import *",
@ -98,12 +97,12 @@ class TiramisuReflector:
" from tiramisu import *",
" from tiramisu.setting import ALLOWED_LEADER_PROPERTIES",
])
for mode in objectspace.rougailconfig["modes_level"]:
for mode in self.rougailconfig["modes_level"]:
self.text['header'].append(f'ALLOWED_LEADER_PROPERTIES.add("{mode}")')
self.objectspace = objectspace
self.make_tiramisu_objects()
if self.cfg['export_with_import'] and (self.cfg['force_convert_dyn_option_description'] or self.objectspace.has_dyn_option is True):
self.text['header'].append("from rougail.tiramisu import ConvertDynOptionDescription")
#FIXME if self.rougailconfig['export_with_import'] and (self.rougailconfig['force_convert_dyn_option_description'] or self.objectspace.has_dyn_option is True):
# self.text['header'].append("from rougail.tiramisu import ConvertDynOptionDescription")
def add_jinja_to_function(self,
variable_name: str,
@ -146,20 +145,30 @@ class TiramisuReflector:
"""make tiramisu objects
"""
baseelt = BaseElt()
baseelt.reflector_name = f'option_0{self.objectspace.rougailconfig["suffix"]}'
self.set_name(baseelt)
self.objectspace.reflector_names[baseelt.path] = f'option_0{self.rougailconfig["suffix"]}'
basefamily = Family(baseelt,
self,
)
if not self.objectspace.paths.has_path_prefix():
for elt in self.reorder_family(self.objectspace.space):
self.populate_family(basefamily,
elt,
)
if not hasattr(basefamily.elt, 'information'):
basefamily.elt.information = self.objectspace.information(None)
basefamily.elt.information = self.objectspace.paths.get_providers_path()
basefamily.elt.information.update(self.objectspace.paths.get_suppliers_path())
#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():
if elt.path in self.objectspace.families:
Family(elt,
self,
)
else:
Variable(elt,
self,
)
# self.populate_family(basefamily,
# elt,
# )
#FIXME if not hasattr(basefamily.elt, 'information'):
# basefamily.elt.information = self.objectspace.information(None)
# basefamily.elt.information = self.objectspace.paths.get_providers_path()
# basefamily.elt.information.update(self.objectspace.paths.get_suppliers_path())
else:
path_prefixes = self.objectspace.paths.get_path_prefixes()
for path_prefix in path_prefixes:
@ -179,66 +188,66 @@ class TiramisuReflector:
setattr(baseprefix.elt.information, key, value)
for key, value in self.objectspace.paths.get_suppliers_path(path_prefix).items():
setattr(baseprefix.elt.information, key, value)
baseelt.name = normalize_family(self.cfg['base_option_name'])
baseelt.doc = self.cfg['base_option_name']
baseelt.reflector_object.get([], baseelt.doc, 'base') # pylint: disable=E1101
def reorder_family(self, space):
"""variable_namespace family has to be loaded before any other family
because `extra` family could use `variable_namespace` variables.
"""
if hasattr(space, 'variables'):
variable_namespace = self.objectspace.rougailconfig['variable_namespace']
if variable_namespace in space.variables:
yield space.variables[variable_namespace]
for elt, value in space.variables.items():
if elt != self.objectspace.rougailconfig['variable_namespace']:
yield value
if hasattr(space, 'services'):
yield space.services
def populate_family(self,
parent_family,
elt,
):
"""Populate family
"""
self.set_name(elt)
family = Family(elt,
self,
)
parent_family.add(family)
for children in vars(elt).values():
if isinstance(children, self.objectspace.family):
self.populate_family(family,
children,
)
continue
if isinstance(children, dict):
children = list(children.values())
if isinstance(children, list):
for child in children:
if isinstance(child, self.objectspace.property_) or \
not isinstance(child, RootRougailObject):
continue
if isinstance(child, self.objectspace.variable):
self.set_name(child)
family.add(Variable(child,
self,
))
else:
self.populate_family(family,
child,
)
baseelt.name = normalize_family(self.rougailconfig['base_option_name'])
baseelt.description = self.rougailconfig['base_option_name']
self.reflector_objects[baseelt.path].get([], baseelt.description, 'base') # pylint: disable=E1101
#
# def reorder_family(self, space):
# """family has to be loaded before any other family
# because `extra` family could use `variable_namespace` variables.
# """
# if hasattr(space, 'variables'):
# variable_namespace = self.rougailconfig['variable_namespace']
# if variable_namespace in space.variables:
# yield space.variables[variable_namespace]
# for elt, value in space.variables.items():
# if elt != self.rougailconfig['variable_namespace']:
# yield value
# if hasattr(space, 'services'):
# yield space.services
#
# def populate_family(self,
# parent_family,
# elt,
# ):
# """Populate family
# """
# self.set_name(elt)
# family = Family(elt,
# self,
# )
# parent_family.add(family)
# for children in vars(elt).values():
# if isinstance(children, self.objectspace.family):
# self.populate_family(family,
# children,
# )
# continue
# if isinstance(children, dict):
# children = list(children.values())
# if isinstance(children, list):
# for child in children:
# if isinstance(child, self.objectspace.property_) or \
# not isinstance(child, RootRougailObject):
# continue
# if isinstance(child, self.objectspace.variable):
# self.set_name(child)
# family.add(Variable(child,
# self,
# ))
# else:
# self.populate_family(family,
# child,
# )
def set_name(self,
elt,
):
"""Set name
"""
if not hasattr(elt, 'reflector_name'):
self.objectspace.paths.set_name(elt, 'optiondescription_')
return elt.reflector_name
if elt.path not in self.objectspace.reflector_names:
self.objectspace.set_name(elt, 'optiondescription_')
return self.objectspace.reflector_names[elt.path]
def get_text(self):
"""Get text
@ -247,7 +256,7 @@ class TiramisuReflector:
self.text['header'].extend(["ENV = SandboxedEnvironment(loader=DictLoader(dict_env), undefined=StrictUndefined)",
"ENV.compile_templates('jinja_caches', zip=None)",
])
return '\n'.join(self.text['header'] + self.text['option'] + self.text['optiondescription'])
return '\n'.join(self.text['header'] + self.text['option'])
class Common:
@ -257,10 +266,11 @@ class Common:
elt,
tiramisu,
):
self.objectspace = tiramisu.objectspace
self.elt = elt
self.option_name = None
self.tiramisu = tiramisu
self.elt.reflector_object = self
tiramisu.reflector_objects[elt.path] = self
self.object_type = None
def get(self, calls, parent_name, typ):
@ -273,7 +283,7 @@ class Common:
self_calls.append(self.elt.path)
self.calls = self_calls
if self.option_name is None:
self.option_name = self.elt.reflector_name
self.option_name = self.objectspace.reflector_names[self.elt.path]
self.populate_attrib()
self.populate_informations()
return self.option_name
@ -282,19 +292,13 @@ class Common:
"""Populate attributes
"""
keys = {'name': self.convert_str(self.elt.name)}
if hasattr(self.elt, 'doc'):
keys['doc'] = self.convert_str(self.elt.doc)
if hasattr(self.elt, 'description') and self.elt.description:
keys['doc'] = self.convert_str(self.elt.description)
self._populate_attrib(keys)
if hasattr(self.elt, 'properties'):
keys['properties'] = self.properties_to_string(self.elt.properties)
if self.elt.path in self.objectspace.properties:
keys['properties'] = self.properties_to_string(self.objectspace.properties[self.elt.path])
attrib = ', '.join([f'{key}={value}' for key, value in keys.items()])
if self.__class__.__name__ == 'Family':
#pouet
name = 'option'
#name = 'optiondescription'
else:
name = 'option'
self.tiramisu.text[name].append(f'{self.option_name} = {self.object_type}({attrib})')
self.tiramisu.text['option'].append(f'{self.option_name} = {self.object_type}({attrib})')
def _populate_attrib(self,
keys: dict,
@ -315,7 +319,7 @@ class Common:
properties = [self.convert_str(property_) for property_ in values
if isinstance(property_, str)]
calc_properties = [self.calc_properties(property_) for property_ in values \
if isinstance(property_, self.tiramisu.objectspace.property_)]
if isinstance(property_, dict)]
return 'frozenset({' + ', '.join(sorted(properties) + calc_properties) + '})'
def calc_properties(self,
@ -323,7 +327,7 @@ class Common:
) -> str:
"""Populate properties
"""
option_name = child.source.reflector_object.get(self.calls, self.elt.path, 'property')
option_name = self.tiramisu.reflector_objects[child.source.path].get(self.calls, self.elt.path, 'property')
kwargs = (f"'condition': ParamOption({option_name}, notraisepropertyerror=True), "
f"'expected': {self.populate_param(child.expected)}")
if child.inverse:
@ -334,15 +338,10 @@ class Common:
def populate_informations(self):
"""Populate Tiramisu's informations
"""
if not hasattr(self.elt, 'information'):
informations = self.objectspace.informations.get(self.elt.path)
if not informations:
return
if isinstance(self.elt.information, dict):
informations = self.elt.information
else:
informations = vars(self.elt.information)
for key, value in informations.items():
if key == 'xmlfiles':
continue
if isinstance(value, str):
value = self.convert_str(value)
self.tiramisu.text['option'].append(f"{self.option_name}.impl_set_information('{key}', {value})")
@ -352,10 +351,10 @@ class Common:
):
"""Populate variable parameters
"""
if param.type in ['number', 'boolean', 'nil', 'port', 'choice', 'space']:
return f'ParamValue({param.text})'
if param.type in ['variable_name', 'variable']:
if isinstance(param, self.objectspace.variable):
return self.build_option_param(param)
if not isinstance(param, self.objectspace.param):
return f'ParamValue({param})'
if param.type == 'information':
if hasattr(self.elt, 'multi') and self.elt.multi:
default = []
@ -364,15 +363,12 @@ class Common:
if hasattr(param, 'variable'):
if param.variable.path == self.elt.path:
return f'ParamSelfInformation("{param.text}", {default})'
return f'ParamInformation("{param.text}", {default}, option={param.variable.reflector_object.get(self.calls, self.elt.path, "param")})'
return f'ParamInformation("{param.text}", {default}, option={self.tiramisu.reflector_objects[param.variable.path].get(self.calls, self.elt.path, "param")})'
return f'ParamInformation("{param.text}", {default})'
if param.type == 'suffix':
return 'ParamSuffix()'
if param.type == 'index':
return 'ParamIndex()'
if param.type == 'jinja':
self.tiramisu.add_jinja_to_function(self.elt.path, param.text)
return f'ParamValue("{self.elt.path}")'
value = self.convert_str(param.text)
return f'ParamValue({value})'
@ -381,21 +377,18 @@ class Common:
) -> str:
"""build variable parameters
"""
if param.type == 'variable':
option_name = param.text.reflector_object.get(self.calls, self.elt.path, 'param')
else:
option_name = param.text
option_name = self.tiramisu.reflector_objects[param.path].get(self.calls, self.elt.path, 'param')
params = [f'{option_name}']
if hasattr(param, 'suffix'):
param_type = 'ParamDynOption'
family = param.family.reflector_object.get(self.calls, self.elt.path, 'suffix')
family = self.tiramisu.reflector_objects[param.family.path].get(self.calls, self.elt.path, 'suffix')
params.extend([f"'{param.suffix}'", f'{family}'])
if param.optional:
params.append('optional=True')
else:
param_type = 'ParamOption'
if not param.propertyerror:
params.append('notraisepropertyerror=True')
# if not param.propertyerror:
# params.append('notraisepropertyerror=True')
return "{}({})".format(param_type, ', '.join(params))
@ -412,30 +405,37 @@ class Variable(Common):
def _populate_attrib(self,
keys: dict,
):
if hasattr(self.elt, 'opt'):
keys['opt'] = self.elt.opt.reflector_object.get(self.calls, self.elt.path, 'opt')
if hasattr(self.elt, 'choice'):
values = self.elt.choice
if values[0].type == 'variable':
value = values[0].name.reflector_object.get(self.calls, self.elt.path, 'choice')
keys['values'] = f"Calculation(func.calc_value, Params((ParamOption({value}))))"
elif values[0].type == 'function':
keys['values'] = self.calculation_value(values[0], [])
if self.elt.type == 'symlink':
keys['opt'] = self.tiramisu.reflector_objects[self.elt.opt.path].get(self.calls, self.elt.path, 'opt')
if hasattr(self.elt, 'choices') and self.elt.choices:
values = self.elt.choices
if isinstance(values[0], dict):
if values[0]['type'] == 'variable':
value = self.tiramisu.reflector_objects[values[0]['variable'].path].get(self.calls, self.elt.path, 'choice')
keys['values'] = f"Calculation(func.calc_value, Params((ParamOption({value}))))"
elif values[0]['type'] == 'jinja':
keys['values'] = self.calculation_value(values[0], [])
else:
keys['values'] = str(tuple([val.name for val in values]))
if hasattr(self.elt, 'multi') and self.elt.multi:
keys['multi'] = self.elt.multi
for key in ['default', 'default_multi']:
if hasattr(self.elt, key) and getattr(self.elt, key) is not None:
value = getattr(self.elt, key)
if isinstance(value, str):
value = self.convert_str(value)
elif isinstance(value, self.tiramisu.objectspace.value):
value = self.calculation_value(value, [], calc_multi=value.calc_multi)
keys[key] = value
if hasattr(self.elt, 'validators'):
keys['validators'] = '[' + ', '.join([self.calculation_value(val,
['ParamSelfOption(whole=False)']) for val in self.elt.validators]) + ']'
keys['values'] = str(tuple(values))
if self.elt.path in self.objectspace.multis:
keys['multi'] = self.objectspace.multis[self.elt.path]
if hasattr(self.elt, 'default') and self.elt.default is not None:
value = self.elt.default
if isinstance(value, str):
value = self.convert_str(value)
elif isinstance(value, dict):
value = self.calculation_value(value, [], False) # calc_multi=key == 'calc_multi')
keys['default'] = value
if self.elt.path in self.objectspace.default_multi:
value = self.objectspace.default_multi[self.elt.path]
if isinstance(value, str):
value = self.convert_str(value)
elif isinstance(value, dict):
value = self.calculation_value(value, [], False) # calc_multi=key == 'calc_multi')
keys['default_multi'] = value
#FIXME if self.elt.validators:
# keys['validators'] = '[' + ', '.join([self.calculation_value(val,
# ['ParamSelfOption(whole=False)']) for val in self.elt.validators]) + ']'
for key in ['min_number', 'max_number']:
if hasattr(self.elt, key):
keys[key] = getattr(self.elt, key)
@ -451,22 +451,21 @@ class Variable(Common):
) -> str:
"""Generate calculated value
"""
kwargs = []
if child['type'] == 'jinja':
self.tiramisu.add_jinja_to_function(self.elt.path, child['jinja'])
function = 'jinja_to_function'
else:
raise Exception("connard")
# has parameters
function = child.name
new_args = []
if hasattr(child, 'param'):
for param in child.param:
value = self.populate_param(param)
if not hasattr(param, 'name'):
kwargs = []
if 'params' in child:
for key, value in child['params'].items():
value = self.populate_param(value)
if not key:
new_args.append(str(value))
else:
kwargs.append(f"'{param.name}': " + value)
if function == 'valid_network_netmask':
new_args.extend(args)
else:
args.extend(new_args)
new_args = args
kwargs.append(f"'{key}': " + value)
ret = f'Calculation(func.{function}, Params((' + ', '.join(new_args) + ')'
if kwargs:
ret += ', kwargs={' + ', '.join(kwargs) + '}'
@ -487,10 +486,10 @@ class Family(Common):
tiramisu,
):
super().__init__(elt, tiramisu)
if hasattr(self.elt, 'suffixes'):
if self.elt.type == 'dynamic':
self.tiramisu.objectspace.has_dyn_option = True
self.object_type = 'ConvertDynOptionDescription'
elif hasattr(self.elt, 'leadership') and self.elt.leadership:
elif self.elt.type == 'leadership':
self.object_type = 'Leadership'
else:
self.object_type = 'OptionDescription'
@ -504,7 +503,10 @@ class Family(Common):
def _populate_attrib(self,
keys: list,
) -> None:
if hasattr(self.elt, 'suffixes'):
dyn = self.elt.suffixes.reflector_object.get(self.calls, self.elt.path, 'suffixes')
if self.elt.type == 'dynamic':
dyn = self.tiramisu.reflector_objects[self.elt.variable.path].get(self.calls, self.elt.path, 'suffixes')
keys['suffixes'] = f"Calculation(func.calc_value, Params((ParamOption({dyn}, notraisepropertyerror=True))))"
keys['children'] = '[' + ', '.join([child.get(self.calls, self.elt.path, 'child') for child in self.children]) + ']'
children = []
for path in self.objectspace.parents[self.elt.path]:
children.append(self.objectspace.paths[path])
keys['children'] = '[' + ', '.join([self.tiramisu.reflector_objects[child.path].get(self.calls, self.elt.path, 'child') for child in children]) + ']'

File diff suppressed because it is too large Load diff

View file

@ -1,10 +0,0 @@
{
"rougail.myvar": {
"owner": "forced",
"value": "no"
},
"rougail.server_deployed": {
"owner": "default",
"value": false
}
}

View file

@ -1,4 +0,0 @@
{
"rougail.myvar": "no",
"rougail.server_deployed": false
}

View file

@ -1,10 +0,0 @@
{
"rougail.myvar": {
"owner": "default",
"value": "no"
},
"rougail.server_deployed": {
"owner": "default",
"value": false
}
}

View file

@ -1,29 +0,0 @@
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
class func:
pass
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
setattr(func, function, getattr(func_, function))
_load_functions('tests/dictionaries/../eosfunc/test.py')
try:
from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except:
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("normal")
ALLOWED_LEADER_PROPERTIES.add("expert")
option_2 = BoolOption(name="server_deployed", doc="server_deployed", default=False, properties=frozenset({"mandatory", "normal"}))
option_1 = StrOption(name="myvar", doc="myvar", default="no", properties=frozenset({"basic", "force_store_value", "mandatory", Calculation(func.calc_value, Params(ParamValue('frozen'), kwargs={'condition': ParamOption(option_2, notraisepropertyerror=True), 'expected': ParamValue(True)}), func.calc_value_property_help)}))
optiondescription_3 = OptionDescription(name="rougail", doc="Rougail", children=[option_1, option_2], properties=frozenset({"basic"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_3])

View file

@ -1,34 +0,0 @@
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
class func:
pass
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
setattr(func, function, getattr(func_, function))
_load_functions('tests/dictionaries/../eosfunc/test.py')
try:
from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except:
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("normal")
ALLOWED_LEADER_PROPERTIES.add("expert")
option_2 = BoolOption(name="server_deployed", doc="server_deployed", default=False, properties=frozenset({"mandatory", "normal"}))
option_1 = StrOption(name="myvar", doc="myvar", default="no", properties=frozenset({"basic", "force_store_value", "mandatory", Calculation(func.calc_value, Params(ParamValue('frozen'), kwargs={'condition': ParamOption(option_2, notraisepropertyerror=True), 'expected': ParamValue(True)}), func.calc_value_property_help)}))
optiondescription_6 = OptionDescription(name="rougail", doc="Rougail", children=[option_1, option_2], properties=frozenset({"basic"}))
optiondescription_5 = OptionDescription(name="1", doc="1", children=[optiondescription_6])
option_4 = BoolOption(name="server_deployed", doc="server_deployed", default=False, properties=frozenset({"mandatory", "normal"}))
option_3 = StrOption(name="myvar", doc="myvar", default="no", properties=frozenset({"basic", "force_store_value", "mandatory", Calculation(func.calc_value, Params(ParamValue('frozen'), kwargs={'condition': ParamOption(option_4, notraisepropertyerror=True), 'expected': ParamValue(True)}), func.calc_value_property_help)}))
optiondescription_8 = OptionDescription(name="rougail", doc="Rougail", children=[option_3, option_4], properties=frozenset({"basic"}))
optiondescription_7 = OptionDescription(name="2", doc="2", children=[optiondescription_8])
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_5, optiondescription_7])

View file

@ -1,11 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<variables>
<variable name="myvar" auto_freeze="True">
<value>no</value>
</variable>
<variable name="server_deployed" type="boolean">
<value>False</value>
</variable>
</variables>
</rougail>

View file

@ -1,11 +0,0 @@
version: '0.10'
variables:
- variable:
- name: myvar
auto_freeze: true
value:
- text: 'no'
- name: server_deployed
type: boolean
value:
- text: false

View file

@ -1,7 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.9">
<services>
<service name="tata">
</service>
</services>
</rougail>

View file

@ -1,9 +1,9 @@
{
"services.tata.activate": {
"services.tata_service.activate": {
"owner": "default",
"value": true
},
"services.tata.manage": {
"services.tata_service.manage": {
"owner": "default",
"value": true
}

View file

@ -1,4 +1,4 @@
{
"services.tata.activate": true,
"services.tata.manage": true
"services.tata_service.activate": true,
"services.tata_service.manage": true
}

View file

@ -1,9 +1,9 @@
{
"services.tata.activate": {
"services.tata_service.activate": {
"owner": "default",
"value": true
},
"services.tata.manage": {
"services.tata_service.manage": {
"owner": "default",
"value": true
}

View file

@ -0,0 +1,2 @@
tata.service: {}
version: '1.0'

View file

@ -1,18 +1,31 @@
from importlib.machinery import SourceFileLoader
from importlib.util import spec_from_loader, module_from_spec
loader = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py')
spec = spec_from_loader(loader.name, loader)
func = module_from_spec(spec)
loader.exec_module(func)
for key, value in dict(locals()).items():
if key != ['SourceFileLoader', 'func']:
setattr(func, key, value)
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
class func:
pass
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
setattr(func, function, getattr(func_, function))
_load_functions('tests/dictionaries_old/../eosfunc/test.py')
try:
from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except:
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("normal")
ALLOWED_LEADER_PROPERTIES.add("expert")
option_3 = BoolOption(name="activate", doc="activate", default=True)
option_4 = BoolOption(name="manage", doc="manage", default=True)
option_2 = OptionDescription(name="tata", doc="tata", children=[option_3, option_4])
option_1 = OptionDescription(name="services", doc="services", children=[option_2], properties=frozenset({"hidden"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])
optiondescription_2 = OptionDescription(name="tata_service", doc="tata_service", children=[option_3, option_4])
optiondescription_2.impl_set_information('type', "service")
optiondescription_1 = OptionDescription(name="services", doc="services", children=[optiondescription_2], properties=frozenset({"hidden", "normal"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -0,0 +1,38 @@
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
class func:
pass
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
setattr(func, function, getattr(func_, function))
_load_functions('tests/dictionaries/../eosfunc/test.py')
try:
from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except:
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("normal")
ALLOWED_LEADER_PROPERTIES.add("expert")
option_1 = BoolOption(name="activate", doc="activate", default=True)
option_2 = BoolOption(name="manage", doc="manage", default=True)
optiondescription_7 = OptionDescription(name="tata_service", doc="tata.service", children=[option_1, option_2])
optiondescription_7.impl_set_information('type', "service")
optiondescription_6 = OptionDescription(name="services", doc="services", children=[optiondescription_7], properties=frozenset({"hidden"}))
optiondescription_5 = OptionDescription(name="1", doc="1", children=[optiondescription_6])
option_3 = BoolOption(name="activate", doc="activate", default=True)
option_4 = BoolOption(name="manage", doc="manage", default=True)
optiondescription_10 = OptionDescription(name="tata_service", doc="tata.service", children=[option_3, option_4])
optiondescription_10.impl_set_information('type', "service")
optiondescription_9 = OptionDescription(name="services", doc="services", children=[optiondescription_10], properties=frozenset({"hidden"}))
optiondescription_8 = OptionDescription(name="2", doc="2", children=[optiondescription_9])
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_5, optiondescription_8])

View file

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<services>
<service name="tata">
</service>
</services>
</rougail>

View file

@ -0,0 +1,4 @@
version: '0.10'
services:
- service:
- name: tata

View file

@ -1,11 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.9">
<variables>
<variable name="myvar" auto_freeze="True">
<value>no</value>
</variable>
<variable name="server_deployed" type="boolean">
<value>False</value>
</variable>
</variables>
</rougail>

View file

@ -1,10 +0,0 @@
{
"rougail.myvar": {
"owner": "forced",
"value": "no"
},
"rougail.server_deployed": {
"owner": "default",
"value": false
}
}

View file

@ -1,4 +0,0 @@
{
"rougail.myvar": "no",
"rougail.server_deployed": false
}

View file

@ -1,10 +0,0 @@
{
"rougail.myvar": {
"owner": "default",
"value": "no"
},
"rougail.server_deployed": {
"owner": "default",
"value": false
}
}

View file

@ -1,17 +0,0 @@
from importlib.machinery import SourceFileLoader
from importlib.util import spec_from_loader, module_from_spec
loader = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py')
spec = spec_from_loader(loader.name, loader)
func = module_from_spec(spec)
loader.exec_module(func)
for key, value in dict(locals()).items():
if key != ['SourceFileLoader', 'func']:
setattr(func, key, value)
try:
from tiramisu4 import *
except:
from tiramisu import *
option_3 = BoolOption(name="server_deployed", doc="server_deployed", default=False, properties=frozenset({"mandatory", "normal"}))
option_2 = StrOption(name="myvar", doc="myvar", default="no", properties=frozenset({"basic", "force_store_value", "mandatory", Calculation(func.calc_value, Params(ParamValue('frozen'), kwargs={'condition': ParamOption(option_3, todict=True, notraisepropertyerror=True), 'expected': ParamValue(True)}))}))
option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2, option_3])
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])

View file

@ -1,11 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.9">
<variables>
<variable name="my_var" auto_freeze="True" mode="expert">
<value>no</value>
</variable>
<variable name="server_deployed" type="boolean">
<value>False</value>
</variable>
</variables>
</rougail>

View file

@ -1,10 +0,0 @@
{
"rougail.my_var": {
"owner": "forced",
"value": "no"
},
"rougail.server_deployed": {
"owner": "default",
"value": false
}
}

View file

@ -1,4 +0,0 @@
{
"rougail.my_var": "no",
"rougail.server_deployed": false
}

View file

@ -1,10 +0,0 @@
{
"rougail.my_var": {
"owner": "default",
"value": "no"
},
"rougail.server_deployed": {
"owner": "default",
"value": false
}
}

View file

@ -1,17 +0,0 @@
from importlib.machinery import SourceFileLoader
from importlib.util import spec_from_loader, module_from_spec
loader = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py')
spec = spec_from_loader(loader.name, loader)
func = module_from_spec(spec)
loader.exec_module(func)
for key, value in dict(locals()).items():
if key != ['SourceFileLoader', 'func']:
setattr(func, key, value)
try:
from tiramisu4 import *
except:
from tiramisu import *
option_3 = BoolOption(name="server_deployed", doc="server_deployed", default=False, properties=frozenset({"mandatory", "normal"}))
option_2 = StrOption(name="my_var", doc="my_var", default="no", properties=frozenset({"expert", "force_store_value", "mandatory", Calculation(func.calc_value, Params(ParamValue('frozen'), kwargs={'condition': ParamOption(option_3, todict=True, notraisepropertyerror=True), 'expected': ParamValue(True)}))}))
option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2, option_3])
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])

View file

@ -1,11 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.9">
<variables>
<variable name="server_deployed" type="boolean"/>
<family name="general" description="général">
<variable name="mode_conteneur_actif" type="string" description="No change" auto_save="True">
<value>non</value>
</variable>
</family>
</variables>
</rougail>

View file

@ -0,0 +1,10 @@
server_deployed:
type: boolean
general:
description: général
mode_conteneur_actif:
type: string
description: No change
auto_save: true
default: non
version: '1.0'

View file

@ -1,18 +1,30 @@
from importlib.machinery import SourceFileLoader
from importlib.util import spec_from_loader, module_from_spec
loader = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py')
spec = spec_from_loader(loader.name, loader)
func = module_from_spec(spec)
loader.exec_module(func)
for key, value in dict(locals()).items():
if key != ['SourceFileLoader', 'func']:
setattr(func, key, value)
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
class func:
pass
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
setattr(func, function, getattr(func_, function))
_load_functions('tests/dictionaries_old/../eosfunc/test.py')
try:
from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except:
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("normal")
ALLOWED_LEADER_PROPERTIES.add("expert")
option_2 = BoolOption(name="server_deployed", doc="server_deployed", default=True, properties=frozenset({"mandatory", "normal"}))
option_4 = StrOption(name="mode_conteneur_actif", doc="No change", default="non", properties=frozenset({"basic", "force_store_value", "mandatory"}))
option_3 = OptionDescription(name="general", doc="général", children=[option_4], properties=frozenset({"basic"}))
option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2, option_3])
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])
optiondescription_3 = OptionDescription(name="general", doc="général", children=[option_4], properties=frozenset({"basic"}))
optiondescription_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2, optiondescription_3], properties=frozenset({"basic"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -0,0 +1,36 @@
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
class func:
pass
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
setattr(func, function, getattr(func_, function))
_load_functions('tests/dictionaries/../eosfunc/test.py')
try:
from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except:
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("normal")
ALLOWED_LEADER_PROPERTIES.add("expert")
option_1 = BoolOption(name="server_deployed", doc="server_deployed", default=True, properties=frozenset({"mandatory", "normal"}))
option_3 = StrOption(name="mode_conteneur_actif", doc="No change", default="non", properties=frozenset({"basic", "force_store_value", "mandatory"}))
optiondescription_2 = OptionDescription(name="general", doc="général", children=[option_3], properties=frozenset({"basic"}))
optiondescription_8 = OptionDescription(name="rougail", doc="Rougail", children=[option_1, optiondescription_2], properties=frozenset({"basic"}))
optiondescription_7 = OptionDescription(name="1", doc="1", children=[optiondescription_8])
option_4 = BoolOption(name="server_deployed", doc="server_deployed", default=True, properties=frozenset({"mandatory", "normal"}))
option_6 = StrOption(name="mode_conteneur_actif", doc="No change", default="non", properties=frozenset({"basic", "force_store_value", "mandatory"}))
optiondescription_5 = OptionDescription(name="general", doc="général", children=[option_6], properties=frozenset({"basic"}))
optiondescription_10 = OptionDescription(name="rougail", doc="Rougail", children=[option_4, optiondescription_5], properties=frozenset({"basic"}))
optiondescription_9 = OptionDescription(name="2", doc="2", children=[optiondescription_10])
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_7, optiondescription_9])

View file

@ -0,0 +1,11 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<variables>
<variable name="server_deployed" type="boolean"/>
<family name="general" description="général">
<variable name="mode_conteneur_actif" type="string" description="No change" auto_save="True">
<value>non</value>
</variable>
</family>
</variables>
</rougail>

View file

@ -0,0 +1,16 @@
version: '0.10'
variables:
- variable:
- name: server_deployed
type: boolean
- family:
- name: general
description: "g\xE9n\xE9ral"
variables:
- variable:
- name: mode_conteneur_actif
type: string
description: No change
auto_save: true
value:
- text: non

View file

@ -1,11 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.9">
<variables>
<variable name="server_deployed" type="boolean"/>
<family name="general" description="général">
<variable name="mode_conteneur_actif" type="string" description="No change" auto_save="True" mode="expert">
<value>non</value>
</variable>
</family>
</variables>
</rougail>

View file

@ -0,0 +1,11 @@
server_deployed:
type: boolean
general:
description: général
mode_conteneur_actif:
type: string
description: No change
auto_save: true
mode: expert
default: non
version: '1.0'

View file

@ -1,18 +1,30 @@
from importlib.machinery import SourceFileLoader
from importlib.util import spec_from_loader, module_from_spec
loader = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py')
spec = spec_from_loader(loader.name, loader)
func = module_from_spec(spec)
loader.exec_module(func)
for key, value in dict(locals()).items():
if key != ['SourceFileLoader', 'func']:
setattr(func, key, value)
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
class func:
pass
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
setattr(func, function, getattr(func_, function))
_load_functions('tests/dictionaries_old/../eosfunc/test.py')
try:
from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except:
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("normal")
ALLOWED_LEADER_PROPERTIES.add("expert")
option_2 = BoolOption(name="server_deployed", doc="server_deployed", default=True, properties=frozenset({"mandatory", "normal"}))
option_4 = StrOption(name="mode_conteneur_actif", doc="No change", default="non", properties=frozenset({"expert", "force_store_value", "mandatory"}))
option_3 = OptionDescription(name="general", doc="général", children=[option_4], properties=frozenset({"expert"}))
option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2, option_3])
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])
optiondescription_3 = OptionDescription(name="general", doc="général", children=[option_4], properties=frozenset({"expert"}))
optiondescription_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2, optiondescription_3], properties=frozenset({"normal"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -0,0 +1,36 @@
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
class func:
pass
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
setattr(func, function, getattr(func_, function))
_load_functions('tests/dictionaries/../eosfunc/test.py')
try:
from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except:
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("normal")
ALLOWED_LEADER_PROPERTIES.add("expert")
option_1 = BoolOption(name="server_deployed", doc="server_deployed", default=True, properties=frozenset({"mandatory", "normal"}))
option_3 = StrOption(name="mode_conteneur_actif", doc="No change", default="non", properties=frozenset({"expert", "force_store_value", "mandatory"}))
optiondescription_2 = OptionDescription(name="general", doc="général", children=[option_3], properties=frozenset({"expert"}))
optiondescription_8 = OptionDescription(name="rougail", doc="Rougail", children=[option_1, optiondescription_2], properties=frozenset({"normal"}))
optiondescription_7 = OptionDescription(name="1", doc="1", children=[optiondescription_8])
option_4 = BoolOption(name="server_deployed", doc="server_deployed", default=True, properties=frozenset({"mandatory", "normal"}))
option_6 = StrOption(name="mode_conteneur_actif", doc="No change", default="non", properties=frozenset({"expert", "force_store_value", "mandatory"}))
optiondescription_5 = OptionDescription(name="general", doc="général", children=[option_6], properties=frozenset({"expert"}))
optiondescription_10 = OptionDescription(name="rougail", doc="Rougail", children=[option_4, optiondescription_5], properties=frozenset({"normal"}))
optiondescription_9 = OptionDescription(name="2", doc="2", children=[optiondescription_10])
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_7, optiondescription_9])

View file

@ -0,0 +1,11 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<variables>
<variable name="server_deployed" type="boolean"/>
<family name="general" description="général">
<variable name="mode_conteneur_actif" type="string" description="No change" auto_save="True" mode="expert">
<value>non</value>
</variable>
</family>
</variables>
</rougail>

View file

@ -0,0 +1,17 @@
version: '0.10'
variables:
- variable:
- name: server_deployed
type: boolean
- family:
- name: general
description: "g\xE9n\xE9ral"
variables:
- variable:
- name: mode_conteneur_actif
type: string
description: No change
auto_save: true
mode: expert
value:
- text: non

View file

@ -1,11 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.9">
<variables>
<family name="general" description="général">
<!-- this is a comment -->
<variable name="mode_conteneur_actif" type="string" description="No change" hidden="True">
<value>non</value>
</variable>
</family>
</variables>
</rougail>

View file

@ -0,0 +1,8 @@
general:
description: général
mode_conteneur_actif:
type: string
description: No change
hidden: true
default: non
version: '1.0'

View file

@ -1,17 +1,29 @@
from importlib.machinery import SourceFileLoader
from importlib.util import spec_from_loader, module_from_spec
loader = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py')
spec = spec_from_loader(loader.name, loader)
func = module_from_spec(spec)
loader.exec_module(func)
for key, value in dict(locals()).items():
if key != ['SourceFileLoader', 'func']:
setattr(func, key, value)
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
class func:
pass
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
setattr(func, function, getattr(func_, function))
_load_functions('tests/dictionaries_old/../eosfunc/test.py')
try:
from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except:
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("normal")
ALLOWED_LEADER_PROPERTIES.add("expert")
option_3 = StrOption(name="mode_conteneur_actif", doc="No change", default="non", properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "mandatory", "normal"}))
option_2 = OptionDescription(name="general", doc="général", children=[option_3], properties=frozenset({"normal"}))
option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2])
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])
optiondescription_2 = OptionDescription(name="general", doc="général", children=[option_3], properties=frozenset({"normal"}))
optiondescription_1 = OptionDescription(name="rougail", doc="rougail", children=[optiondescription_2], properties=frozenset({"normal"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -0,0 +1,34 @@
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
class func:
pass
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
setattr(func, function, getattr(func_, function))
_load_functions('tests/dictionaries/../eosfunc/test.py')
try:
from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except:
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("normal")
ALLOWED_LEADER_PROPERTIES.add("expert")
option_2 = StrOption(name="mode_conteneur_actif", doc="No change", default="non", properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "mandatory", "normal"}))
optiondescription_1 = OptionDescription(name="general", doc="général", children=[option_2], properties=frozenset({"normal"}))
optiondescription_6 = OptionDescription(name="rougail", doc="Rougail", children=[optiondescription_1], properties=frozenset({"normal"}))
optiondescription_5 = OptionDescription(name="1", doc="1", children=[optiondescription_6])
option_4 = StrOption(name="mode_conteneur_actif", doc="No change", default="non", properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "mandatory", "normal"}))
optiondescription_3 = OptionDescription(name="general", doc="général", children=[option_4], properties=frozenset({"normal"}))
optiondescription_8 = OptionDescription(name="rougail", doc="Rougail", children=[optiondescription_3], properties=frozenset({"normal"}))
optiondescription_7 = OptionDescription(name="2", doc="2", children=[optiondescription_8])
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_5, optiondescription_7])

View file

@ -0,0 +1,11 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<variables>
<family name="general" description="général">
<!-- this is a comment -->
<variable name="mode_conteneur_actif" type="string" description="No change" hidden="True">
<value>non</value>
</variable>
</family>
</variables>
</rougail>

View file

@ -0,0 +1,13 @@
version: '0.10'
variables:
- family:
- name: general
description: "g\xE9n\xE9ral"
variables:
- variable:
- name: mode_conteneur_actif
type: string
description: No change
hidden: true
value:
- text: non

View file

@ -1,13 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.9">
<variables>
<family name="general" description="général">
<variable name="mode_conteneur_actif" type="string" description="No change" hidden="True">
<value>non</value>
</variable>
<variable name="without_type">
<value>non</value>
</variable>
</family>
</variables>
</rougail>

View file

@ -0,0 +1,10 @@
general:
description: général
mode_conteneur_actif:
type: string
description: No change
hidden: true
default: non
without_type:
default: non
version: '1.0'

View file

@ -1,18 +1,30 @@
from importlib.machinery import SourceFileLoader
from importlib.util import spec_from_loader, module_from_spec
loader = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py')
spec = spec_from_loader(loader.name, loader)
func = module_from_spec(spec)
loader.exec_module(func)
for key, value in dict(locals()).items():
if key != ['SourceFileLoader', 'func']:
setattr(func, key, value)
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
class func:
pass
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
setattr(func, function, getattr(func_, function))
_load_functions('tests/dictionaries_old/../eosfunc/test.py')
try:
from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except:
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("normal")
ALLOWED_LEADER_PROPERTIES.add("expert")
option_3 = StrOption(name="mode_conteneur_actif", doc="No change", default="non", properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "mandatory", "normal"}))
option_4 = StrOption(name="without_type", doc="without_type", default="non", properties=frozenset({"mandatory", "normal"}))
option_2 = OptionDescription(name="general", doc="général", children=[option_3, option_4], properties=frozenset({"normal"}))
option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2])
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])
optiondescription_2 = OptionDescription(name="general", doc="général", children=[option_3, option_4], properties=frozenset({"normal"}))
optiondescription_1 = OptionDescription(name="rougail", doc="rougail", children=[optiondescription_2], properties=frozenset({"normal"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -0,0 +1,36 @@
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
class func:
pass
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
setattr(func, function, getattr(func_, function))
_load_functions('tests/dictionaries/../eosfunc/test.py')
try:
from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except:
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("normal")
ALLOWED_LEADER_PROPERTIES.add("expert")
option_2 = StrOption(name="mode_conteneur_actif", doc="No change", default="non", properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "mandatory", "normal"}))
option_3 = StrOption(name="without_type", doc="without_type", default="non", properties=frozenset({"mandatory", "normal"}))
optiondescription_1 = OptionDescription(name="general", doc="général", children=[option_2, option_3], properties=frozenset({"normal"}))
optiondescription_8 = OptionDescription(name="rougail", doc="Rougail", children=[optiondescription_1], properties=frozenset({"normal"}))
optiondescription_7 = OptionDescription(name="1", doc="1", children=[optiondescription_8])
option_5 = StrOption(name="mode_conteneur_actif", doc="No change", default="non", properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "mandatory", "normal"}))
option_6 = StrOption(name="without_type", doc="without_type", default="non", properties=frozenset({"mandatory", "normal"}))
optiondescription_4 = OptionDescription(name="general", doc="général", children=[option_5, option_6], properties=frozenset({"normal"}))
optiondescription_10 = OptionDescription(name="rougail", doc="Rougail", children=[optiondescription_4], properties=frozenset({"normal"}))
optiondescription_9 = OptionDescription(name="2", doc="2", children=[optiondescription_10])
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_7, optiondescription_9])

View file

@ -0,0 +1,13 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<variables>
<family name="general" description="général">
<variable name="mode_conteneur_actif" type="string" description="No change" hidden="True">
<value>non</value>
</variable>
<variable name="without_type">
<value>non</value>
</variable>
</family>
</variables>
</rougail>

View file

@ -0,0 +1,16 @@
version: '0.10'
variables:
- family:
- name: general
description: "g\xE9n\xE9ral"
variables:
- variable:
- name: mode_conteneur_actif
type: string
description: No change
hidden: true
value:
- text: non
- name: without_type
value:
- text: non

View file

@ -1,10 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.9">
<variables>
<family name="general" description="général">
<variable name="mode_conteneur_actif" type="string" description="No change" hidden="True">
<value>non</value>
</variable>
</family>
</variables>
</rougail>

View file

@ -0,0 +1,8 @@
general:
description: général
mode_conteneur_actif:
type: string
description: No change
hidden: true
default: non
version: '1.0'

View file

@ -1,17 +1,29 @@
from importlib.machinery import SourceFileLoader
from importlib.util import spec_from_loader, module_from_spec
loader = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py')
spec = spec_from_loader(loader.name, loader)
func = module_from_spec(spec)
loader.exec_module(func)
for key, value in dict(locals()).items():
if key != ['SourceFileLoader', 'func']:
setattr(func, key, value)
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
class func:
pass
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
setattr(func, function, getattr(func_, function))
_load_functions('tests/dictionaries_old/../eosfunc/test.py')
try:
from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except:
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("normal")
ALLOWED_LEADER_PROPERTIES.add("expert")
option_3 = StrOption(name="mode_conteneur_actif", doc="No change", default="non", properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "mandatory", "normal"}))
option_2 = OptionDescription(name="general", doc="général", children=[option_3], properties=frozenset({"normal"}))
option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2])
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])
optiondescription_2 = OptionDescription(name="general", doc="général", children=[option_3], properties=frozenset({"normal"}))
optiondescription_1 = OptionDescription(name="rougail", doc="rougail", children=[optiondescription_2], properties=frozenset({"normal"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -0,0 +1,34 @@
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
class func:
pass
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
setattr(func, function, getattr(func_, function))
_load_functions('tests/dictionaries/../eosfunc/test.py')
try:
from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except:
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("normal")
ALLOWED_LEADER_PROPERTIES.add("expert")
option_2 = StrOption(name="mode_conteneur_actif", doc="No change", default="non", properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "mandatory", "normal"}))
optiondescription_1 = OptionDescription(name="general", doc="général", children=[option_2], properties=frozenset({"normal"}))
optiondescription_6 = OptionDescription(name="rougail", doc="Rougail", children=[optiondescription_1], properties=frozenset({"normal"}))
optiondescription_5 = OptionDescription(name="1", doc="1", children=[optiondescription_6])
option_4 = StrOption(name="mode_conteneur_actif", doc="No change", default="non", properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "mandatory", "normal"}))
optiondescription_3 = OptionDescription(name="general", doc="général", children=[option_4], properties=frozenset({"normal"}))
optiondescription_8 = OptionDescription(name="rougail", doc="Rougail", children=[optiondescription_3], properties=frozenset({"normal"}))
optiondescription_7 = OptionDescription(name="2", doc="2", children=[optiondescription_8])
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_5, optiondescription_7])

View file

@ -0,0 +1,10 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<variables>
<family name="general" description="général">
<variable name="mode_conteneur_actif" type="string" description="No change" hidden="True">
<value>non</value>
</variable>
</family>
</variables>
</rougail>

View file

@ -0,0 +1,13 @@
version: '0.10'
variables:
- family:
- name: general
description: "g\xE9n\xE9ral"
variables:
- variable:
- name: mode_conteneur_actif
type: string
description: No change
hidden: true
value:
- text: non

View file

@ -1,10 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.9">
<variables>
<family name="general" description="général">
<variable name="mode_conteneur_actif" type="string" description="No change" hidden="True">
<value>non</value>
</variable>
</family>
</variables>
</rougail>

View file

@ -1,10 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.9">
<variables>
<family name="general" description="général">
<variable name="mode_conteneur_actif1" type="string" description="No change" hidden="True">
<value>non</value>
</variable>
</family>
</variables>
</rougail>

View file

@ -1,18 +0,0 @@
from importlib.machinery import SourceFileLoader
from importlib.util import spec_from_loader, module_from_spec
loader = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py')
spec = spec_from_loader(loader.name, loader)
func = module_from_spec(spec)
loader.exec_module(func)
for key, value in dict(locals()).items():
if key != ['SourceFileLoader', 'func']:
setattr(func, key, value)
try:
from tiramisu4 import *
except:
from tiramisu import *
option_3 = StrOption(name="mode_conteneur_actif", doc="No change", default="non", properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "mandatory", "normal"}))
option_4 = StrOption(name="mode_conteneur_actif1", doc="No change", default="non", properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "mandatory", "normal"}))
option_2 = OptionDescription(name="general", doc="général", children=[option_3, option_4], properties=frozenset({"normal"}))
option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2])
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])

View file

@ -1,17 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.9">
<variables>
<variable name="server_deployed" type="boolean">
<value>no</value>
</variable>
<variable name="my_variable" auto_freeze="True" hidden="True">
<value>no</value>
</variable>
</variables>
<constraints>
<fill name="calc_val">
<param>yes</param>
<target>my_variable</target>
</fill>
</constraints>
</rougail>

View file

@ -1,10 +0,0 @@
{
"rougail.server_deployed": {
"owner": "default",
"value": false
},
"rougail.my_variable": {
"owner": "forced",
"value": "yes"
}
}

View file

@ -1,4 +0,0 @@
{
"rougail.server_deployed": false,
"rougail.my_variable": "yes"
}

View file

@ -1,10 +0,0 @@
{
"rougail.server_deployed": {
"owner": "default",
"value": false
},
"rougail.my_variable": {
"owner": "default",
"value": "yes"
}
}

View file

@ -1,17 +0,0 @@
from importlib.machinery import SourceFileLoader
from importlib.util import spec_from_loader, module_from_spec
loader = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py')
spec = spec_from_loader(loader.name, loader)
func = module_from_spec(spec)
loader.exec_module(func)
for key, value in dict(locals()).items():
if key != ['SourceFileLoader', 'func']:
setattr(func, key, value)
try:
from tiramisu4 import *
except:
from tiramisu import *
option_2 = BoolOption(name="server_deployed", doc="server_deployed", default=False, properties=frozenset({"mandatory", "normal"}))
option_3 = StrOption(name="my_variable", doc="my_variable", default=Calculation(func.calc_val, Params((ParamValue("yes")))), properties=frozenset({"basic", "force_store_value", "hidden", Calculation(func.calc_value, Params(ParamValue('frozen'), kwargs={'condition': ParamOption(option_2, todict=True, notraisepropertyerror=True), 'expected': ParamValue(True)}))}))
option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2, option_3])
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])

View file

@ -1,19 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.9">
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="string" description="No change" hidden="True">
<value>non</value>
</variable>
<variable name="mode_conteneur_actif1" type="string" description="No change">
<value>non</value>
</variable>
</family>
</variables>
<constraints>
<fill name="calc_val">
<param type="variable">mode_conteneur_actif1</param>
<target>mode_conteneur_actif</target>
</fill>
</constraints>
</rougail>

View file

@ -0,0 +1,13 @@
general:
mode_conteneur_actif:
type: string
description: No change
hidden: true
default:
jinja: '{{ rougail.general.mode_conteneur_actif1 | calc_val }}'
type: jinja
mode_conteneur_actif1:
type: string
description: No change
default: non
version: '1.0'

View file

@ -1,18 +1,60 @@
from importlib.machinery import SourceFileLoader
from importlib.util import spec_from_loader, module_from_spec
loader = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py')
spec = spec_from_loader(loader.name, loader)
func = module_from_spec(spec)
loader.exec_module(func)
for key, value in dict(locals()).items():
if key != ['SourceFileLoader', 'func']:
setattr(func, key, value)
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
class func:
pass
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
setattr(func, function, getattr(func_, function))
_load_functions('tests/dictionaries_old/../eosfunc/test.py')
try:
from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except:
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("normal")
ALLOWED_LEADER_PROPERTIES.add("expert")
from jinja2 import StrictUndefined, DictLoader
from jinja2.sandbox import SandboxedEnvironment
from rougail.annotator.variable import CONVERT_OPTION
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
kw = {}
for key, value in kwargs.items():
if '.' in key:
c_kw = kw
path, var = key.rsplit('.', 1)
for subkey in path.split('.'):
c_kw = c_kw.setdefault(subkey, {})
c_kw[var] = value
else:
kw[key] = value
values = ENV.get_template(__internal_jinja).render(kw)
convert = CONVERT_OPTION[__internal_type].get('func', str)
if __internal_multi:
return [convert(val) for val in values.split(',')]
return convert(values)
def valid_with_jinja(value, **kwargs):
kwargs[kwargs.pop('__internal_key')] = value
value = jinja_to_function(__internal_type='string', __internal_multi=False, **kwargs)
if value:
raise ValueError(value)
func.jinja_to_function = jinja_to_function
func.valid_with_jinja = valid_with_jinja
dict_env = {}
dict_env['rougail.general.mode_conteneur_actif'] = "{{ rougail.general.mode_conteneur_actif1 | calc_val }}"
ENV = SandboxedEnvironment(loader=DictLoader(dict_env), undefined=StrictUndefined)
ENV.compile_templates('jinja_caches', zip=None)
option_4 = StrOption(name="mode_conteneur_actif1", doc="No change", default="non", properties=frozenset({"mandatory", "normal"}))
option_3 = StrOption(name="mode_conteneur_actif", doc="No change", default=Calculation(func.calc_val, Params((ParamOption(option_4)))), properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "normal"}))
option_2 = OptionDescription(name="general", doc="general", children=[option_3, option_4], properties=frozenset({"normal"}))
option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2])
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])
option_3 = StrOption(name="mode_conteneur_actif", doc="No change", default=Calculation(func.jinja_to_function, Params((), kwargs={'__internal_jinja': ParamValue(rougail.general.mode_conteneur_actif), '__internal_type': ParamValue(string), '__internal_multi': ParamValue(False), 'rougail.general.mode_conteneur_actif1': ParamOption(option_4)})), properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "normal"}))
optiondescription_2 = OptionDescription(name="general", doc="general", children=[option_3, option_4], properties=frozenset({"normal"}))
optiondescription_1 = OptionDescription(name="rougail", doc="rougail", children=[optiondescription_2], properties=frozenset({"normal"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -0,0 +1,36 @@
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
class func:
pass
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
setattr(func, function, getattr(func_, function))
_load_functions('tests/dictionaries/../eosfunc/test.py')
try:
from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except:
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("normal")
ALLOWED_LEADER_PROPERTIES.add("expert")
option_3 = StrOption(name="mode_conteneur_actif1", doc="No change", default="non", properties=frozenset({"mandatory", "normal"}))
option_2 = StrOption(name="mode_conteneur_actif", doc="No change", default=Calculation(func.calc_val, Params((ParamOption(option_3)))), properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "normal"}))
optiondescription_1 = OptionDescription(name="general", doc="general", children=[option_2, option_3], properties=frozenset({"normal"}))
optiondescription_8 = OptionDescription(name="rougail", doc="Rougail", children=[optiondescription_1], properties=frozenset({"normal"}))
optiondescription_7 = OptionDescription(name="1", doc="1", children=[optiondescription_8])
option_6 = StrOption(name="mode_conteneur_actif1", doc="No change", default="non", properties=frozenset({"mandatory", "normal"}))
option_5 = StrOption(name="mode_conteneur_actif", doc="No change", default=Calculation(func.calc_val, Params((ParamOption(option_6)))), properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "normal"}))
optiondescription_4 = OptionDescription(name="general", doc="general", children=[option_5, option_6], properties=frozenset({"normal"}))
optiondescription_10 = OptionDescription(name="rougail", doc="Rougail", children=[optiondescription_4], properties=frozenset({"normal"}))
optiondescription_9 = OptionDescription(name="2", doc="2", children=[optiondescription_10])
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_7, optiondescription_9])

View file

@ -0,0 +1,19 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="string" description="No change" hidden="True">
<value>non</value>
</variable>
<variable name="mode_conteneur_actif1" type="string" description="No change">
<value>non</value>
</variable>
</family>
</variables>
<constraints>
<fill name="calc_val">
<param type="variable">mode_conteneur_actif1</param>
<target>mode_conteneur_actif</target>
</fill>
</constraints>
</rougail>

View file

@ -0,0 +1,25 @@
version: '0.10'
variables:
- family:
- name: general
variables:
- variable:
- name: mode_conteneur_actif
type: string
description: No change
hidden: true
value:
- text: non
- name: mode_conteneur_actif1
type: string
description: No change
value:
- text: non
constraints:
- fill:
- name: calc_val
param:
- type: variable
text: mode_conteneur_actif1
target:
- text: mode_conteneur_actif

View file

@ -0,0 +1,13 @@
general:
mode_conteneur_actif:
type: string
description: No change
hidden: true
default:
jinja: '{{ rougail.general.mode_conteneur_actif1 }}'
type: jinja
mode_conteneur_actif1:
type: string
description: No change
default: non
version: '1.0'

View file

@ -0,0 +1,60 @@
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
class func:
pass
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
setattr(func, function, getattr(func_, function))
_load_functions('tests/dictionaries_old/../eosfunc/test.py')
try:
from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except:
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("normal")
ALLOWED_LEADER_PROPERTIES.add("expert")
from jinja2 import StrictUndefined, DictLoader
from jinja2.sandbox import SandboxedEnvironment
from rougail.annotator.variable import CONVERT_OPTION
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
kw = {}
for key, value in kwargs.items():
if '.' in key:
c_kw = kw
path, var = key.rsplit('.', 1)
for subkey in path.split('.'):
c_kw = c_kw.setdefault(subkey, {})
c_kw[var] = value
else:
kw[key] = value
values = ENV.get_template(__internal_jinja).render(kw)
convert = CONVERT_OPTION[__internal_type].get('func', str)
if __internal_multi:
return [convert(val) for val in values.split(',')]
return convert(values)
def valid_with_jinja(value, **kwargs):
kwargs[kwargs.pop('__internal_key')] = value
value = jinja_to_function(__internal_type='string', __internal_multi=False, **kwargs)
if value:
raise ValueError(value)
func.jinja_to_function = jinja_to_function
func.valid_with_jinja = valid_with_jinja
dict_env = {}
dict_env['rougail.general.mode_conteneur_actif'] = "{{ rougail.general.mode_conteneur_actif1 }}"
ENV = SandboxedEnvironment(loader=DictLoader(dict_env), undefined=StrictUndefined)
ENV.compile_templates('jinja_caches', zip=None)
option_4 = StrOption(name="mode_conteneur_actif1", doc="No change", default="non", properties=frozenset({"mandatory", "normal"}))
option_3 = StrOption(name="mode_conteneur_actif", doc="No change", default=Calculation(func.jinja_to_function, Params((), kwargs={'__internal_jinja': ParamValue(rougail.general.mode_conteneur_actif), '__internal_type': ParamValue(string), '__internal_multi': ParamValue(False), 'rougail.general.mode_conteneur_actif1': ParamOption(option_4)})), properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "normal"}))
optiondescription_2 = OptionDescription(name="general", doc="general", children=[option_3, option_4], properties=frozenset({"normal"}))
optiondescription_1 = OptionDescription(name="rougail", doc="rougail", children=[optiondescription_2], properties=frozenset({"normal"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -0,0 +1,67 @@
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
class func:
pass
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
setattr(func, function, getattr(func_, function))
_load_functions('tests/dictionaries/../eosfunc/test.py')
try:
from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except:
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("normal")
ALLOWED_LEADER_PROPERTIES.add("expert")
from jinja2 import StrictUndefined, DictLoader
from jinja2.sandbox import SandboxedEnvironment
from rougail.annotator.variable import CONVERT_OPTION
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
kw = {}
for key, value in kwargs.items():
if '.' in key:
c_kw = kw
path, var = key.rsplit('.', 1)
for subkey in path.split('.'):
c_kw = c_kw.setdefault(subkey, {})
c_kw[var] = value
else:
kw[key] = value
values = ENV.get_template(__internal_jinja).render(kw)
convert = CONVERT_OPTION[__internal_type].get('func', str)
if __internal_multi:
return [convert(val) for val in values.split(',')]
return convert(values)
def valid_with_jinja(value, **kwargs):
kwargs[kwargs.pop('__internal_key')] = value
value = jinja_to_function(__internal_type='string', __internal_multi=False, **kwargs)
if value:
raise ValueError(value)
func.jinja_to_function = jinja_to_function
func.valid_with_jinja = valid_with_jinja
dict_env = {}
dict_env['1.rougail.general.mode_conteneur_actif'] = "{{ mode_conteneur_actif1 }}"
dict_env['2.rougail.general.mode_conteneur_actif'] = "{{ mode_conteneur_actif1 }}"
ENV = SandboxedEnvironment(loader=DictLoader(dict_env), undefined=StrictUndefined)
ENV.compile_templates('jinja_caches', zip=None)
option_3 = StrOption(name="mode_conteneur_actif1", doc="No change", default="non", properties=frozenset({"mandatory", "normal"}))
option_2 = StrOption(name="mode_conteneur_actif", doc="No change", default=Calculation(func.jinja_to_function, Params((), kwargs={'__internal_jinja': ParamValue("1.rougail.general.mode_conteneur_actif"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), 'mode_conteneur_actif1': ParamOption(option_3)})), properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "normal"}))
optiondescription_1 = OptionDescription(name="general", doc="general", children=[option_2, option_3], properties=frozenset({"normal"}))
optiondescription_8 = OptionDescription(name="rougail", doc="Rougail", children=[optiondescription_1], properties=frozenset({"normal"}))
optiondescription_7 = OptionDescription(name="1", doc="1", children=[optiondescription_8])
option_6 = StrOption(name="mode_conteneur_actif1", doc="No change", default="non", properties=frozenset({"mandatory", "normal"}))
option_5 = StrOption(name="mode_conteneur_actif", doc="No change", default=Calculation(func.jinja_to_function, Params((), kwargs={'__internal_jinja': ParamValue("2.rougail.general.mode_conteneur_actif"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), 'mode_conteneur_actif1': ParamOption(option_6)})), properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "normal"}))
optiondescription_4 = OptionDescription(name="general", doc="general", children=[option_5, option_6], properties=frozenset({"normal"}))
optiondescription_10 = OptionDescription(name="rougail", doc="Rougail", children=[optiondescription_4], properties=frozenset({"normal"}))
optiondescription_9 = OptionDescription(name="2", doc="2", children=[optiondescription_10])
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_7, optiondescription_9])

View file

@ -0,0 +1,18 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="string" description="No change" hidden="True">
<value>non</value>
</variable>
<variable name="mode_conteneur_actif1" type="string" description="No change">
<value>non</value>
</variable>
</family>
</variables>
<constraints>
<fill name="{{ rougail.general.mode_conteneur_actif1 }}" type="jinja">
<target>mode_conteneur_actif</target>
</fill>
</constraints>
</rougail>

View file

@ -0,0 +1,23 @@
version: '0.10'
variables:
- family:
- name: general
variables:
- variable:
- name: mode_conteneur_actif
type: string
description: No change
hidden: true
value:
- text: non
- name: mode_conteneur_actif1
type: string
description: No change
value:
- text: non
constraints:
- fill:
- name: '{{ mode_conteneur_actif1 }}'
type: jinja
target:
- text: mode_conteneur_actif

View file

@ -0,0 +1,10 @@
{
"rougail.general.mode_conteneur_actif": {
"owner": "default",
"value": "non"
},
"rougail.general.mode_conteneur_actif1": {
"owner": "default",
"value": "non"
}
}

View file

@ -0,0 +1,4 @@
{
"rougail.general.mode_conteneur_actif": "non",
"rougail.general.mode_conteneur_actif1": "non"
}

Some files were not shown because too many files have changed in this diff Show more