This commit is contained in:
egarette@silique.fr 2023-10-12 08:17:30 +02:00
parent 940b20f5d9
commit cb6aa7fdb7
2940 changed files with 51018 additions and 14430 deletions

View file

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

View file

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

View file

@ -52,24 +52,22 @@ class Annotator(TargetAnnotator, ParamAnnotator, Walk):
*args, *args,
): ):
self.objectspace = objectspace self.objectspace = objectspace
self.target_is_uniq = False # self.target_is_uniq = False
self.only_variable = False # self.only_variable = False
self.allow_function = False # self.allow_function = False
self.force_service_value = {} # self.force_service_value = {}
if hasattr(objectspace.space, 'variables'): #for path_prefix, constraints in self.get_constraints():
self.convert_auto_freeze() # if not hasattr(constraints, 'condition'):
for path_prefix, constraints in self.get_constraints(): # continue
if not hasattr(constraints, 'condition'): # self.convert_target(constraints.condition, path_prefix)
continue # self.check_condition_optional(constraints, path_prefix)
self.convert_target(constraints.condition, path_prefix) # self.convert_condition_source(constraints, path_prefix)
self.check_condition_optional(constraints, path_prefix) # self.convert_param(constraints.condition, path_prefix)
self.convert_condition_source(constraints, path_prefix) # self.check_source_target(constraints)
self.convert_param(constraints.condition, path_prefix) # self.convert_xxxlist(constraints, path_prefix)
self.check_source_target(constraints) # self.check_choice_option_condition(constraints, path_prefix)
self.convert_xxxlist(constraints, path_prefix) # self.remove_condition_with_empty_target(constraints)
self.check_choice_option_condition(constraints, path_prefix) # self.convert_condition(constraints, path_prefix)
self.remove_condition_with_empty_target(constraints)
self.convert_condition(constraints, path_prefix)
def valid_type_validation(self, def valid_type_validation(self,
obj, obj,
@ -78,47 +76,6 @@ class Annotator(TargetAnnotator, ParamAnnotator, Walk):
return None return None
return obj.source.type 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): def check_source_target(self, constraints):
"""verify that source != target in condition """verify that source != target in condition
""" """
@ -404,7 +361,7 @@ class Annotator(TargetAnnotator, ParamAnnotator, Walk):
main_action, main_action,
) )
if isinstance(leader_or_variable, self.objectspace.variable) and \ 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: 'force_default_on_freeze' in actions:
continue continue
for action in actions[1:]: for action in actions[1:]:

View file

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

View file

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

View file

@ -41,7 +41,7 @@ class Annotator(Walk):
objectspace, objectspace,
*args, *args,
): ):
if not hasattr(objectspace.space, 'variables'): if not objectspace.paths:
return return
self.objectspace = objectspace self.objectspace = objectspace
self.convert_groups() self.convert_groups()
@ -51,9 +51,7 @@ class Annotator(Walk):
""" """
# store old leaders family name # store old leaders family name
for family in self.get_families(): for family in self.get_families():
if not isinstance(family, self.objectspace.family): if family.type != 'leadership':
continue
if not family.leadership:
continue continue
if hasattr(family, 'dynamic'): if hasattr(family, 'dynamic'):
msg = _(f'the family "{family.name}" cannot be leadership and dynamic together') msg = _(f'the family "{family.name}" cannot be leadership and dynamic together')

View file

@ -45,88 +45,87 @@ class Annotator(Walk):
*args *args
) -> None: ) -> None:
self.objectspace = objectspace self.objectspace = objectspace
services = [] # services = []
if not self.objectspace.paths.has_path_prefix() and hasattr(self.objectspace.space, 'services'): # if not self.objectspace.paths.has_path_prefix() and hasattr(self.objectspace.space, 'services'):
services.append(self.objectspace.space.services) # services.append(self.objectspace.space.services)
elif hasattr(self.objectspace.space, 'variables'): # elif hasattr(self.objectspace.space, 'variables'):
for path_prefix in self.objectspace.paths.get_path_prefixes(): # for path_prefix in self.objectspace.paths.get_path_prefixes():
if path_prefix in self.objectspace.space.variables and \ # if path_prefix in self.objectspace.space.variables and \
hasattr(self.objectspace.space.variables[path_prefix], 'services'): # hasattr(self.objectspace.space.variables[path_prefix], 'services'):
services.append(self.objectspace.space.variables[path_prefix].services) # services.append(self.objectspace.space.variables[path_prefix].services)
for service in services: if self.objectspace.paths:
self.convert_services(service) for family in self.get_families():
if hasattr(self.objectspace.space, 'variables'): #if family.path != 'services' and not family.path.startswith('services.'):
if family.path != 'services':
continue
self.convert_services(family)
self.convert_family() self.convert_family()
self.convert_variable() 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: def convert_services(self, services) -> None:
"""convert services """convert services
""" """
self.convert_property(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)
def convert_family(self) -> None: def convert_family(self) -> None:
"""convert families """convert families
""" """
for family in self.get_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: def convert_variable(self) -> None:
"""convert variables """convert variables
""" """
for variable in self.get_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

@ -48,13 +48,6 @@ FORCE_INFORMATIONS = ['mode']
class Annotator: class Annotator:
"""Manage service's object """Manage service's object
for example::
<services>
<service name="test">
<service_access service='ntp'>
</service_access>
</service>
</services>
""" """
level = 20 level = 20
def __init__(self, def __init__(self,
@ -63,108 +56,147 @@ class Annotator:
) -> None: ) -> None:
self.objectspace = objectspace self.objectspace = objectspace
self.uniq_overrides = {} self.uniq_overrides = {}
if 'network_type' not in self.objectspace.types: #if 'network_type' not in self.objectspace.types:
self.objectspace.types['network_type'] = self.objectspace.types['ip_type'] # self.objectspace.types['network_type'] = self.objectspace.types['ip_type']
services = [] services = []
if not self.objectspace.paths.has_path_prefix(): if 1:
#FIXME if not self.objectspace.paths.has_path_prefix():
self.uniq_overrides[None] = [] self.uniq_overrides[None] = []
if hasattr(self.objectspace.space, 'services'): # if hasattr(self.objectspace.space, 'services'):
if not hasattr(self.objectspace.space.services, 'service'): if self.objectspace.services:
del self.objectspace.space.services services.append((None, 'services', self.objectspace.services))
else: #elif hasattr(self.objectspace.space, 'variables'):
services.append((None, 'services', self.objectspace.space.services)) # for path_prefix in self.objectspace.paths.get_path_prefixes():
elif hasattr(self.objectspace.space, 'variables'): # self.uniq_overrides[path_prefix] = []
for path_prefix in self.objectspace.paths.get_path_prefixes(): # root_path = f'{path_prefix}.services'
self.uniq_overrides[path_prefix] = [] # if not path_prefix in self.objectspace.space.variables or \
root_path = f'{path_prefix}.services' # not hasattr(self.objectspace.space.variables[path_prefix], 'services'):
if not path_prefix in self.objectspace.space.variables or \ # continue
not hasattr(self.objectspace.space.variables[path_prefix], 'services'): # if not hasattr(self.objectspace.space.variables[path_prefix].services, 'service'):
continue # del self.objectspace.space.variables[path_prefix].services
if not hasattr(self.objectspace.space.variables[path_prefix].services, 'service'): # else:
del self.objectspace.space.variables[path_prefix].services # services.append((path_prefix, root_path, self.objectspace.space.variables[path_prefix].services))
else: if services:
services.append((path_prefix, root_path, self.objectspace.space.variables[path_prefix].services)) self.objectspace.add_family('.',
for path_prefix, root_path, service in services: 'services',
self.convert_services(path_prefix, root_path, service) '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): def convert_services(self, path_prefix, root_path, services):
"""convert services to variables """convert services to variables
""" """
services.hidden = True for service_name, service in services.items():
services.name = 'services' n_service_name = normalize_family(service_name)
services.doc = 'services' path = f'{root_path}.{n_service_name}'
services.path = root_path self.objectspace.add_family(root_path,
for service_name, service in services.service.items(): path,
service.name = normalize_family(service_name) n_service_name,
activate_obj = self._generate_element('boolean', {},
None, service.xmlfiles,
None, )
'activate', if path in self.objectspace.ip:
not service.disabled, obj_path = f'{path}.ip'
service, if obj_path not in self.objectspace.paths:
f'{root_path}.{service.name}', self.objectspace.add_family(path,
path_prefix, obj_path,
) 'ip',
service.disabled = None {},
dico = dict(vars(service)) service.xmlfiles,
if 'type' not in dico: )
if service.manage: for ip in self.objectspace.ip[path]:
dico['type'] = service.type self.convert_service_ip(ip,
else: obj_path,
dico['type'] = 'none' n_service_name,
for elttype, values in dico.items():
if elttype == 'servicelist':
self.objectspace.paths.list_conditions[path_prefix].setdefault('servicelist',
{}).setdefault(
values,
[]).append(activate_obj)
continue
if elttype in ERASED_ATTRIBUTES:
continue
if not service.manage and elttype not in ALLOW_ATTRIBUT_NOT_MANAGE and (elttype != 'type' or values != '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, path_prefix,
) )
service.variable = [activate_obj, manage] self._generate_element('boolean',
service.doc = service_name 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 is not None):
msg = _(f'unmanage service cannot have "{elttype}"')
raise DictConsistencyError(msg, 66, service.xmlfiles)
if values:
self.objectspace.informations.add(path, elttype, values)
self.objectspace.add_variable(path,
f'{path}.manage',
'manage',
{'type': 'boolean',
'default': True,
},
service.xmlfiles,
)
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,
)
if ip.netmask:
self.objectspace.add_variable(path,
f'{path}.netmask',
'netmask',
{'type': 'symlink',
'default': variable,
},
ip.xmlfiles,
)
self._generate_element('boolean',
None,
None,
'activate',
True,
#not service.disabled,
ip,
path,
path_prefix,
)
def make_group_from_elts(self, def make_group_from_elts(self,
service_name, service_name,
@ -303,13 +335,13 @@ class Annotator:
key, key,
value, value,
elt, elt,
path, subpath,
path_prefix, path_prefix,
): # pylint: disable=R0913 ): # pylint: disable=R0913
variable = self.objectspace.variable(elt.xmlfiles) name = normalize_family(key)
variable.name = normalize_family(key) variable_obj = {'type': type_,
variable.mode = None 'xmlfiles': elt.xmlfiles
variable.type = type_ }
if type_ == 'symlink': if type_ == 'symlink':
variable.opt = self.objectspace.paths.get_variable(value, variable.opt = self.objectspace.paths.get_variable(value,
self.objectspace.rougailconfig['variable_namespace'], self.objectspace.rougailconfig['variable_namespace'],
@ -325,15 +357,21 @@ class Annotator:
raise DictConsistencyError(msg, 58, elt.xmlfiles) raise DictConsistencyError(msg, 58, elt.xmlfiles)
else: else:
variable.doc = key variable_obj['description'] = key
variable.default = value variable_obj['default'] = value
variable.namespace = 'services' path = f'{subpath}.{name}'
self.objectspace.paths.add_variable('services', self.objectspace.add_variable(subpath,
path, path,
variable, name,
force_path_prefix=path_prefix variable_obj,
) elt.xmlfiles,
return variable )
# self.objectspace.paths.add_variable('services',
# path,
# variable,
# force_path_prefix=path_prefix
# )
return self.objectspace.paths[path]
def _update_override(self, def _update_override(self,
override, override,
@ -363,37 +401,6 @@ class Annotator:
f'"({service_name})"') f'"({service_name})"')
raise DictConsistencyError(msg, 34, file_.xmlfiles) 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, def _update_certificate(self,
certificate, certificate,
certificate_name, certificate_name,

View file

@ -31,6 +31,7 @@ from rougail.annotator.variable import Walk
from rougail.i18n import _ from rougail.i18n import _
from rougail.error import DictConsistencyError from rougail.error import DictConsistencyError
from rougail.annotator.fill import get_jinja_variable_to_param
class Annotator(Walk): # pylint: disable=R0903 class Annotator(Walk): # pylint: disable=R0903
"""Annotate value """Annotate value
@ -38,10 +39,12 @@ class Annotator(Walk): # pylint: disable=R0903
level = 70 level = 70
def __init__(self, def __init__(self,
objectspace, objectspace,
functions,
*args, *args,
) -> None: ) -> None:
if not hasattr(objectspace.space, 'variables'): if not objectspace.paths:
return return
self.functions = functions
self.objectspace = objectspace self.objectspace = objectspace
self.convert_value() self.convert_value()
self.add_choice_nil() self.add_choice_nil()
@ -50,36 +53,50 @@ class Annotator(Walk): # pylint: disable=R0903
"""convert value """convert value
""" """
for variable in self.get_variables(): for variable in self.get_variables():
if variable.type == 'symlink':
continue
self._convert_value(variable) self._convert_value(variable)
def _convert_value(self, def _convert_value(self,
variable, variable: dict,
) -> None: ) -> None:
# a boolean must have value, the default value is "True" # a boolean must have value, the default value is "True"
if not hasattr(variable, 'value') and variable.type == 'boolean': if variable.type == 'boolean' and \
new_value = self.objectspace.value(variable.xmlfiles) variable.multi is False and \
new_value.name = True variable.default is None:
new_value.type = 'boolean' variable.default = True
variable.value = [new_value]
# if the variable is mandatory and doesn't have any value if variable.default is None:
# 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'):
return return
if variable.value[0].type == 'calculation':
variable.default = variable.value[0] has_value = False
elif variable.multi: if isinstance(variable.default, dict):
if variable.default['type'] == 'jinja':
path_prefix = None
default = {'type': 'jinja',
'name': variable.default['name'],
'params': {'__internal_jinja': variable.path,
'__internal_type': variable.type,
'__internal_multi': variable.multi,
},
}
for sub_variable in get_jinja_variable_to_param(variable.default['name'],
self.objectspace,
variable.xmlfiles,
path_prefix,
self.functions,
None,
None,
):
default['params'][sub_variable.path] = sub_variable
variable.default = default
else:
raise Exception('pfff')
elif isinstance(variable.default, list):
if not variable.multi:
raise Exception('pfff')
if self.objectspace.paths.is_follower(variable): if self.objectspace.paths.is_follower(variable):
if variable.multi != 'submulti' and len(variable.value) != 1: if variable.multi != 'submulti' and len(variable.default) != 1:
msg = _(f'the follower "{variable.name}" without multi attribute can only have one value') msg = _(f'the follower "{variable.name}" without multi attribute can only have one value')
raise DictConsistencyError(msg, 87, variable.xmlfiles) raise DictConsistencyError(msg, 87, variable.xmlfiles)
else: else:
@ -89,13 +106,18 @@ class Annotator(Walk): # pylint: disable=R0903
variable.default_multi = [value.name for value in variable.value] variable.default_multi = [value.name for value in variable.value]
else: else:
variable.default_multi = variable.value[0].name variable.default_multi = variable.value[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: else:
if len(variable.value) > 1: has_value = True
msg = _(f'the none multi variable "{variable.name}" cannot have ' # variable with default value is mandatory
'more than one value') if has_value and variable.mandatory is None:
raise DictConsistencyError(msg, 68, variable.xmlfiles) # if has value without any calculation
variable.default = variable.value[0].name variable.mandatory = True
del variable.value
def add_choice_nil(self) -> None: def add_choice_nil(self) -> None:
"""A variable with type "Choice" that is not mandatory must has "nil" value """A variable with type "Choice" that is not mandatory must has "nil" value
@ -104,11 +126,9 @@ class Annotator(Walk): # pylint: disable=R0903
if variable.type != 'choice': if variable.type != 'choice':
continue continue
is_none = False is_none = False
for choice in variable.choice: for choice in variable.choices:
if choice.type == 'nil': if choice is None:
is_none = True is_none = True
break
if not variable.mandatory and not is_none: if not variable.mandatory and not is_none:
choice = self.objectspace.choice(variable.xmlfiles) variable.choices.append(None)
choice.name = None
choice.type = 'nil'
variable.choice.append(choice)

View file

@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from rougail.i18n import _ from rougail.i18n import _
from rougail.error import DictConsistencyError 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), CONVERT_OPTION = {'number': dict(opttype="IntOption", func=int),
@ -75,15 +75,17 @@ class Walk:
def get_variables(self): def get_variables(self):
"""Iter all variables from the objectspace """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, def get_families(self):
with_parent: bool=False,
):
"""Iter all families from the objectspace """Iter all families from the objectspace
""" """
for family in self.objectspace.space.variables.values(): for path in self.objectspace.families:
yield from self._get_families(family, None, with_parent) 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, def _get_families(self,
family: 'self.objectspace.family', family: 'self.objectspace.family',
@ -101,30 +103,30 @@ class Walk:
if hasattr(family, 'variables'): if hasattr(family, 'variables'):
for fam in family.variables.values(): for fam in family.variables.values():
yield from self._get_families(fam, family, with_parent) yield from self._get_families(fam, family, with_parent)
#
def get_constraints(self, # def get_constraints(self,
create: bool=False, # create: bool=False,
path_prefix: str=None, # path_prefix: str=None,
): # ):
if not self.objectspace.paths.has_path_prefix(): # if not self.objectspace.paths.has_path_prefix():
if hasattr(self.objectspace.space, 'constraints'): # if hasattr(self.objectspace.space, 'constraints'):
yield None, self.objectspace.space.constraints # yield None, self.objectspace.space.constraints
elif create: # elif create:
self.objectspace.space.constraints = self.objectspace.constraints(None) # self.objectspace.space.constraints = self.objectspace.constraints(None)
yield None, self.objectspace.space.constraints # yield None, self.objectspace.space.constraints
else: # else:
if path_prefix: # if path_prefix:
path_prefixes = [path_prefix] # path_prefixes = [path_prefix]
else: # else:
path_prefixes = self.objectspace.paths.get_path_prefixes() # path_prefixes = self.objectspace.paths.get_path_prefixes()
for path_prefix in path_prefixes: # for path_prefix in path_prefixes:
if hasattr(self.objectspace.space, 'variables') and \ # if hasattr(self.objectspace.space, 'variables') and \
path_prefix in self.objectspace.space.variables and \ # path_prefix in self.objectspace.space.variables and \
hasattr(self.objectspace.space.variables[path_prefix], 'constraints'): # hasattr(self.objectspace.space.variables[path_prefix], 'constraints'):
yield path_prefix, self.objectspace.space.variables[path_prefix].constraints # yield path_prefix, self.objectspace.space.variables[path_prefix].constraints
elif create: # elif create:
self.objectspace.space.variables[path_prefix].constraints = self.objectspace.constraints(None) # self.objectspace.space.variables[path_prefix].constraints = self.objectspace.constraints(None)
yield path_prefix, self.objectspace.space.variables[path_prefix].constraints # yield path_prefix, self.objectspace.space.variables[path_prefix].constraints
class Annotator(Walk): # pylint: disable=R0903 class Annotator(Walk): # pylint: disable=R0903
@ -135,7 +137,7 @@ class Annotator(Walk): # pylint: disable=R0903
objectspace, objectspace,
*args, *args,
): ):
if not hasattr(objectspace.space, 'variables'): if not objectspace.paths:
return return
self.objectspace = objectspace self.objectspace = objectspace
self.forbidden_name = ['services', self.objectspace.rougailconfig['variable_namespace']] self.forbidden_name = ['services', self.objectspace.rougailconfig['variable_namespace']]
@ -152,14 +154,10 @@ class Annotator(Walk): # pylint: disable=R0903
self._convert_variable(variable) self._convert_variable(variable)
def _convert_variable(self, def _convert_variable(self,
variable, variable: dict,
) -> None: ) -> None:
if variable.namespace == self.objectspace.rougailconfig['variable_namespace'] and \ # variable without description: description is the name
variable.name in self.forbidden_name: if variable.type != 'symlink' and not variable.description:
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.description = variable.name variable.description = variable.name
if hasattr(variable, 'value'): if hasattr(variable, 'value'):
for idx, value in enumerate(variable.value): for idx, value in enumerate(variable.value):
@ -178,54 +176,56 @@ class Annotator(Walk): # pylint: disable=R0903
value.name = None value.name = None
if not variable.value: if not variable.value:
del variable.value del variable.value
if hasattr(variable, 'choice'): if hasattr(variable, 'choices') and variable.choices is not None:
if variable.type != 'choice': if variable.type != 'choice':
msg = _(f'choice for the variable "{variable.name}" not allowed with "{variable.type}" type') msg = _(f'choice for the variable "{variable.name}" not allowed with "{variable.type}" type')
raise DictConsistencyError(msg, 3, variable.xmlfiles) raise DictConsistencyError(msg, 3, variable.xmlfiles)
values = [] values = []
choice_type = None choice_type = None
for choice in variable.choice: for choice in variable.choices:
if choice_type == 'variable': #if choice_type == 'variable':
msg = _(f'only one "variable" choice is allowed ' # msg = _(f'only one "variable" choice is allowed '
f'the variable "{variable.name}"') # f'the variable "{variable.name}"')
raise DictConsistencyError(msg, 5, choice.xmlfiles) # raise DictConsistencyError(msg, 5, choice.xmlfiles)
if choice.type == 'nil': #if choice.type == 'nil':
choice.name = None # choice.name = None
elif choice.type == 'space': #elif choice.type == 'space':
choice.name = ' ' # choice.name = ' '
elif choice.type == 'variable': if isinstance(choice, dict):
choice.name = self.objectspace.paths.get_variable(choice.name, if choice['type'] == 'variable':
variable.namespace, obj = self.objectspace.paths[choice['value']]
force_path_prefix=variable.path_prefix, #FIXME?
) if not obj.multi:
if not choice.name.multi: msg = _(f'only multi "variable" is allowed for a choice '
msg = _(f'only multi "variable" is allowed for a choice ' f'of variable "{variable.name}"')
f'of variable "{variable.name}"') raise DictConsistencyError(msg, 6, choice['xmlfiles'])
raise DictConsistencyError(msg, 6, choice.xmlfiles) #values.append(obj)
else: elif choice['type'] != 'jinja':
if not hasattr(choice, 'name'): raise Exception('hu?')
msg = _(f'choice for variable "{variable.name}" must have a value') # else:
raise DictConsistencyError(msg, 14, choice.xmlfiles) # if not hasattr(choice, 'name'):
choice.name = CONVERT_OPTION.get(choice.type, {}).get('func', str)(choice.name) # msg = _(f'choice for variable "{variable.name}" must have a value')
if choice_type is None: # raise DictConsistencyError(msg, 14, choice.xmlfiles)
choice_type = choice.type # choice.name = CONVERT_OPTION.get(choice.type, {}).get('func', str)(choice.name)
values.append(choice.name) #if choice_type is None:
if choice_type not in ['function', 'variable'] and hasattr(variable, 'value'): # choice_type = choice.type
for value in variable.value: # else:
if value.name not in values: # values.append(choice)
msg = _(f'value "{value.name}" of variable "{variable.name}" is not in list ' # FIXME if variable.values:
f'of all expected values ({values})') # FIXME for value in variable.values:
raise DictConsistencyError(msg, 15, value.xmlfiles) # FIXME if value not in values:
ref_choice = variable.choice[0] # FIXME msg = _(f'value "{value.name}" of variable "{variable.name}" is not in list '
self.objectspace.paths.set_valid_enums(variable.path, # FIXME f'of all expected values ({values})')
values, # FIXME raise DictConsistencyError(msg, 15, value.xmlfiles)
variable.path_prefix, #ref_choice = variable.choices[0]
) self.objectspace.choices.append(variable.path,
values,
)
elif variable.type == 'choice': elif variable.type == 'choice':
msg = _(f'choice is mandatory for the variable "{variable.name}" with choice type') msg = _(f'choice is mandatory for the variable "{variable.name}" with choice type')
raise DictConsistencyError(msg, 4, variable.xmlfiles) raise DictConsistencyError(msg, 4, variable.xmlfiles)
variable.doc = variable.description # variable.doc = variable.description
del variable.description # del variable.description
def convert_test(self): def convert_test(self):
"""Convert variable tests value """Convert variable tests value
@ -241,17 +241,13 @@ class Annotator(Walk): # pylint: disable=R0903
else: else:
value = CONVERT_OPTION.get(variable.type, {}).get('func', str)(value) value = CONVERT_OPTION.get(variable.type, {}).get('func', str)(value)
new_values.append(value) new_values.append(value)
if not hasattr(variable, 'information'): self.objectspace.informations.add(variable.path, 'test', tuple(new_values))
variable.information = self.objectspace.information(variable.xmlfiles)
variable.information.test = tuple(new_values)
def convert_help(self): def convert_help(self):
"""Convert variable help """Convert variable help
""" """
for variable in self.get_variables(): for variable in self.get_variables():
if not hasattr(variable, 'help'): if not hasattr(variable, 'help') or not variable.help:
continue continue
if not hasattr(variable, 'information'): self.objectspace.informations.add(variable.path, 'help', variable.help)
variable.information = self.objectspace.information(variable.xmlfiles)
variable.information.help = variable.help
del variable.help del variable.help

View file

@ -36,6 +36,7 @@ DTDDIR = join(dirname(abspath(__file__)), 'data')
RougailConfig = {'dictionaries_dir': [join(ROUGAILROOT, 'dictionaries')], RougailConfig = {'dictionaries_dir': [join(ROUGAILROOT, 'dictionaries')],
'services_dir': [join(ROUGAILROOT, 'services')],
'extra_dictionaries': {}, 'extra_dictionaries': {},
'patches_dir': join(ROUGAILROOT, 'patches'), 'patches_dir': join(ROUGAILROOT, 'patches'),
'templates_dir': join(ROUGAILROOT, 'templates'), 'templates_dir': join(ROUGAILROOT, 'templates'),

View file

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

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

@ -0,0 +1,487 @@
from typing import Optional, Union, get_type_hints, Any, Literal, List
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 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 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,
) -> None:
if 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 is_family(self, path: str):
if not path in self._data:
raise Exception(f'cannot find family {path}')
return isinstance(self._data[path], Family)
def __contains__(self,
path: str,
) -> bool:
return path in self._data
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.family = Family
self.variable = Variable
#FIXME
self.exclude_imports = []
self.informations = Informations()
self.properties = Appendable()
self.choices = Appendable()
super().__init__()
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.parents[namespace] = []
# self.parse_family(filename, namespace, '.', namespace, {'description': description})
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,
) -> None:
if subpath:
path = f'{subpath}.{name}'
else:
path = name
if 'type' in obj:
if obj['type'] in ['family', 'dynamic', 'leadership']:
typ = 'family'
else:
typ = 'variable'
else:
if path in self.paths:
if self.paths.is_family(path):
typ = 'family'
else:
typ = 'variable'
else:
extra_keys = set(obj) - FAMILY_ATTRS
typ = 'family'
for key in extra_keys:
value = obj[key]
if not isinstance(value, dict):
typ = 'variable'
break
if typ == 'family':
parser = self.parse_family
else:
parser = self.parse_variable
parser(filename, name, subpath, path, obj)
def parse_family(self,
filename: str,
name: str,
subpath: str,
path: str,
family: dict,
) -> None:
family_obj = {}
subfamily_obj = {}
for key, value in family.items():
if key.startswith('_'):
key = key[1:]
if key in 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))
self.paths[path].xmlfiles.append(filename)
else:
extra_attrs = set(family_obj) - FAMILY_ATTRS
if extra_attrs:
raise Exception(f'extra attrs ... {extra_attrs}')
self.add_family(subpath,
path,
name,
family_obj,
filename,
)
for key, value in subfamily_obj.items():
if not isinstance(value, dict):
raise Exception(f'pfff {key}')
self.family_or_variable(filename,
key,
path,
value,
)
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
self.paths.add(path, self.family(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,
) -> None:
extra_attrs = set(variable) - 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))
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,
)
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_')
class ParserService:
def __init__(self):
self.service = Service
self.services = {}
self.ip = {}
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 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) - 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 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) - IP_ATTRS
if extra_attrs:
raise Exception(f'extra attrs ... {extra_attrs}')
self.ip.setdefault(path, []).append(IP(name=name, **ip))
self.ip[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__()
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.parents['.'].append(namespace)
self.parse_variable_file(filename,
namespace,
# self.rougailconfig['variable_namespace_description'],
)
for namespace, extra_dirs in self.rougailconfig['extra_dictionaries'].items():
#self.parents['.'].append(namespace)
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()
FAMILY_ATTRS = frozenset(list(get_type_hints(Family)) + ['redefine'])
VARIABLE_ATTRS = frozenset(list(get_type_hints(Variable)) + ['redefine', 'exists'])
SERVICE_ATTRS = frozenset(list(get_type_hints(Service)) + ['redefine', 'type'])
IP_ATTRS = frozenset(list(get_type_hints(IP)))

View file

@ -90,6 +90,7 @@ class ObjSpace: # pylint: disable=R0903
def convert_boolean(value: str) -> bool: def convert_boolean(value: str) -> bool:
"""Boolean coercion. The Rougail XML may contain srings like `True` or `False` """Boolean coercion. The Rougail XML may contain srings like `True` or `False`
""" """
print('FIXME')
if isinstance(value, bool): if isinstance(value, bool):
return value return value
if value == 'True': if value == 'True':
@ -587,24 +588,24 @@ class RougailObjSpace:
getattr(space, child.tag).append(variableobj) getattr(space, child.tag).append(variableobj)
else: else:
setattr(space, child.tag, variableobj) setattr(space, child.tag, variableobj)
#
#
def get_variables(objectspace): #def get_variables(objectspace):
"""Iter all variables from the objectspace # """Iter all variables from the objectspace
""" # """
if not hasattr(objectspace.space, 'variables'): # if not hasattr(objectspace.space, 'variables'):
return # return
for family in objectspace.space.variables.values(): # for family in objectspace.space.variables.values():
yield from _get_variables(family, objectspace.family) # yield from _get_variables(family, objectspace.family)
#
#
def _get_variables(family, family_type): #def _get_variables(family, family_type):
if hasattr(family, 'variable'): # if hasattr(family, 'variable'):
for variable in family.variable.values(): # for variable in family.variable.values():
if isinstance(variable, family_type): # if isinstance(variable, family_type):
yield from _get_variables(variable, family_type) # yield from _get_variables(variable, family_type)
else: # else:
yield variable # yield variable
if hasattr(family, 'variables'): # if hasattr(family, 'variables'):
for family in family.variables.values(): # for family in family.variables.values():
yield from _get_variables(family, family_type) # 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 along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
""" """
from rougail.objspace import get_variables #from rougail.objspace import get_variables
from rougail.utils import normalize_family #from rougail.utils import normalize_family
#
#
def provider_supplier(objectspace, #def provider_supplier(objectspace,
path_prefix, # path_prefix,
): # ):
n_path_prefix = normalize_family(path_prefix) # n_path_prefix = normalize_family(path_prefix)
for variable in get_variables(objectspace): # for variable in get_variables(objectspace):
if variable.path_prefix != n_path_prefix: # if variable.path_prefix != n_path_prefix:
continue # continue
if hasattr(variable, 'provider'): # if hasattr(variable, 'provider'):
family_name, variable.name = variable.path.rsplit('.', 1) # family_name, variable.name = variable.path.rsplit('.', 1)
objectspace.paths.set_provider(variable, # objectspace.paths.set_provider(variable,
variable.name, # variable.name,
family_name, # family_name,
) # )
if hasattr(variable, 'supplier'): # if hasattr(variable, 'supplier'):
family_name, variable.name = variable.path.rsplit('.', 1) # family_name, variable.name = variable.path.rsplit('.', 1)
objectspace.paths.set_supplier(variable, # objectspace.paths.set_supplier(variable,
variable.name, # variable.name,
family_name, # family_name,
) # )

View file

@ -1,4 +1,20 @@
from . import none, cheetah, jinja, creole_legacy MODULES = ['none']
from . import none
try:
__all__ = ('none', 'cheetah', 'jinja', 'creole_legacy') 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

@ -56,17 +56,16 @@ class TiramisuReflector:
def __init__(self, def __init__(self,
objectspace, objectspace,
funcs_paths, funcs_paths,
internal_functions,
cfg,
): ):
self.cfg = cfg self.rougailconfig = objectspace.rougailconfig
self.jinja_added = False self.jinja_added = False
self.reflector_objects = {}
self.text = {'header': [], self.text = {'header': [],
'option': [], 'option': [],
'optiondescription': [], 'optiondescription': [],
} }
if funcs_paths: 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", 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", "from importlib.util import spec_from_loader as _spec_from_loader, module_from_spec as _module_from_spec",
"class func:", "class func:",
@ -87,9 +86,9 @@ class TiramisuReflector:
if not isfile(funcs_path): if not isfile(funcs_path):
continue continue
self.text['header'].append(f"_load_functions('{funcs_path}')") self.text['header'].append(f"_load_functions('{funcs_path}')")
if self.cfg['export_with_import']: if self.rougailconfig['export_with_import']:
if internal_functions: if self.rougailconfig['internal_functions']:
for func in internal_functions: for func in self.rougailconfig['internal_functions']:
self.text['header'].append(f"setattr(func, '{func}', {func})") self.text['header'].append(f"setattr(func, '{func}', {func})")
self.text['header'].extend(["try:", self.text['header'].extend(["try:",
" from tiramisu4 import *", " from tiramisu4 import *",
@ -98,12 +97,12 @@ class TiramisuReflector:
" from tiramisu import *", " from tiramisu import *",
" from tiramisu.setting import ALLOWED_LEADER_PROPERTIES", " 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.text['header'].append(f'ALLOWED_LEADER_PROPERTIES.add("{mode}")')
self.objectspace = objectspace self.objectspace = objectspace
self.make_tiramisu_objects() 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): #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") # self.text['header'].append("from rougail.tiramisu import ConvertDynOptionDescription")
def add_jinja_to_function(self, def add_jinja_to_function(self,
variable_name: str, variable_name: str,
@ -146,20 +145,30 @@ class TiramisuReflector:
"""make tiramisu objects """make tiramisu objects
""" """
baseelt = BaseElt() baseelt = BaseElt()
baseelt.reflector_name = f'option_0{self.objectspace.rougailconfig["suffix"]}' self.objectspace.reflector_names[baseelt.path] = f'option_0{self.rougailconfig["suffix"]}'
self.set_name(baseelt)
basefamily = Family(baseelt, basefamily = Family(baseelt,
self, self,
) )
if not self.objectspace.paths.has_path_prefix(): #FIXMEif not self.objectspace.paths.has_path_prefix():
for elt in self.reorder_family(self.objectspace.space): if 1:
self.populate_family(basefamily, # for elt in self.reorder_family(self.objectspace.space):
elt, for elt in self.objectspace.paths.get():
) if elt.path in self.objectspace.families:
if not hasattr(basefamily.elt, 'information'): Family(elt,
basefamily.elt.information = self.objectspace.information(None) self,
basefamily.elt.information = self.objectspace.paths.get_providers_path() )
basefamily.elt.information.update(self.objectspace.paths.get_suppliers_path()) 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: else:
path_prefixes = self.objectspace.paths.get_path_prefixes() path_prefixes = self.objectspace.paths.get_path_prefixes()
for path_prefix in path_prefixes: for path_prefix in path_prefixes:
@ -179,66 +188,67 @@ class TiramisuReflector:
setattr(baseprefix.elt.information, key, value) setattr(baseprefix.elt.information, key, value)
for key, value in self.objectspace.paths.get_suppliers_path(path_prefix).items(): for key, value in self.objectspace.paths.get_suppliers_path(path_prefix).items():
setattr(baseprefix.elt.information, key, value) setattr(baseprefix.elt.information, key, value)
baseelt.name = normalize_family(self.cfg['base_option_name']) baseelt.name = normalize_family(self.rougailconfig['base_option_name'])
baseelt.doc = self.cfg['base_option_name'] baseelt.description = self.rougailconfig['base_option_name']
baseelt.reflector_object.get([], baseelt.doc, 'base') # pylint: disable=E1101 self.reflector_objects[baseelt.path].get([], baseelt.description, 'base') # pylint: disable=E1101
#
def reorder_family(self, space): # def reorder_family(self, space):
"""variable_namespace family has to be loaded before any other family # """family has to be loaded before any other family
because `extra` family could use `variable_namespace` variables. # because `extra` family could use `variable_namespace` variables.
""" # """
if hasattr(space, 'variables'): # if hasattr(space, 'variables'):
variable_namespace = self.objectspace.rougailconfig['variable_namespace'] # variable_namespace = self.rougailconfig['variable_namespace']
if variable_namespace in space.variables: # if variable_namespace in space.variables:
yield space.variables[variable_namespace] # yield space.variables[variable_namespace]
for elt, value in space.variables.items(): # for elt, value in space.variables.items():
if elt != self.objectspace.rougailconfig['variable_namespace']: # if elt != self.rougailconfig['variable_namespace']:
yield value # yield value
if hasattr(space, 'services'): # if hasattr(space, 'services'):
yield space.services # yield space.services
#
def populate_family(self, # def populate_family(self,
parent_family, # parent_family,
elt, # elt,
): # ):
"""Populate family # """Populate family
""" # """
self.set_name(elt) # self.set_name(elt)
family = Family(elt, # family = Family(elt,
self, # self,
) # )
parent_family.add(family) # parent_family.add(family)
for children in vars(elt).values(): # for children in vars(elt).values():
if isinstance(children, self.objectspace.family): # print('pouet', children)
self.populate_family(family, # if isinstance(children, self.objectspace.family):
children, # self.populate_family(family,
) # children,
continue # )
if isinstance(children, dict): # continue
children = list(children.values()) # if isinstance(children, dict):
if isinstance(children, list): # children = list(children.values())
for child in children: # if isinstance(children, list):
if isinstance(child, self.objectspace.property_) or \ # for child in children:
not isinstance(child, RootRougailObject): # if isinstance(child, self.objectspace.property_) or \
continue # not isinstance(child, RootRougailObject):
if isinstance(child, self.objectspace.variable): # continue
self.set_name(child) # if isinstance(child, self.objectspace.variable):
family.add(Variable(child, # self.set_name(child)
self, # family.add(Variable(child,
)) # self,
else: # ))
self.populate_family(family, # else:
child, # self.populate_family(family,
) # child,
# )
def set_name(self, def set_name(self,
elt, elt,
): ):
"""Set name """Set name
""" """
if not hasattr(elt, 'reflector_name'): if elt.path not in self.objectspace.reflector_names:
self.objectspace.paths.set_name(elt, 'optiondescription_') self.objectspace.set_name(elt, 'optiondescription_')
return elt.reflector_name return self.objectspace.reflector_names[elt.path]
def get_text(self): def get_text(self):
"""Get text """Get text
@ -257,10 +267,11 @@ class Common:
elt, elt,
tiramisu, tiramisu,
): ):
self.objectspace = tiramisu.objectspace
self.elt = elt self.elt = elt
self.option_name = None self.option_name = None
self.tiramisu = tiramisu self.tiramisu = tiramisu
self.elt.reflector_object = self tiramisu.reflector_objects[elt.path] = self
self.object_type = None self.object_type = None
def get(self, calls, parent_name, typ): def get(self, calls, parent_name, typ):
@ -273,7 +284,7 @@ class Common:
self_calls.append(self.elt.path) self_calls.append(self.elt.path)
self.calls = self_calls self.calls = self_calls
if self.option_name is None: 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_attrib()
self.populate_informations() self.populate_informations()
return self.option_name return self.option_name
@ -282,11 +293,11 @@ class Common:
"""Populate attributes """Populate attributes
""" """
keys = {'name': self.convert_str(self.elt.name)} keys = {'name': self.convert_str(self.elt.name)}
if hasattr(self.elt, 'doc'): if hasattr(self.elt, 'description') and self.elt.description:
keys['doc'] = self.convert_str(self.elt.doc) keys['doc'] = self.convert_str(self.elt.description)
self._populate_attrib(keys) self._populate_attrib(keys)
if hasattr(self.elt, 'properties'): if self.elt.path in self.objectspace.properties:
keys['properties'] = self.properties_to_string(self.elt.properties) keys['properties'] = self.properties_to_string(self.objectspace.properties[self.elt.path])
attrib = ', '.join([f'{key}={value}' for key, value in keys.items()]) attrib = ', '.join([f'{key}={value}' for key, value in keys.items()])
if self.__class__.__name__ == 'Family': if self.__class__.__name__ == 'Family':
#pouet #pouet
@ -315,7 +326,7 @@ class Common:
properties = [self.convert_str(property_) for property_ in values properties = [self.convert_str(property_) for property_ in values
if isinstance(property_, str)] if isinstance(property_, str)]
calc_properties = [self.calc_properties(property_) for property_ in values \ 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) + '})' return 'frozenset({' + ', '.join(sorted(properties) + calc_properties) + '})'
def calc_properties(self, def calc_properties(self,
@ -323,7 +334,7 @@ class Common:
) -> str: ) -> str:
"""Populate properties """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), " kwargs = (f"'condition': ParamOption({option_name}, notraisepropertyerror=True), "
f"'expected': {self.populate_param(child.expected)}") f"'expected': {self.populate_param(child.expected)}")
if child.inverse: if child.inverse:
@ -334,15 +345,10 @@ class Common:
def populate_informations(self): def populate_informations(self):
"""Populate Tiramisu's informations """Populate Tiramisu's informations
""" """
if not hasattr(self.elt, 'information'): informations = self.objectspace.informations.get(self.elt.path)
if not informations:
return return
if isinstance(self.elt.information, dict):
informations = self.elt.information
else:
informations = vars(self.elt.information)
for key, value in informations.items(): for key, value in informations.items():
if key == 'xmlfiles':
continue
if isinstance(value, str): if isinstance(value, str):
value = self.convert_str(value) value = self.convert_str(value)
self.tiramisu.text['option'].append(f"{self.option_name}.impl_set_information('{key}', {value})") self.tiramisu.text['option'].append(f"{self.option_name}.impl_set_information('{key}', {value})")
@ -352,10 +358,10 @@ class Common:
): ):
"""Populate variable parameters """Populate variable parameters
""" """
if param.type in ['number', 'boolean', 'nil', 'port', 'choice', 'space']: if isinstance(param, self.objectspace.variable):
return f'ParamValue({param.text})'
if param.type in ['variable_name', 'variable']:
return self.build_option_param(param) return self.build_option_param(param)
if not isinstance(param, dict):
return f'ParamValue({param})'
if param.type == 'information': if param.type == 'information':
if hasattr(self.elt, 'multi') and self.elt.multi: if hasattr(self.elt, 'multi') and self.elt.multi:
default = [] default = []
@ -364,15 +370,12 @@ class Common:
if hasattr(param, 'variable'): if hasattr(param, 'variable'):
if param.variable.path == self.elt.path: if param.variable.path == self.elt.path:
return f'ParamSelfInformation("{param.text}", {default})' 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})' return f'ParamInformation("{param.text}", {default})'
if param.type == 'suffix': if param.type == 'suffix':
return 'ParamSuffix()' return 'ParamSuffix()'
if param.type == 'index': if param.type == 'index':
return 'ParamIndex()' 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) value = self.convert_str(param.text)
return f'ParamValue({value})' return f'ParamValue({value})'
@ -381,21 +384,18 @@ class Common:
) -> str: ) -> str:
"""build variable parameters """build variable parameters
""" """
if param.type == 'variable': option_name = self.tiramisu.reflector_objects[param.path].get(self.calls, self.elt.path, 'param')
option_name = param.text.reflector_object.get(self.calls, self.elt.path, 'param')
else:
option_name = param.text
params = [f'{option_name}'] params = [f'{option_name}']
if hasattr(param, 'suffix'): if hasattr(param, 'suffix'):
param_type = 'ParamDynOption' 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}']) params.extend([f"'{param.suffix}'", f'{family}'])
if param.optional: if param.optional:
params.append('optional=True') params.append('optional=True')
else: else:
param_type = 'ParamOption' param_type = 'ParamOption'
if not param.propertyerror: # if not param.propertyerror:
params.append('notraisepropertyerror=True') # params.append('notraisepropertyerror=True')
return "{}({})".format(param_type, ', '.join(params)) return "{}({})".format(param_type, ', '.join(params))
@ -412,12 +412,12 @@ class Variable(Common):
def _populate_attrib(self, def _populate_attrib(self,
keys: dict, keys: dict,
): ):
if hasattr(self.elt, 'opt'): if self.elt.type == 'symlink':
keys['opt'] = self.elt.opt.reflector_object.get(self.calls, self.elt.path, 'opt') keys['opt'] = self.tiramisu.reflector_objects[self.elt.opt.path].get(self.calls, self.elt.path, 'opt')
if hasattr(self.elt, 'choice'): if hasattr(self.elt, 'choice'):
values = self.elt.choice values = self.elt.choice
if values[0].type == 'variable': if values[0].type == 'variable':
value = values[0].name.reflector_object.get(self.calls, self.elt.path, 'choice') value = self.tiramisu.reflector_objects[values[0].name.path].get(self.calls, self.elt.path, 'choice')
keys['values'] = f"Calculation(func.calc_value, Params((ParamOption({value}))))" keys['values'] = f"Calculation(func.calc_value, Params((ParamOption({value}))))"
elif values[0].type == 'function': elif values[0].type == 'function':
keys['values'] = self.calculation_value(values[0], []) keys['values'] = self.calculation_value(values[0], [])
@ -430,12 +430,12 @@ class Variable(Common):
value = getattr(self.elt, key) value = getattr(self.elt, key)
if isinstance(value, str): if isinstance(value, str):
value = self.convert_str(value) value = self.convert_str(value)
elif isinstance(value, self.tiramisu.objectspace.value): elif isinstance(value, dict):
value = self.calculation_value(value, [], calc_multi=value.calc_multi) value = self.calculation_value(value, [], calc_multi=key == 'calc_multi')
keys[key] = value keys[key] = value
if hasattr(self.elt, 'validators'): #FIXME if self.elt.validators:
keys['validators'] = '[' + ', '.join([self.calculation_value(val, # keys['validators'] = '[' + ', '.join([self.calculation_value(val,
['ParamSelfOption(whole=False)']) for val in self.elt.validators]) + ']' # ['ParamSelfOption(whole=False)']) for val in self.elt.validators]) + ']'
for key in ['min_number', 'max_number']: for key in ['min_number', 'max_number']:
if hasattr(self.elt, key): if hasattr(self.elt, key):
keys[key] = getattr(self.elt, key) keys[key] = getattr(self.elt, key)
@ -451,22 +451,21 @@ class Variable(Common):
) -> str: ) -> str:
"""Generate calculated value """Generate calculated value
""" """
kwargs = [] if child['type'] == 'jinja':
self.tiramisu.add_jinja_to_function(self.elt.path, child['name'])
function = 'jinja_to_function'
else:
raise Exception("connard")
# has parameters # has parameters
function = child.name
new_args = [] new_args = []
if hasattr(child, 'param'): kwargs = []
for param in child.param: if 'params' in child:
value = self.populate_param(param) for key, value in child['params'].items():
if not hasattr(param, 'name'): value = self.populate_param(value)
if not key:
new_args.append(str(value)) new_args.append(str(value))
else: else:
kwargs.append(f"'{param.name}': " + value) kwargs.append(f"'{key}': " + value)
if function == 'valid_network_netmask':
new_args.extend(args)
else:
args.extend(new_args)
new_args = args
ret = f'Calculation(func.{function}, Params((' + ', '.join(new_args) + ')' ret = f'Calculation(func.{function}, Params((' + ', '.join(new_args) + ')'
if kwargs: if kwargs:
ret += ', kwargs={' + ', '.join(kwargs) + '}' ret += ', kwargs={' + ', '.join(kwargs) + '}'
@ -505,6 +504,9 @@ class Family(Common):
keys: list, keys: list,
) -> None: ) -> None:
if hasattr(self.elt, 'suffixes'): if hasattr(self.elt, 'suffixes'):
dyn = self.elt.suffixes.reflector_object.get(self.calls, self.elt.path, 'suffixes') dyn = self.tiramisu.reflector_objects[self.elt.suffixes.path].get(self.calls, self.elt.path, 'suffixes')
keys['suffixes'] = f"Calculation(func.calc_value, Params((ParamOption({dyn}, notraisepropertyerror=True))))" 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", "owner": "default",
"value": true "value": true
}, },
"services.tata.manage": { "services.tata_service.manage": {
"owner": "default", "owner": "default",
"value": true "value": true
} }

View file

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

View file

@ -1,9 +1,9 @@
{ {
"services.tata.activate": { "services.tata_service.activate": {
"owner": "default", "owner": "default",
"value": true "value": true
}, },
"services.tata.manage": { "services.tata_service.manage": {
"owner": "default", "owner": "default",
"value": true "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.machinery import SourceFileLoader as _SourceFileLoader
from importlib.util import spec_from_loader, module_from_spec from importlib.util import spec_from_loader as _spec_from_loader, module_from_spec as _module_from_spec
loader = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py') class func:
spec = spec_from_loader(loader.name, loader) pass
func = module_from_spec(spec)
loader.exec_module(func) def _load_functions(path):
for key, value in dict(locals()).items(): global _SourceFileLoader, _spec_from_loader, _module_from_spec, func
if key != ['SourceFileLoader', 'func']: loader = _SourceFileLoader('func', path)
setattr(func, key, value) 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: try:
from tiramisu4 import * from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except: except:
from tiramisu import * 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_3 = BoolOption(name="activate", doc="activate", default=True)
option_4 = BoolOption(name="manage", doc="manage", default=True) option_4 = BoolOption(name="manage", doc="manage", default=True)
option_2 = OptionDescription(name="tata", doc="tata", children=[option_3, option_4]) optiondescription_2 = OptionDescription(name="tata_service", doc="tata_service", children=[option_3, option_4])
option_1 = OptionDescription(name="services", doc="services", children=[option_2], properties=frozenset({"hidden"})) optiondescription_2.impl_set_information('type', "service")
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1]) 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.machinery import SourceFileLoader as _SourceFileLoader
from importlib.util import spec_from_loader, module_from_spec from importlib.util import spec_from_loader as _spec_from_loader, module_from_spec as _module_from_spec
loader = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py') class func:
spec = spec_from_loader(loader.name, loader) pass
func = module_from_spec(spec)
loader.exec_module(func) def _load_functions(path):
for key, value in dict(locals()).items(): global _SourceFileLoader, _spec_from_loader, _module_from_spec, func
if key != ['SourceFileLoader', 'func']: loader = _SourceFileLoader('func', path)
setattr(func, key, value) 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: try:
from tiramisu4 import * from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except: except:
from tiramisu import * 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_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_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"})) optiondescription_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]) optiondescription_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2, optiondescription_3], properties=frozenset({"basic"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1]) 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.machinery import SourceFileLoader as _SourceFileLoader
from importlib.util import spec_from_loader, module_from_spec from importlib.util import spec_from_loader as _spec_from_loader, module_from_spec as _module_from_spec
loader = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py') class func:
spec = spec_from_loader(loader.name, loader) pass
func = module_from_spec(spec)
loader.exec_module(func) def _load_functions(path):
for key, value in dict(locals()).items(): global _SourceFileLoader, _spec_from_loader, _module_from_spec, func
if key != ['SourceFileLoader', 'func']: loader = _SourceFileLoader('func', path)
setattr(func, key, value) 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: try:
from tiramisu4 import * from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except: except:
from tiramisu import * 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_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_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"})) optiondescription_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]) optiondescription_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2, optiondescription_3], properties=frozenset({"normal"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1]) 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.machinery import SourceFileLoader as _SourceFileLoader
from importlib.util import spec_from_loader, module_from_spec from importlib.util import spec_from_loader as _spec_from_loader, module_from_spec as _module_from_spec
loader = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py') class func:
spec = spec_from_loader(loader.name, loader) pass
func = module_from_spec(spec)
loader.exec_module(func) def _load_functions(path):
for key, value in dict(locals()).items(): global _SourceFileLoader, _spec_from_loader, _module_from_spec, func
if key != ['SourceFileLoader', 'func']: loader = _SourceFileLoader('func', path)
setattr(func, key, value) 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: try:
from tiramisu4 import * from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except: except:
from tiramisu import * 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_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"})) optiondescription_2 = OptionDescription(name="general", doc="général", children=[option_3], properties=frozenset({"normal"}))
option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2]) optiondescription_1 = OptionDescription(name="rougail", doc="rougail", children=[optiondescription_2], properties=frozenset({"normal"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1]) 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.machinery import SourceFileLoader as _SourceFileLoader
from importlib.util import spec_from_loader, module_from_spec from importlib.util import spec_from_loader as _spec_from_loader, module_from_spec as _module_from_spec
loader = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py') class func:
spec = spec_from_loader(loader.name, loader) pass
func = module_from_spec(spec)
loader.exec_module(func) def _load_functions(path):
for key, value in dict(locals()).items(): global _SourceFileLoader, _spec_from_loader, _module_from_spec, func
if key != ['SourceFileLoader', 'func']: loader = _SourceFileLoader('func', path)
setattr(func, key, value) 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: try:
from tiramisu4 import * from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except: except:
from tiramisu import * 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_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_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"})) optiondescription_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]) optiondescription_1 = OptionDescription(name="rougail", doc="rougail", children=[optiondescription_2], properties=frozenset({"normal"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1]) 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.machinery import SourceFileLoader as _SourceFileLoader
from importlib.util import spec_from_loader, module_from_spec from importlib.util import spec_from_loader as _spec_from_loader, module_from_spec as _module_from_spec
loader = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py') class func:
spec = spec_from_loader(loader.name, loader) pass
func = module_from_spec(spec)
loader.exec_module(func) def _load_functions(path):
for key, value in dict(locals()).items(): global _SourceFileLoader, _spec_from_loader, _module_from_spec, func
if key != ['SourceFileLoader', 'func']: loader = _SourceFileLoader('func', path)
setattr(func, key, value) 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: try:
from tiramisu4 import * from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except: except:
from tiramisu import * 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_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"})) optiondescription_2 = OptionDescription(name="general", doc="général", children=[option_3], properties=frozenset({"normal"}))
option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2]) optiondescription_1 = OptionDescription(name="rougail", doc="rougail", children=[optiondescription_2], properties=frozenset({"normal"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1]) 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:
name: '{{ 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.machinery import SourceFileLoader as _SourceFileLoader
from importlib.util import spec_from_loader, module_from_spec from importlib.util import spec_from_loader as _spec_from_loader, module_from_spec as _module_from_spec
loader = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py') class func:
spec = spec_from_loader(loader.name, loader) pass
func = module_from_spec(spec)
loader.exec_module(func) def _load_functions(path):
for key, value in dict(locals()).items(): global _SourceFileLoader, _spec_from_loader, _module_from_spec, func
if key != ['SourceFileLoader', 'func']: loader = _SourceFileLoader('func', path)
setattr(func, key, value) 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: try:
from tiramisu4 import * from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except: except:
from tiramisu import * 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_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_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"}))
option_2 = OptionDescription(name="general", doc="general", children=[option_3, option_4], properties=frozenset({"normal"})) optiondescription_2 = OptionDescription(name="general", doc="general", children=[option_3, option_4], properties=frozenset({"normal"}))
option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2]) optiondescription_1 = OptionDescription(name="rougail", doc="rougail", children=[optiondescription_2], properties=frozenset({"normal"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1]) 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:
name: '{{ 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