From 822483ab7075a201d3e50ad9d9460a379d611482 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Fri, 10 Apr 2020 18:01:00 +0200 Subject: [PATCH 01/32] manage method in service --- src/rougail/annotator.py | 2 +- src/rougail/data/rougail.dtd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rougail/annotator.py b/src/rougail/annotator.py index e3c9f18a..08d9e502 100644 --- a/src/rougail/annotator.py +++ b/src/rougail/annotator.py @@ -113,7 +113,7 @@ class ServiceAnnotator: def convert_service_to_family(self, service_name, service_family, service): for elttype, values in vars(service).items(): - if elttype in ['name', 'index']: + if elttype in ['name', 'index', 'method']: continue family = self.objectspace.family() family.name = elttype + 's' diff --git a/src/rougail/data/rougail.dtd b/src/rougail/data/rougail.dtd index 4dc3ef58..22495198 100644 --- a/src/rougail/data/rougail.dtd +++ b/src/rougail/data/rougail.dtd @@ -68,7 +68,7 @@ - + From b0b44d4ee1468a76ff0bf25abdc53aa06e9b8fea Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sat, 11 Apr 2020 17:24:09 +0200 Subject: [PATCH 02/32] reorganise --- src/rougail/annotator.py | 173 ++++++++++++++++++++++++++------------- src/rougail/objspace.py | 162 ++++++++++++++++++++++++------------ 2 files changed, 222 insertions(+), 113 deletions(-) diff --git a/src/rougail/annotator.py b/src/rougail/annotator.py index 08d9e502..7e2bfacc 100644 --- a/src/rougail/annotator.py +++ b/src/rougail/annotator.py @@ -1,5 +1,6 @@ # coding: utf-8 from copy import copy +from typing import List from collections import OrderedDict from os.path import join, basename @@ -184,7 +185,10 @@ class ServiceAnnotator: family.name = '{}{}'.format(name, index) family.variable = variables family.mode = None - self.paths.append('family', subpath, 'services', creoleobj=family) + self.paths.add_family('services', + subpath, + family, + ) families.append(family) return families @@ -230,7 +234,11 @@ class ServiceAnnotator: choices.append(choice) variable.choice = choices path = '{}.{}'.format(subpath, name) - self.paths.append('variable', path, 'services', 'service', variable) + self.paths.add_variable('services', + path, + 'service', + variable, + ) return variable def _update_file(self, file_, index, service_path): @@ -327,7 +335,10 @@ class ServiceAnnotator: family.name = '{}{}'.format(name, index) family.variable = variables family.mode = None - self.paths.append('family', subpath, 'services', creoleobj=family) + self.paths.add_family('services', + subpath, + family, + ) families.append(family) return families @@ -440,64 +451,108 @@ class SpaceAnnotator(object): variable.help = hlp.text del self.space.help + def manage_leader(self, + leader_space: 'Leadership', + leader_family_name: str, + leader_name: str, + namespace: str, + variable: 'Variable', + group: 'Group', + leader_fullname: str, + ) -> None: + # manage leader's variable + if variable.multi is not True: + raise CreoleDictConsistencyError(_('the variable {} in a group must be multi').format(variable.name)) + leader_space.variable = [] + leader_space.name = leader_name + leader_space.hidden = variable.hidden + variable.hidden = None + if hasattr(group, 'description'): + leader_space.doc = group.description + else: + leader_space.doc = variable.description + leader_path = namespace + '.' + leader_family_name + '.' + leader_name + self.paths.add_family(namespace, + leader_path, + leader_space, + ) + leader_family = self.space.variables[namespace].family[leader_family_name] + leader_family.variable[leader_name] = leader_space + leader_space.variable.append(variable) + self.paths.set_leader(namespace, + leader_family_name, + leader_name, + leader_name, + ) + leader_space.path = leader_fullname + + + def manage_slave(self, + namespace: str, + leader_family_name: str, + variable: 'Variable', + leader_name: str, + follower_names: List[str], + leader_space: 'Leadership', + ) -> None: + if variable.name != follower_names[0]: + raise CreoleDictConsistencyError(_('cannot found this follower {}').format(follower_names[0])) + follower_names.remove(variable.name) + # followers are multi + if not variable.multi: + raise CreoleDictConsistencyError(_('the variable {} in a group must be multi or submulti').format(variable.name)) + leader_space.variable.append(variable) # pylint: disable=E1101 + self.paths.set_leader(namespace, + leader_family_name, + variable.name, + leader_name, + ) + def convert_groups(self): # pylint: disable=C0111 - if hasattr(self.space, 'constraints'): - if hasattr(self.space.constraints, 'group'): - for group in self.space.constraints.group: - leader_fullname = group.master - follower_names = list(group.slave.keys()) - leader_family_name = self.paths.get_variable_family_name(leader_fullname) - namespace = self.paths.get_variable_namespace(leader_fullname) - leader_name = self.paths.get_variable_name(leader_fullname) - leader_family = self.space.variables[namespace].family[leader_family_name] - leader_path = namespace + '.' + leader_family_name - is_leader = False - for variable in list(leader_family.variable.values()): - if isinstance(variable, self.objectspace.Leadership): - # append follower to an existed leadership - if variable.name == leader_name: - leader_space = variable - is_leader = True - else: - if is_leader: - if variable.name == follower_names[0]: - # followers are multi - if not variable.multi: - raise CreoleDictConsistencyError(_('the variable {} in a group must be multi or submulti').format(variable.name)) - follower_names.remove(variable.name) - leader_family.variable.pop(variable.name) - leader_space.variable.append(variable) # pylint: disable=E1101 - if namespace == 'creole': - variable_fullpath = variable.name - else: - variable_fullpath = leader_path + '.' + variable.name - self.paths.set_leader(variable_fullpath, leader_name) - if follower_names == []: - break - else: - raise CreoleDictConsistencyError(_('cannot found this follower {}').format(follower_names[0])) - if is_leader is False and variable.name == leader_name: - leader_space = self.objectspace.Leadership() - leader_space.variable = [] - leader_space.name = leader_name - leader_space.hidden = variable.hidden - if hasattr(group, 'description'): - leader_space.doc = group.description - else: - leader_space.doc = variable.description - variable.hidden = None - self.paths.append('family', leader_path + '.' + leader_name, namespace, creoleobj=leader_space) - # manage leader's variable - if variable.multi is not True: - raise CreoleDictConsistencyError(_('the variable {} in a group must be multi').format(variable.name)) - leader_family.variable[leader_name] = leader_space - leader_space.variable.append(variable) # pylint: disable=E1101 - self.paths.set_leader(leader_fullname, leader_name) - leader_space.path = leader_fullname - is_leader = True + if hasattr(self.space, 'constraints') and hasattr(self.space.constraints, 'group'): + for group in self.space.constraints.group: + leader_fullname = group.master + follower_names = list(group.slave.keys()) + leader_family_name = self.paths.get_variable_family_name(leader_fullname) + namespace = self.paths.get_variable_namespace(leader_fullname) + leader_name = self.paths.get_variable_name(leader_fullname) + ori_leader_family = self.space.variables[namespace].family[leader_family_name] + has_a_leader = False + for variable in list(ori_leader_family.variable.values()): + if isinstance(variable, self.objectspace.Leadership): + # append follower to an existed leadership + if variable.name == leader_name: + leader_space = variable + has_a_leader = True else: - raise CreoleDictConsistencyError(_('cannot found followers {}').format(follower_names)) - del self.space.constraints.group + if has_a_leader: + # it's a slave + self.manage_slave(namespace, + leader_family_name, + variable, + leader_name, + follower_names, + leader_space, + ) + ori_leader_family.variable.pop(variable.name) + if follower_names == []: + # no more slave + break + elif variable.name == leader_name: + # it's a leader + leader_space = self.objectspace.Leadership() + self.manage_leader(leader_space, + leader_family_name, + leader_name, + namespace, + variable, + group, + leader_fullname, + ) + has_a_leader = True + else: + raise CreoleDictConsistencyError(_('cannot found followers {}').format(follower_names)) + del self.space.constraints.group def remove_empty_families(self): # pylint: disable=C0111,R0201 if hasattr(self.space, 'variables'): diff --git a/src/rougail/objspace.py b/src/rougail/objspace.py index 75d30dbb..306be9fd 100644 --- a/src/rougail/objspace.py +++ b/src/rougail/objspace.py @@ -194,7 +194,11 @@ class CreoleObjSpace(object): if 'variable' not in vars(family): family.variable = OrderedDict() family.variable[name] = variable_obj - self.paths.append('variable', name, namespace, family.name, variable_obj) + self.paths.add_variable(namespace, + name, + family.name, + variable_obj, + ) return variable_obj def remove_check(self, name): # pylint: disable=C0111 @@ -425,8 +429,10 @@ class CreoleObjSpace(object): if not isinstance(space, self.help): # pylint: disable=E1101 if child.tag == 'variable': family_name = normalize_family(document.attrib['name']) - self.paths.append('variable', child.attrib['name'], namespace, family_name, - creoleobj) + self.paths.add_variable(namespace, + child.attrib['name'], + family_name, + creoleobj) if child.attrib.get('redefine', 'False') == 'True': if namespace == 'creole': self.redefine_variables.append(child.attrib['name']) @@ -438,7 +444,10 @@ class CreoleObjSpace(object): family_name = normalize_family(child.attrib['name']) if namespace != 'creole': family_name = namespace + '.' + family_name - self.paths.append('family', family_name, namespace, creoleobj=creoleobj) + self.paths.add_family(namespace, + family_name, + creoleobj, + ) creoleobj.path = self.paths.get_family_path(family_name, namespace) def create_or_populate_from_xml(self, namespace, xmlfolders, from_zephir=None): @@ -575,7 +584,7 @@ class CreoleObjSpace(object): self._sub_xml_export(name, node, node_name, subspace, space) -class Path(object): +class Path: """Helper class to handle the `path` attribute of a CreoleObjSpace instance. @@ -585,28 +594,27 @@ class Path(object): self.variables = {} self.families = {} - def append(self, pathtype, name, namespace, family=None, creoleobj=None): # pylint: disable=C0111 - if pathtype == 'family': - self.families[name] = dict(name=name, namespace=namespace, creoleobj=creoleobj) - elif pathtype == 'variable': - if namespace == 'creole': - varname = name - else: - if '.' in name: - varname = name - else: - varname = '.'.join([namespace, family, name]) - self.variables[varname] = dict(name=name, family=family, namespace=namespace, - leader=None, creoleobj=creoleobj) - else: # pragma: no cover - raise Exception('unknown pathtype {}'.format(pathtype)) + # Family + def add_family(self, + namespace: str, + name: str, + creoleobj: str, + ) -> str: # pylint: disable=C0111 + self.families[name] = dict(name=name, + namespace=namespace, + creoleobj=creoleobj, + ) - def get_family_path(self, name, current_namespace): # pylint: disable=C0111 + def get_family_path(self, + name: str, + current_namespace: str, + ) -> str: # pylint: disable=C0111 if current_namespace is None: # pragma: no cover raise CreoleOperationError('current_namespace must not be None') dico = self.families[normalize_family(name, check_name=False, - allow_dot=True)] + allow_dot=True, + )] if dico['namespace'] != 'creole' and current_namespace != dico['namespace']: raise CreoleDictConsistencyError(_('A family located in the {} namespace ' 'shall not be used in the {} namespace').format( @@ -616,41 +624,100 @@ class Path(object): path = '.'.join([dico['namespace'], path]) return path - def get_family_namespace(self, name): # pylint: disable=C0111 + def get_family_namespace(self, + name: str, + ) -> str: # pylint: disable=C0111 dico = self.families[name] if dico['namespace'] is None: return dico['name'] return dico['namespace'] - def get_family_obj(self, name): # pylint: disable=C0111 + def get_family_obj(self, + name: str, + ) -> 'Family': # pylint: disable=C0111 if name not in self.families: raise CreoleDictConsistencyError(_('unknown family {}').format(name)) dico = self.families[name] return dico['creoleobj'] - def get_variable_name(self, name): # pylint: disable=C0111 + # Leadership + def set_leader(self, + namespace: str, + leader_family_name: str, + name: str, + leader_name: str, + ) -> None: # pylint: disable=C0111 + if namespace != 'creole': + # need rebuild path and move object in new path + old_path = namespace + '.' + leader_family_name + '.' + name + dico = self._get_variable(old_path) + del self.variables[old_path] + new_path = namespace + '.' + leader_family_name + '.' + leader_name + '.' + name + self.add_variable(namespace, + new_path, + family=dico['family'], + creoleobj=dico['creoleobj']) + name = new_path dico = self._get_variable(name) - return dico['name'] + if dico['leader'] != None: + raise CreoleDictConsistencyError(_('Already defined leader {} for variable' + ' {}'.format(dico['leader'], name))) + dico['leader'] = leader_name - def get_variable_obj(self, name): # pylint: disable=C0111 - dico = self._get_variable(name) - return dico['creoleobj'] + def get_leader(self, name): # pylint: disable=C0111 + return self._get_variable(name)['leader'] - def get_variable_family_name(self, name): # pylint: disable=C0111 - dico = self._get_variable(name) - return dico['family'] + # Variable + def add_variable(self, + namespace: str, + name: str, + family: str=None, + creoleobj=None, + ) -> str: # pylint: disable=C0111 + if namespace == 'creole' or '.' in name: + varname = name + else: + varname = '.'.join([namespace, family, name]) + self.variables[varname] = dict(name=name, + family=family, + namespace=namespace, + leader=None, + creoleobj=creoleobj) - def get_variable_family_path(self, name): # pylint: disable=C0111 + def get_variable_name(self, + name, + ): # pylint: disable=C0111 + return self._get_variable(name)['name'] + + def get_variable_obj(self, + name:str, + ) -> 'Variable': # pylint: disable=C0111 + return self._get_variable(name)['creoleobj'] + + def get_variable_family_name(self, + name: str, + ) -> str: # pylint: disable=C0111 + return self._get_variable(name)['family'] + + def get_variable_family_path(self, + name: str, + ) -> str: # pylint: disable=C0111 dico = self._get_variable(name) list_path = [dico['namespace'], dico['family']] if dico['leader'] is not None: list_path.append(dico['leader']) return '.'.join(list_path) - def get_variable_namespace(self, name): # pylint: disable=C0111 + def get_variable_namespace(self, + name: str, + ) -> str: # pylint: disable=C0111 return self._get_variable(name)['namespace'] - def get_variable_path(self, name, current_namespace, allow_source=False): # pylint: disable=C0111 + def get_variable_path(self, + name: str, + current_namespace: str, + allow_source: str=False, + ) -> str: # pylint: disable=C0111 if current_namespace is None: # pragma: no cover raise CreoleOperationError('current_namespace must not be None') dico = self._get_variable(name) @@ -667,30 +734,17 @@ class Path(object): list_path.append(dico['name']) return '.'.join(list_path) - def path_is_defined(self, name): # pylint: disable=C0111 + def path_is_defined(self, + name: str, + ) -> str: # pylint: disable=C0111 return name in self.variables - def set_leader(self, name, leader): # pylint: disable=C0111 - dico = self._get_variable(name) - namespace = dico['namespace'] - if dico['leader'] != None: - raise CreoleDictConsistencyError(_('Already defined leader {} for variable' - ' {}'.format(dico['leader'], name))) - dico['leader'] = leader - if namespace != 'creole': - new_path = self.get_variable_path(name, namespace) - self.append('variable', new_path, namespace, family=dico['family'], creoleobj=dico['creoleobj']) - self.variables[new_path]['leader'] = leader - del self.variables[name] - - def _get_variable(self, name): + def _get_variable(self, + name: str, + ) -> str: if name not in self.variables: if name.startswith('creole.'): name = name.split('.')[-1] if name not in self.variables: raise CreoleDictConsistencyError(_('unknown option {}').format(name)) return self.variables[name] - - def get_leader(self, name): # pylint: disable=C0111 - dico = self._get_variable(name) - return dico['leader'] From 1cd8873e5bf84a6249508c73ad869b6999dd4636 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sat, 11 Apr 2020 20:45:28 +0200 Subject: [PATCH 03/32] add fill/auto with dynamic option --- src/rougail/annotator.py | 7 ++- src/rougail/loader.py | 19 +++++-- src/rougail/objspace.py | 52 ++++++++++++++----- .../20family_dynamic_calc/00-base.xml | 25 +++++++++ .../20family_dynamic_calc/makedict/base.json | 1 + .../20family_dynamic_calc/result/00-base.xml | 31 +++++++++++ 6 files changed, 118 insertions(+), 17 deletions(-) create mode 100644 tests/flattener_dicos/20family_dynamic_calc/00-base.xml create mode 100644 tests/flattener_dicos/20family_dynamic_calc/makedict/base.json create mode 100644 tests/flattener_dicos/20family_dynamic_calc/result/00-base.xml diff --git a/src/rougail/annotator.py b/src/rougail/annotator.py index 7e2bfacc..a38a94f2 100644 --- a/src/rougail/annotator.py +++ b/src/rougail/annotator.py @@ -237,6 +237,7 @@ class ServiceAnnotator: self.paths.add_variable('services', path, 'service', + False, variable, ) return variable @@ -1116,7 +1117,11 @@ class SpaceAnnotator(object): # if param.optional is True: # param_option_indexes.append(fill_idx) try: - param.text = self.paths.get_variable_path(param.text, namespace) + param.text, suffix = self.paths.get_variable_path(param.text, + namespace, + with_suffix=True) + if suffix: + param.suffix = suffix except CreoleDictConsistencyError as err: if param.optional is True: param_option_indexes.append(fill_idx) diff --git a/src/rougail/loader.py b/src/rougail/loader.py index b6637b2f..097a4360 100644 --- a/src/rougail/loader.py +++ b/src/rougail/loader.py @@ -11,7 +11,7 @@ from tiramisu import (StrOption, OptionDescription, DynOptionDescription, PortOp NetworkOption, NetmaskOption, DomainnameOption, BroadcastOption, URLOption, EmailOption, FilenameOption, UsernameOption, DateOption, PasswordOption, BoolOption, MACOption, Leadership, submulti, - Params, ParamSelfOption, ParamOption, ParamValue, Calculation, calc_value, + Params, ParamSelfOption, ParamOption, ParamDynOption, ParamValue, Calculation, calc_value, groups, owners) from tiramisu.error import ConfigError @@ -431,7 +431,7 @@ class Variable(Common): transitive = False else: raise CreoleLoaderError(_('unknown transitive boolean {}').format(transitive)) - value = [param.text, transitive] + value = [param.text, transitive, param.attrib.get('suffix')] elif param.attrib['type'] == 'number': value = int(param.text) else: @@ -462,10 +462,21 @@ class Variable(Common): if len(value) == 3: for param in value[1]: if isinstance(param[1], list): + option = self.storage.get(param[1][0]).get() + param_kwargs = {'notraisepropertyerror': param[1][1]} if value[0] in FUNC_TO_DICT: - param_value = ParamOption(self.storage.get(param[1][0]).get(), notraisepropertyerror=param[1][1], todict=True) + param_kwargs['todict'] = True + if not param[1][2]: + param_value = ParamOption(option, + **param_kwargs, + ) else: - param_value = ParamOption(self.storage.get(param[1][0]).get(), notraisepropertyerror=param[1][1]) + family = '.'.join(param[1][0].split('.', 3)[:2]) + param_value = ParamDynOption(option, + param[1][2], + self.storage.get(family).get(), + **param_kwargs, + ) else: param_value = ParamValue(param[1]) if not param[0]: diff --git a/src/rougail/objspace.py b/src/rougail/objspace.py index 306be9fd..284ec2a7 100644 --- a/src/rougail/objspace.py +++ b/src/rougail/objspace.py @@ -197,6 +197,7 @@ class CreoleObjSpace(object): self.paths.add_variable(namespace, name, family.name, + False, variable_obj, ) return variable_obj @@ -423,7 +424,13 @@ class CreoleObjSpace(object): if list(child) != []: self.xml_parse_document(child, creoleobj, namespace, is_in_family) - def _fill_creoleobj_path_attribute(self, space, child, namespace, document, creoleobj): # pylint: disable=R0913 + def _fill_creoleobj_path_attribute(self, + space, + child, + namespace, + document, + creoleobj, + ): # pylint: disable=R0913 """Fill self.paths attributes """ if not isinstance(space, self.help): # pylint: disable=E1101 @@ -432,6 +439,7 @@ class CreoleObjSpace(object): self.paths.add_variable(namespace, child.attrib['name'], family_name, + document.attrib.get('dynamic') != None, creoleobj) if child.attrib.get('redefine', 'False') == 'True': if namespace == 'creole': @@ -655,8 +663,10 @@ class Path: new_path = namespace + '.' + leader_family_name + '.' + leader_name + '.' + name self.add_variable(namespace, new_path, - family=dico['family'], - creoleobj=dico['creoleobj']) + dico['family'], + False, + dico['creoleobj'], + ) name = new_path dico = self._get_variable(name) if dico['leader'] != None: @@ -671,8 +681,9 @@ class Path: def add_variable(self, namespace: str, name: str, - family: str=None, - creoleobj=None, + family: str, + is_dynamic: bool, + creoleobj, ) -> str: # pylint: disable=C0111 if namespace == 'creole' or '.' in name: varname = name @@ -682,6 +693,7 @@ class Path: family=family, namespace=namespace, leader=None, + is_dynamic=is_dynamic, creoleobj=creoleobj) def get_variable_name(self, @@ -717,22 +729,32 @@ class Path: name: str, current_namespace: str, allow_source: str=False, + with_suffix: bool=False, ) -> str: # pylint: disable=C0111 if current_namespace is None: # pragma: no cover raise CreoleOperationError('current_namespace must not be None') - dico = self._get_variable(name) + if with_suffix: + dico, suffix = self._get_variable(name, + with_suffix=True, + ) + else: + dico = self._get_variable(name) if not allow_source: if dico['namespace'] not in ['creole', 'services'] and current_namespace != dico['namespace']: raise CreoleDictConsistencyError(_('A variable located in the {} namespace ' 'shall not be used in the {} namespace').format( dico['namespace'], current_namespace)) if '.' in dico['name']: - return dico['name'] - list_path = [dico['namespace'], dico['family']] - if dico['leader'] is not None: - list_path.append(dico['leader']) - list_path.append(dico['name']) - return '.'.join(list_path) + value = dico['name'] + else: + list_path = [dico['namespace'], dico['family']] + if dico['leader'] is not None: + list_path.append(dico['leader']) + list_path.append(dico['name']) + value = '.'.join(list_path) + if with_suffix: + return value, suffix + return value def path_is_defined(self, name: str, @@ -741,10 +763,16 @@ class Path: def _get_variable(self, name: str, + with_suffix: bool=False, ) -> str: if name not in self.variables: if name.startswith('creole.'): name = name.split('.')[-1] if name not in self.variables: + for var_name, variable in self.variables.items(): + if variable['is_dynamic'] and name.startswith(var_name): + return variable, name[len(var_name):] raise CreoleDictConsistencyError(_('unknown option {}').format(name)) + if with_suffix: + return self.variables[name], None return self.variables[name] diff --git a/tests/flattener_dicos/20family_dynamic_calc/00-base.xml b/tests/flattener_dicos/20family_dynamic_calc/00-base.xml new file mode 100644 index 00000000..7fa2ca78 --- /dev/null +++ b/tests/flattener_dicos/20family_dynamic_calc/00-base.xml @@ -0,0 +1,25 @@ + + + + + + + val1 + val2 + + + + + val + + + + + + + + + vardynval1 + + + diff --git a/tests/flattener_dicos/20family_dynamic_calc/makedict/base.json b/tests/flattener_dicos/20family_dynamic_calc/makedict/base.json new file mode 100644 index 00000000..0f79db59 --- /dev/null +++ b/tests/flattener_dicos/20family_dynamic_calc/makedict/base.json @@ -0,0 +1 @@ +{"creole.general.varname": ["val1", "val2"], "creole.dynval1.vardynval1": "val", "creole.dynval2.vardynval2": "val", "creole.new.newvar": null} diff --git a/tests/flattener_dicos/20family_dynamic_calc/result/00-base.xml b/tests/flattener_dicos/20family_dynamic_calc/result/00-base.xml new file mode 100644 index 00000000..ed8c4a24 --- /dev/null +++ b/tests/flattener_dicos/20family_dynamic_calc/result/00-base.xml @@ -0,0 +1,31 @@ + + + + + normal + + mandatory + normal + val1 + val2 + + + + normal + + mandatory + normal + val + + + + normal + + normal + + creole.dyn.vardyn + + + + + From 308e980bfd8ede51a09d8ff124bb8b4e780c3f35 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sat, 18 Apr 2020 09:00:03 +0200 Subject: [PATCH 04/32] master/slave => leader/follower --- src/rougail/annotator.py | 12 ++--- src/rougail/data/rougail.dtd | 8 +-- src/rougail/objspace.py | 4 +- src/rougail/template.py | 54 +++++++++---------- .../10load_masterslaves/00-base.xml | 18 +++---- .../10load_masterslaves/makedict/base.json | 2 +- .../10load_masterslaves/result/00-base.xml | 10 ++-- .../00-base.xml | 14 ++--- .../makedict/base.json | 2 +- .../result/00-base.xml | 10 ++-- .../00-base.xml | 14 ++--- .../makedict/base.json | 2 +- .../result/00-base.xml | 10 ++-- .../00-base.xml | 18 +++---- .../makedict/base.json | 2 +- .../result/00-base.xml | 10 ++-- .../00-base.xml | 12 ++--- .../01-base.xml | 2 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 8 +-- .../10masterslave_autosaveexpert/00-base.xml | 18 +++---- .../makedict/base.json | 2 +- .../result/00-base.xml | 10 ++-- .../10masterslave_mandatory/00-base.xml | 18 +++---- .../makedict/base.json | 2 +- .../result/00-base.xml | 10 ++-- .../10masterslave_mandatoryslave/00-base.xml | 4 +- .../10masterslave_mastermandatory/00-base.xml | 18 +++---- .../makedict/base.json | 2 +- .../result/00-base.xml | 10 ++-- .../10masterslave_multi/00-base.xml | 30 +++++------ .../10masterslave_multi/makedict/base.json | 2 +- .../10masterslave_multi/result/00-base.xml | 18 +++---- .../10masterslaves_append/00-base.xml | 18 +++---- .../10masterslaves_append/01-base.xml | 6 +-- .../10masterslaves_append/makedict/base.json | 2 +- .../10masterslaves_append/result/00-base.xml | 12 ++--- .../10masterslaves_auto/00-base.xml | 26 ++++----- .../10masterslaves_auto/makedict/base.json | 2 +- .../10masterslaves_auto/result/00-base.xml | 14 ++--- .../10masterslaves_automaster/00-base.xml | 18 +++---- .../makedict/base.json | 2 +- .../result/00-base.xml | 10 ++-- .../00-base.xml | 16 +++--- .../result/00-base.xml | 10 ++-- .../10masterslaves_familyaccent/00-base.xml | 18 +++---- .../makedict/base.json | 2 +- .../result/00-base.xml | 10 ++-- .../10valid_enum_master/00-base.xml | 14 ++--- .../10valid_enum_master/makedict/base.json | 2 +- .../10valid_enum_master/result/00-base.xml | 8 +-- .../20family_modemasterslaves/00-base.xml | 12 ++--- .../makedict/base.json | 2 +- .../result/00-base.xml | 8 +-- .../40ifin_masterslaves/00-base.xml | 14 ++--- .../40ifin_masterslaves/makedict/base.json | 2 +- .../40ifin_masterslaves/result/00-base.xml | 8 +-- .../40ifin_masterslavesauto/00-base.xml | 16 +++--- .../makedict/base.json | 2 +- .../result/00-base.xml | 8 +-- .../extra_dirs/extra/00-base.xml | 4 +- .../00-base.xml | 4 +- .../80condition_itself/00-base.xml | 2 +- .../80family_several/00-base.xml | 18 +++---- .../00-base.xml | 18 +++---- .../80leadership_not_ordered/00-base.xml | 18 +++---- .../80leadership_not_same_family/00-base.xml | 18 +++---- .../80leadership_notmulti2/00-base.xml | 18 +++---- .../80masterslave_auto_save/00-base.xml | 18 +++---- .../80masterslave_notexists/00-base.xml | 24 ++++----- .../80masterslaves_autofreeze/00-base.xml | 18 +++---- .../80masterslaves_notmulti/00-base.xml | 18 +++---- 72 files changed, 399 insertions(+), 399 deletions(-) diff --git a/src/rougail/annotator.py b/src/rougail/annotator.py index a38a94f2..0c0e6185 100644 --- a/src/rougail/annotator.py +++ b/src/rougail/annotator.py @@ -488,7 +488,7 @@ class SpaceAnnotator(object): leader_space.path = leader_fullname - def manage_slave(self, + def manage_follower(self, namespace: str, leader_family_name: str, variable: 'Variable', @@ -512,8 +512,8 @@ class SpaceAnnotator(object): def convert_groups(self): # pylint: disable=C0111 if hasattr(self.space, 'constraints') and hasattr(self.space.constraints, 'group'): for group in self.space.constraints.group: - leader_fullname = group.master - follower_names = list(group.slave.keys()) + leader_fullname = group.leader + follower_names = list(group.follower.keys()) leader_family_name = self.paths.get_variable_family_name(leader_fullname) namespace = self.paths.get_variable_namespace(leader_fullname) leader_name = self.paths.get_variable_name(leader_fullname) @@ -527,8 +527,8 @@ class SpaceAnnotator(object): has_a_leader = True else: if has_a_leader: - # it's a slave - self.manage_slave(namespace, + # it's a follower + self.manage_follower(namespace, leader_family_name, variable, leader_name, @@ -537,7 +537,7 @@ class SpaceAnnotator(object): ) ori_leader_family.variable.pop(variable.name) if follower_names == []: - # no more slave + # no more follower break elif variable.name == leader_name: # it's a leader diff --git a/src/rougail/data/rougail.dtd b/src/rougail/data/rougail.dtd index 22495198..df054016 100644 --- a/src/rougail/data/rougail.dtd +++ b/src/rougail/data/rougail.dtd @@ -13,7 +13,7 @@ # Forked by: # Cadoles (http://www.cadoles.com) -# Copyright (C) 2019 +# Copyright (C) 2019-2020 # distribued with GPL-2 or later license @@ -172,8 +172,8 @@ - - + + @@ -186,6 +186,6 @@ - + diff --git a/src/rougail/objspace.py b/src/rougail/objspace.py index 284ec2a7..4654e3b7 100644 --- a/src/rougail/objspace.py +++ b/src/rougail/objspace.py @@ -34,8 +34,8 @@ from .annotator import ERASED_ATTRIBUTES, ActionAnnotator, ServiceAnnotator, Spa from .utils import normalize_family from .error import CreoleOperationError, SpaceObjShallNotBeUpdated, CreoleDictConsistencyError -# CreoleObjSpace's elements like 'family' or 'slave', that shall be forced to the Redefinable type -FORCE_REDEFINABLES = ('family', 'slave', 'service', 'disknod', 'variables', 'family_action') +# CreoleObjSpace's elements like 'family' or 'follower', that shall be forced to the Redefinable type +FORCE_REDEFINABLES = ('family', 'follower', 'service', 'disknod', 'variables', 'family_action') # CreoleObjSpace's elements that shall be forced to the UnRedefinable type FORCE_UNREDEFINABLES = ('value', 'input', 'profile', 'ewtapp', 'tag', 'saltaction') # CreoleObjSpace's elements that shall be set to the UnRedefinable type diff --git a/src/rougail/template.py b/src/rougail/template.py index 1a933da8..928e7f70 100644 --- a/src/rougail/template.py +++ b/src/rougail/template.py @@ -59,11 +59,11 @@ class IsDefined: if '.' in varname: splitted_var = varname.split('.') if len(splitted_var) != 2: - msg = _("Group variables must be of type master.slave") + msg = _("Group variables must be of type leader.follower") raise KeyError(msg) - master, slave = splitted_var - if master in self.context: - return slave in self.context[master].slave.keys() + leader, follower = splitted_var + if leader in self.context: + return follower in self.context[leader].follower.keys() return False else: return varname in self.context @@ -133,7 +133,7 @@ class CheetahTemplate(ChtTemplate): class CreoleLeader: - def __init__(self, value, slave=None, index=None): + def __init__(self, value, follower=None, index=None): """ On rend la variable itérable pour pouvoir faire: for ip in iplist: @@ -143,20 +143,20 @@ class CreoleLeader: index is used for CreoleLint """ self._value = value - if slave is not None: - self.slave = slave + if follower is not None: + self.follower = follower else: - self.slave = {} + self.follower = {} self._index = index def __getattr__(self, name): - """Get slave variable or attribute of master value. + """Get follower variable or attribute of leader value. - If the attribute is a name of a slave variable, return its value. - Otherwise, returns the requested attribute of master value. + If the attribute is a name of a follower variable, return its value. + Otherwise, returns the requested attribute of leader value. """ - if name in self.slave: - value = self.slave[name] + if name in self.follower: + value = self.follower[name] if isinstance(value, PropertiesOptionError): raise AttributeError() return value @@ -164,36 +164,36 @@ class CreoleLeader: return getattr(self._value, name) def __getitem__(self, index): - """Get a master.slave at requested index. + """Get a leader.follower at requested index. """ ret = {} - for key, values in self.slave.items(): + for key, values in self.follower.items(): ret[key] = values[index] return CreoleLeader(self._value[index], ret, index) def __iter__(self): - """Iterate over master.slave. + """Iterate over leader.follower. - Return synchronised value of master.slave. + Return synchronised value of leader.follower. """ for i in range(len(self._value)): ret = {} - for key, values in self.slave.items(): + for key, values in self.follower.items(): ret[key] = values[i] yield CreoleLeader(self._value[i], ret, i) def __len__(self): - """Delegate to master value + """Delegate to leader value """ return len(self._value) def __repr__(self): """Show CreoleLeader as dictionary. - The master value is stored under 'value' key. - The slaves are stored under 'slave' key. + The leader value is stored under 'value' key. + The followers are stored under 'follower' key. """ - return repr({'value': self._value, 'slave': self.slave}) + return repr({'value': self._value, 'follower': self.follower}) def __eq__(self, value): return value == self._value @@ -214,7 +214,7 @@ class CreoleLeader: return self._value >= value def __str__(self): - """Delegate to master value + """Delegate to leader value """ return str(self._value) @@ -227,7 +227,7 @@ class CreoleLeader: def __contains__(self, item): return item in self._value - async def add_slave(self, config, name, path): + async def add_follower(self, config, name, path): if isinstance(self._value, list): values = [] for idx in range(len(self._value)): @@ -237,7 +237,7 @@ class CreoleLeader: values.append(err) else: raise Exception('hu?') - self.slave[name] = values + self.follower[name] = values class CreoleExtra: @@ -285,7 +285,7 @@ class CreoleTemplateEngine: leader = CreoleLeader(await suboption.value.get()) self.creole_variables_dict[await suboption.option.name()] = leader else: - await leader.add_slave(self.config, + await leader.add_follower(self.config, await suboption.option.name(), await suboption.option.path()) else: @@ -306,7 +306,7 @@ class CreoleTemplateEngine: leader = CreoleLeader(await suboption.value.get()) leader_name = await suboption.option.name() else: - await leader.add_slave(self.config, + await leader.add_follower(self.config, await suboption.option.name(), await suboption.option.path()) variables[leader_name] = leader diff --git a/tests/flattener_dicos/10load_masterslaves/00-base.xml b/tests/flattener_dicos/10load_masterslaves/00-base.xml index 20128fd6..f9a78f67 100644 --- a/tests/flattener_dicos/10load_masterslaves/00-base.xml +++ b/tests/flattener_dicos/10load_masterslaves/00-base.xml @@ -10,22 +10,22 @@ - - - + + + - + valfill - - slave1 + + follower1 - - slave1 - slave2 + + follower1 + follower2 diff --git a/tests/flattener_dicos/10load_masterslaves/makedict/base.json b/tests/flattener_dicos/10load_masterslaves/makedict/base.json index d80c04f0..7637dca2 100644 --- a/tests/flattener_dicos/10load_masterslaves/makedict/base.json +++ b/tests/flattener_dicos/10load_masterslaves/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif": "non", "creole.general1.master.master": [], "creole.general1.master.slave1": [], "creole.general1.master.slave2": []} +{"creole.general.mode_conteneur_actif": "non", "creole.general1.leader.leader": [], "creole.general1.leader.follower1": [], "creole.general1.leader.follower2": []} diff --git a/tests/flattener_dicos/10load_masterslaves/result/00-base.xml b/tests/flattener_dicos/10load_masterslaves/result/00-base.xml index ae3075fe..2c2cf4dc 100644 --- a/tests/flattener_dicos/10load_masterslaves/result/00-base.xml +++ b/tests/flattener_dicos/10load_masterslaves/result/00-base.xml @@ -13,19 +13,19 @@ normal - + normal - - + + normal valfill - + normal - creole.general1.master.slave1 + creole.general1.leader.follower1 diff --git a/tests/flattener_dicos/10load_masterslaves_default_multi/00-base.xml b/tests/flattener_dicos/10load_masterslaves_default_multi/00-base.xml index 7026f0e2..e57a95af 100644 --- a/tests/flattener_dicos/10load_masterslaves_default_multi/00-base.xml +++ b/tests/flattener_dicos/10load_masterslaves_default_multi/00-base.xml @@ -5,21 +5,21 @@ - + non - - + + value - + - - slave1 - slave2 + + follower1 + follower2 diff --git a/tests/flattener_dicos/10load_masterslaves_default_multi/makedict/base.json b/tests/flattener_dicos/10load_masterslaves_default_multi/makedict/base.json index d3f6f01a..ccd15703 100644 --- a/tests/flattener_dicos/10load_masterslaves_default_multi/makedict/base.json +++ b/tests/flattener_dicos/10load_masterslaves_default_multi/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif": ["non"], "creole.general.master.master": [], "creole.general.master.slave1": [], "creole.general.master.slave2": []} +{"creole.general.mode_conteneur_actif": ["non"], "creole.general.leader.leader": [], "creole.general.leader.follower1": [], "creole.general.leader.follower2": []} diff --git a/tests/flattener_dicos/10load_masterslaves_default_multi/result/00-base.xml b/tests/flattener_dicos/10load_masterslaves_default_multi/result/00-base.xml index 88111892..a5da75c8 100644 --- a/tests/flattener_dicos/10load_masterslaves_default_multi/result/00-base.xml +++ b/tests/flattener_dicos/10load_masterslaves_default_multi/result/00-base.xml @@ -3,22 +3,22 @@ normal - + oui non mandatory normal non - + normal - - + + mandatory normal value - + normal diff --git a/tests/flattener_dicos/10load_masterslaves_defaultmulti_master/00-base.xml b/tests/flattener_dicos/10load_masterslaves_defaultmulti_master/00-base.xml index 561a6500..8f25b8c7 100644 --- a/tests/flattener_dicos/10load_masterslaves_defaultmulti_master/00-base.xml +++ b/tests/flattener_dicos/10load_masterslaves_defaultmulti_master/00-base.xml @@ -5,21 +5,21 @@ - + non - + value - - + + - - slave1 - slave2 + + follower1 + follower2 diff --git a/tests/flattener_dicos/10load_masterslaves_defaultmulti_master/makedict/base.json b/tests/flattener_dicos/10load_masterslaves_defaultmulti_master/makedict/base.json index 044ad1ee..4efe2c93 100644 --- a/tests/flattener_dicos/10load_masterslaves_defaultmulti_master/makedict/base.json +++ b/tests/flattener_dicos/10load_masterslaves_defaultmulti_master/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif": ["non"], "creole.general.master.master": ["value"], "creole.general.master.slave1": [null], "creole.general.master.slave2": [null]} +{"creole.general.mode_conteneur_actif": ["non"], "creole.general.leader.leader": ["value"], "creole.general.leader.follower1": [null], "creole.general.leader.follower2": [null]} diff --git a/tests/flattener_dicos/10load_masterslaves_defaultmulti_master/result/00-base.xml b/tests/flattener_dicos/10load_masterslaves_defaultmulti_master/result/00-base.xml index 2108d613..cd29e940 100644 --- a/tests/flattener_dicos/10load_masterslaves_defaultmulti_master/result/00-base.xml +++ b/tests/flattener_dicos/10load_masterslaves_defaultmulti_master/result/00-base.xml @@ -3,23 +3,23 @@ normal - + oui non mandatory normal non - + normal - + mandatory value - + normal - + normal diff --git a/tests/flattener_dicos/10load_masterslaves_description/00-base.xml b/tests/flattener_dicos/10load_masterslaves_description/00-base.xml index 04b81b7f..f75f067c 100644 --- a/tests/flattener_dicos/10load_masterslaves_description/00-base.xml +++ b/tests/flattener_dicos/10load_masterslaves_description/00-base.xml @@ -7,21 +7,21 @@ - - - + + + - + valfill - - slave1 + + follower1 - - slave1 - slave2 + + follower1 + follower2 diff --git a/tests/flattener_dicos/10load_masterslaves_description/makedict/base.json b/tests/flattener_dicos/10load_masterslaves_description/makedict/base.json index d80c04f0..7637dca2 100644 --- a/tests/flattener_dicos/10load_masterslaves_description/makedict/base.json +++ b/tests/flattener_dicos/10load_masterslaves_description/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif": "non", "creole.general1.master.master": [], "creole.general1.master.slave1": [], "creole.general1.master.slave2": []} +{"creole.general.mode_conteneur_actif": "non", "creole.general1.leader.leader": [], "creole.general1.leader.follower1": [], "creole.general1.leader.follower2": []} diff --git a/tests/flattener_dicos/10load_masterslaves_description/result/00-base.xml b/tests/flattener_dicos/10load_masterslaves_description/result/00-base.xml index b17a5b5a..a78ab551 100644 --- a/tests/flattener_dicos/10load_masterslaves_description/result/00-base.xml +++ b/tests/flattener_dicos/10load_masterslaves_description/result/00-base.xml @@ -13,19 +13,19 @@ normal - + normal - - + + normal valfill - + normal - creole.general1.master.slave1 + creole.general1.leader.follower1 diff --git a/tests/flattener_dicos/10load_masterslaves_normalize_family/00-base.xml b/tests/flattener_dicos/10load_masterslaves_normalize_family/00-base.xml index e80c2fd7..98041c11 100644 --- a/tests/flattener_dicos/10load_masterslaves_normalize_family/00-base.xml +++ b/tests/flattener_dicos/10load_masterslaves_normalize_family/00-base.xml @@ -10,16 +10,16 @@ - - - + + + - - slave1 - slave2 + + follower1 + follower2 diff --git a/tests/flattener_dicos/10load_masterslaves_normalize_family/01-base.xml b/tests/flattener_dicos/10load_masterslaves_normalize_family/01-base.xml index 4db65a41..d0926cce 100644 --- a/tests/flattener_dicos/10load_masterslaves_normalize_family/01-base.xml +++ b/tests/flattener_dicos/10load_masterslaves_normalize_family/01-base.xml @@ -5,7 +5,7 @@ - + diff --git a/tests/flattener_dicos/10load_masterslaves_normalize_family/makedict/base.json b/tests/flattener_dicos/10load_masterslaves_normalize_family/makedict/base.json index a82c00c4..dd3f25df 100644 --- a/tests/flattener_dicos/10load_masterslaves_normalize_family/makedict/base.json +++ b/tests/flattener_dicos/10load_masterslaves_normalize_family/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif": "non", "creole.general_1.master.master": [], "creole.general_1.master.slave1": [], "creole.general_1.master.slave2": []} +{"creole.general.mode_conteneur_actif": "non", "creole.general_1.leader.leader": [], "creole.general_1.leader.follower1": [], "creole.general_1.leader.follower2": []} diff --git a/tests/flattener_dicos/10load_masterslaves_normalize_family/result/00-base.xml b/tests/flattener_dicos/10load_masterslaves_normalize_family/result/00-base.xml index eca99d8a..b581a144 100644 --- a/tests/flattener_dicos/10load_masterslaves_normalize_family/result/00-base.xml +++ b/tests/flattener_dicos/10load_masterslaves_normalize_family/result/00-base.xml @@ -13,15 +13,15 @@ basic - + basic - + mandatory - + normal - + normal diff --git a/tests/flattener_dicos/10masterslave_autosaveexpert/00-base.xml b/tests/flattener_dicos/10masterslave_autosaveexpert/00-base.xml index 0d157c7e..fbbd2e80 100644 --- a/tests/flattener_dicos/10masterslave_autosaveexpert/00-base.xml +++ b/tests/flattener_dicos/10masterslave_autosaveexpert/00-base.xml @@ -8,22 +8,22 @@ non - - - + + + - + valfill - - slave1 + + follower1 - - slave1 - slave2 + + follower1 + follower2 diff --git a/tests/flattener_dicos/10masterslave_autosaveexpert/makedict/base.json b/tests/flattener_dicos/10masterslave_autosaveexpert/makedict/base.json index 61f7517c..a5b9c7f6 100644 --- a/tests/flattener_dicos/10masterslave_autosaveexpert/makedict/base.json +++ b/tests/flattener_dicos/10masterslave_autosaveexpert/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif": "non", "creole.general.master.master": [], "creole.general.master.slave1": [], "creole.general.master.slave2": []} +{"creole.general.mode_conteneur_actif": "non", "creole.general.leader.leader": [], "creole.general.leader.follower1": [], "creole.general.leader.follower2": []} diff --git a/tests/flattener_dicos/10masterslave_autosaveexpert/result/00-base.xml b/tests/flattener_dicos/10masterslave_autosaveexpert/result/00-base.xml index ffbe7a70..00318561 100644 --- a/tests/flattener_dicos/10masterslave_autosaveexpert/result/00-base.xml +++ b/tests/flattener_dicos/10masterslave_autosaveexpert/result/00-base.xml @@ -10,19 +10,19 @@ normal non - + normal - - + + normal valfill - + expert - creole.general.master.slave1 + creole.general.leader.follower1 diff --git a/tests/flattener_dicos/10masterslave_mandatory/00-base.xml b/tests/flattener_dicos/10masterslave_mandatory/00-base.xml index 18157e61..3305c720 100644 --- a/tests/flattener_dicos/10masterslave_mandatory/00-base.xml +++ b/tests/flattener_dicos/10masterslave_mandatory/00-base.xml @@ -8,22 +8,22 @@ non - - - + + + - + valfill - - slave1 + + follower1 - - slave1 - slave2 + + follower1 + follower2 diff --git a/tests/flattener_dicos/10masterslave_mandatory/makedict/base.json b/tests/flattener_dicos/10masterslave_mandatory/makedict/base.json index 61f7517c..a5b9c7f6 100644 --- a/tests/flattener_dicos/10masterslave_mandatory/makedict/base.json +++ b/tests/flattener_dicos/10masterslave_mandatory/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif": "non", "creole.general.master.master": [], "creole.general.master.slave1": [], "creole.general.master.slave2": []} +{"creole.general.mode_conteneur_actif": "non", "creole.general.leader.leader": [], "creole.general.leader.follower1": [], "creole.general.leader.follower2": []} diff --git a/tests/flattener_dicos/10masterslave_mandatory/result/00-base.xml b/tests/flattener_dicos/10masterslave_mandatory/result/00-base.xml index 629553e6..66455866 100644 --- a/tests/flattener_dicos/10masterslave_mandatory/result/00-base.xml +++ b/tests/flattener_dicos/10masterslave_mandatory/result/00-base.xml @@ -10,20 +10,20 @@ normal non - + normal - - + + mandatory normal valfill - + normal - creole.general.master.slave1 + creole.general.leader.follower1 diff --git a/tests/flattener_dicos/10masterslave_mandatoryslave/00-base.xml b/tests/flattener_dicos/10masterslave_mandatoryslave/00-base.xml index b72cc76e..dd4e26ff 100644 --- a/tests/flattener_dicos/10masterslave_mandatoryslave/00-base.xml +++ b/tests/flattener_dicos/10masterslave_mandatoryslave/00-base.xml @@ -13,8 +13,8 @@ - - nut_monitor_host + + nut_monitor_host diff --git a/tests/flattener_dicos/10masterslave_mastermandatory/00-base.xml b/tests/flattener_dicos/10masterslave_mastermandatory/00-base.xml index dcb7d03d..3ecc195c 100644 --- a/tests/flattener_dicos/10masterslave_mastermandatory/00-base.xml +++ b/tests/flattener_dicos/10masterslave_mastermandatory/00-base.xml @@ -8,22 +8,22 @@ non - - - + + + - + valfill - - slave1 + + follower1 - - slave1 - slave2 + + follower1 + follower2 diff --git a/tests/flattener_dicos/10masterslave_mastermandatory/makedict/base.json b/tests/flattener_dicos/10masterslave_mastermandatory/makedict/base.json index 61f7517c..a5b9c7f6 100644 --- a/tests/flattener_dicos/10masterslave_mastermandatory/makedict/base.json +++ b/tests/flattener_dicos/10masterslave_mastermandatory/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif": "non", "creole.general.master.master": [], "creole.general.master.slave1": [], "creole.general.master.slave2": []} +{"creole.general.mode_conteneur_actif": "non", "creole.general.leader.leader": [], "creole.general.leader.follower1": [], "creole.general.leader.follower2": []} diff --git a/tests/flattener_dicos/10masterslave_mastermandatory/result/00-base.xml b/tests/flattener_dicos/10masterslave_mastermandatory/result/00-base.xml index 7f4c6051..ba4245dc 100644 --- a/tests/flattener_dicos/10masterslave_mastermandatory/result/00-base.xml +++ b/tests/flattener_dicos/10masterslave_mastermandatory/result/00-base.xml @@ -10,21 +10,21 @@ normal non - + basic - + mandatory - + normal valfill - + normal - creole.general.master.slave1 + creole.general.leader.follower1 diff --git a/tests/flattener_dicos/10masterslave_multi/00-base.xml b/tests/flattener_dicos/10masterslave_multi/00-base.xml index 38b4c14f..ff926ac6 100644 --- a/tests/flattener_dicos/10masterslave_multi/00-base.xml +++ b/tests/flattener_dicos/10masterslave_multi/00-base.xml @@ -10,29 +10,29 @@ - - - - - - + + + + + + - + valfill - - slave1 + + follower1 - - slave1 - slave2 + + follower1 + follower2 - - slave11 - slave21 + + follower11 + follower21 diff --git a/tests/flattener_dicos/10masterslave_multi/makedict/base.json b/tests/flattener_dicos/10masterslave_multi/makedict/base.json index 1651d055..b51314de 100644 --- a/tests/flattener_dicos/10masterslave_multi/makedict/base.json +++ b/tests/flattener_dicos/10masterslave_multi/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif": "non", "creole.general1.master.master": [], "creole.general1.master.slave1": [], "creole.general1.master.slave2": [], "creole.general1.master1.master1": [], "creole.general1.master1.slave11": [], "creole.general1.master1.slave21": []} +{"creole.general.mode_conteneur_actif": "non", "creole.general1.leader.leader": [], "creole.general1.leader.follower1": [], "creole.general1.leader.follower2": [], "creole.general1.leader1.leader1": [], "creole.general1.leader1.follower11": [], "creole.general1.leader1.follower21": []} diff --git a/tests/flattener_dicos/10masterslave_multi/result/00-base.xml b/tests/flattener_dicos/10masterslave_multi/result/00-base.xml index 3ecf24f1..a2525bef 100644 --- a/tests/flattener_dicos/10masterslave_multi/result/00-base.xml +++ b/tests/flattener_dicos/10masterslave_multi/result/00-base.xml @@ -13,29 +13,29 @@ normal - + normal - - + + normal valfill - + normal - creole.general1.master.slave1 + creole.general1.leader.follower1 - + normal - - + + normal - + normal diff --git a/tests/flattener_dicos/10masterslaves_append/00-base.xml b/tests/flattener_dicos/10masterslaves_append/00-base.xml index 20128fd6..f9a78f67 100644 --- a/tests/flattener_dicos/10masterslaves_append/00-base.xml +++ b/tests/flattener_dicos/10masterslaves_append/00-base.xml @@ -10,22 +10,22 @@ - - - + + + - + valfill - - slave1 + + follower1 - - slave1 - slave2 + + follower1 + follower2 diff --git a/tests/flattener_dicos/10masterslaves_append/01-base.xml b/tests/flattener_dicos/10masterslaves_append/01-base.xml index cb85bf0e..d0fab650 100644 --- a/tests/flattener_dicos/10masterslaves_append/01-base.xml +++ b/tests/flattener_dicos/10masterslaves_append/01-base.xml @@ -5,13 +5,13 @@ - + - - slave3 + + follower3 diff --git a/tests/flattener_dicos/10masterslaves_append/makedict/base.json b/tests/flattener_dicos/10masterslaves_append/makedict/base.json index 459e3dfc..efadab16 100644 --- a/tests/flattener_dicos/10masterslaves_append/makedict/base.json +++ b/tests/flattener_dicos/10masterslaves_append/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif": "non", "creole.general1.master.master": [], "creole.general1.master.slave1": [], "creole.general1.master.slave2": [], "creole.general1.master.slave3": []} +{"creole.general.mode_conteneur_actif": "non", "creole.general1.leader.leader": [], "creole.general1.leader.follower1": [], "creole.general1.leader.follower2": [], "creole.general1.leader.follower3": []} diff --git a/tests/flattener_dicos/10masterslaves_append/result/00-base.xml b/tests/flattener_dicos/10masterslaves_append/result/00-base.xml index d30e3b74..4b8d1024 100644 --- a/tests/flattener_dicos/10masterslaves_append/result/00-base.xml +++ b/tests/flattener_dicos/10masterslaves_append/result/00-base.xml @@ -13,22 +13,22 @@ normal - + normal - - + + normal valfill - + normal - creole.general1.master.slave1 + creole.general1.leader.follower1 - + normal diff --git a/tests/flattener_dicos/10masterslaves_auto/00-base.xml b/tests/flattener_dicos/10masterslaves_auto/00-base.xml index a6e6872f..7d9f1ca2 100644 --- a/tests/flattener_dicos/10masterslaves_auto/00-base.xml +++ b/tests/flattener_dicos/10masterslaves_auto/00-base.xml @@ -8,27 +8,27 @@ non - - - - + + + + - + valfill - - slave1 + + follower1 - - master + + leader - - slave1 - slave2 - slave3 + + follower1 + follower2 + follower3 diff --git a/tests/flattener_dicos/10masterslaves_auto/makedict/base.json b/tests/flattener_dicos/10masterslaves_auto/makedict/base.json index 9202d7fe..f8bc165e 100644 --- a/tests/flattener_dicos/10masterslaves_auto/makedict/base.json +++ b/tests/flattener_dicos/10masterslaves_auto/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif": "non", "creole.general.master.master": []} +{"creole.general.mode_conteneur_actif": "non", "creole.general.leader.leader": []} diff --git a/tests/flattener_dicos/10masterslaves_auto/result/00-base.xml b/tests/flattener_dicos/10masterslaves_auto/result/00-base.xml index 93c36e41..ef7e3cc0 100644 --- a/tests/flattener_dicos/10masterslaves_auto/result/00-base.xml +++ b/tests/flattener_dicos/10masterslaves_auto/result/00-base.xml @@ -10,10 +10,10 @@ normal non - + normal - - + + force_default_on_freeze frozen hidden @@ -22,22 +22,22 @@ valfill - + force_default_on_freeze frozen hidden normal - creole.general.master.slave1 + creole.general.leader.follower1 - + force_default_on_freeze frozen hidden normal - creole.general.master.master + creole.general.leader.leader diff --git a/tests/flattener_dicos/10masterslaves_automaster/00-base.xml b/tests/flattener_dicos/10masterslaves_automaster/00-base.xml index 439c96a7..d24509d3 100644 --- a/tests/flattener_dicos/10masterslaves_automaster/00-base.xml +++ b/tests/flattener_dicos/10masterslaves_automaster/00-base.xml @@ -8,22 +8,22 @@ non - - - + + + - + valfill - - master + + leader - - slave1 - slave2 + + follower1 + follower2 diff --git a/tests/flattener_dicos/10masterslaves_automaster/makedict/base.json b/tests/flattener_dicos/10masterslaves_automaster/makedict/base.json index 9202d7fe..f8bc165e 100644 --- a/tests/flattener_dicos/10masterslaves_automaster/makedict/base.json +++ b/tests/flattener_dicos/10masterslaves_automaster/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif": "non", "creole.general.master.master": []} +{"creole.general.mode_conteneur_actif": "non", "creole.general.leader.leader": []} diff --git a/tests/flattener_dicos/10masterslaves_automaster/result/00-base.xml b/tests/flattener_dicos/10masterslaves_automaster/result/00-base.xml index a7fa7d42..32fc5126 100644 --- a/tests/flattener_dicos/10masterslaves_automaster/result/00-base.xml +++ b/tests/flattener_dicos/10masterslaves_automaster/result/00-base.xml @@ -10,10 +10,10 @@ normal non - + normal - - + + force_default_on_freeze frozen hidden @@ -22,13 +22,13 @@ valfill - + force_default_on_freeze frozen hidden normal - creole.general.master.master + creole.general.leader.leader diff --git a/tests/flattener_dicos/10masterslaves_automaster_expert/00-base.xml b/tests/flattener_dicos/10masterslaves_automaster_expert/00-base.xml index 49369ad6..76e712e8 100644 --- a/tests/flattener_dicos/10masterslaves_automaster_expert/00-base.xml +++ b/tests/flattener_dicos/10masterslaves_automaster_expert/00-base.xml @@ -9,20 +9,20 @@ non - - - - + + + + - + valfill - - slave1 - slave2 + + follower1 + follower2 diff --git a/tests/flattener_dicos/10masterslaves_automaster_expert/result/00-base.xml b/tests/flattener_dicos/10masterslaves_automaster_expert/result/00-base.xml index 8fba03dc..37131b3e 100644 --- a/tests/flattener_dicos/10masterslaves_automaster_expert/result/00-base.xml +++ b/tests/flattener_dicos/10masterslaves_automaster_expert/result/00-base.xml @@ -11,22 +11,22 @@ non - + expert - + hidden expert - + force_default_on_freeze frozen valfill - + expert - + expert diff --git a/tests/flattener_dicos/10masterslaves_familyaccent/00-base.xml b/tests/flattener_dicos/10masterslaves_familyaccent/00-base.xml index 7500aecc..b746e57e 100644 --- a/tests/flattener_dicos/10masterslaves_familyaccent/00-base.xml +++ b/tests/flattener_dicos/10masterslaves_familyaccent/00-base.xml @@ -8,22 +8,22 @@ non - - - + + + - + valfill - - slave1 + + follower1 - - slave1 - slave2 + + follower1 + follower2 diff --git a/tests/flattener_dicos/10masterslaves_familyaccent/makedict/base.json b/tests/flattener_dicos/10masterslaves_familyaccent/makedict/base.json index 61f7517c..a5b9c7f6 100644 --- a/tests/flattener_dicos/10masterslaves_familyaccent/makedict/base.json +++ b/tests/flattener_dicos/10masterslaves_familyaccent/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif": "non", "creole.general.master.master": [], "creole.general.master.slave1": [], "creole.general.master.slave2": []} +{"creole.general.mode_conteneur_actif": "non", "creole.general.leader.leader": [], "creole.general.leader.follower1": [], "creole.general.leader.follower2": []} diff --git a/tests/flattener_dicos/10masterslaves_familyaccent/result/00-base.xml b/tests/flattener_dicos/10masterslaves_familyaccent/result/00-base.xml index 190353f9..47482572 100644 --- a/tests/flattener_dicos/10masterslaves_familyaccent/result/00-base.xml +++ b/tests/flattener_dicos/10masterslaves_familyaccent/result/00-base.xml @@ -10,19 +10,19 @@ normal non - + normal - - + + normal valfill - + normal - creole.general.master.slave1 + creole.general.leader.follower1 diff --git a/tests/flattener_dicos/10valid_enum_master/00-base.xml b/tests/flattener_dicos/10valid_enum_master/00-base.xml index cfff2572..b605f770 100644 --- a/tests/flattener_dicos/10valid_enum_master/00-base.xml +++ b/tests/flattener_dicos/10valid_enum_master/00-base.xml @@ -8,20 +8,20 @@ non - - - + + + - + ['a','b','c'] - - slave1 - slave2 + + follower1 + follower2 diff --git a/tests/flattener_dicos/10valid_enum_master/makedict/base.json b/tests/flattener_dicos/10valid_enum_master/makedict/base.json index 61f7517c..a5b9c7f6 100644 --- a/tests/flattener_dicos/10valid_enum_master/makedict/base.json +++ b/tests/flattener_dicos/10valid_enum_master/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif": "non", "creole.general.master.master": [], "creole.general.master.slave1": [], "creole.general.master.slave2": []} +{"creole.general.mode_conteneur_actif": "non", "creole.general.leader.leader": [], "creole.general.leader.follower1": [], "creole.general.leader.follower2": []} diff --git a/tests/flattener_dicos/10valid_enum_master/result/00-base.xml b/tests/flattener_dicos/10valid_enum_master/result/00-base.xml index a4de8b15..117e6dac 100644 --- a/tests/flattener_dicos/10valid_enum_master/result/00-base.xml +++ b/tests/flattener_dicos/10valid_enum_master/result/00-base.xml @@ -10,10 +10,10 @@ normal non - + normal - - + + a b c @@ -21,7 +21,7 @@ normal a - + normal diff --git a/tests/flattener_dicos/20family_modemasterslaves/00-base.xml b/tests/flattener_dicos/20family_modemasterslaves/00-base.xml index 62aeae3e..4a6ac513 100644 --- a/tests/flattener_dicos/20family_modemasterslaves/00-base.xml +++ b/tests/flattener_dicos/20family_modemasterslaves/00-base.xml @@ -8,17 +8,17 @@ non - - - + + + - - slave1 - slave2 + + follower1 + follower2 diff --git a/tests/flattener_dicos/20family_modemasterslaves/makedict/base.json b/tests/flattener_dicos/20family_modemasterslaves/makedict/base.json index 61f7517c..a5b9c7f6 100644 --- a/tests/flattener_dicos/20family_modemasterslaves/makedict/base.json +++ b/tests/flattener_dicos/20family_modemasterslaves/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif": "non", "creole.general.master.master": [], "creole.general.master.slave1": [], "creole.general.master.slave2": []} +{"creole.general.mode_conteneur_actif": "non", "creole.general.leader.leader": [], "creole.general.leader.follower1": [], "creole.general.leader.follower2": []} diff --git a/tests/flattener_dicos/20family_modemasterslaves/result/00-base.xml b/tests/flattener_dicos/20family_modemasterslaves/result/00-base.xml index f584c5ae..b4ccf3fe 100644 --- a/tests/flattener_dicos/20family_modemasterslaves/result/00-base.xml +++ b/tests/flattener_dicos/20family_modemasterslaves/result/00-base.xml @@ -10,13 +10,13 @@ normal non - + normal - - + + normal - + normal diff --git a/tests/flattener_dicos/40ifin_masterslaves/00-base.xml b/tests/flattener_dicos/40ifin_masterslaves/00-base.xml index 4615d044..58919ad4 100644 --- a/tests/flattener_dicos/40ifin_masterslaves/00-base.xml +++ b/tests/flattener_dicos/40ifin_masterslaves/00-base.xml @@ -9,20 +9,20 @@ non - - - + + + - - slave1 - slave2 + + follower1 + follower2 oui - slave1 + follower1 diff --git a/tests/flattener_dicos/40ifin_masterslaves/makedict/base.json b/tests/flattener_dicos/40ifin_masterslaves/makedict/base.json index 24f59146..4d5d7674 100644 --- a/tests/flattener_dicos/40ifin_masterslaves/makedict/base.json +++ b/tests/flattener_dicos/40ifin_masterslaves/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif": "non", "creole.general.condition": "oui", "creole.general.master.master": [], "creole.general.master.slave2": []} +{"creole.general.mode_conteneur_actif": "non", "creole.general.condition": "oui", "creole.general.leader.leader": [], "creole.general.leader.follower2": []} diff --git a/tests/flattener_dicos/40ifin_masterslaves/result/00-base.xml b/tests/flattener_dicos/40ifin_masterslaves/result/00-base.xml index ccee203c..94359a0a 100644 --- a/tests/flattener_dicos/40ifin_masterslaves/result/00-base.xml +++ b/tests/flattener_dicos/40ifin_masterslaves/result/00-base.xml @@ -17,14 +17,14 @@ normal oui - + normal - - + + normal disabled - + normal diff --git a/tests/flattener_dicos/40ifin_masterslavesauto/00-base.xml b/tests/flattener_dicos/40ifin_masterslavesauto/00-base.xml index c031638b..45846822 100644 --- a/tests/flattener_dicos/40ifin_masterslavesauto/00-base.xml +++ b/tests/flattener_dicos/40ifin_masterslavesauto/00-base.xml @@ -9,23 +9,23 @@ non - - - + + + - - slave1 - slave2 + + follower1 + follower2 - + valfill oui - slave1 + follower1 diff --git a/tests/flattener_dicos/40ifin_masterslavesauto/makedict/base.json b/tests/flattener_dicos/40ifin_masterslavesauto/makedict/base.json index 24f59146..4d5d7674 100644 --- a/tests/flattener_dicos/40ifin_masterslavesauto/makedict/base.json +++ b/tests/flattener_dicos/40ifin_masterslavesauto/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif": "non", "creole.general.condition": "oui", "creole.general.master.master": [], "creole.general.master.slave2": []} +{"creole.general.mode_conteneur_actif": "non", "creole.general.condition": "oui", "creole.general.leader.leader": [], "creole.general.leader.follower2": []} diff --git a/tests/flattener_dicos/40ifin_masterslavesauto/result/00-base.xml b/tests/flattener_dicos/40ifin_masterslavesauto/result/00-base.xml index 180b37dc..624e3346 100644 --- a/tests/flattener_dicos/40ifin_masterslavesauto/result/00-base.xml +++ b/tests/flattener_dicos/40ifin_masterslavesauto/result/00-base.xml @@ -17,10 +17,10 @@ normal oui - + normal - - + + force_default_on_freeze frozen hidden @@ -30,7 +30,7 @@ valfill - + normal diff --git a/tests/flattener_dicos/60extra_group/extra_dirs/extra/00-base.xml b/tests/flattener_dicos/60extra_group/extra_dirs/extra/00-base.xml index 158e7b05..ebbabd26 100644 --- a/tests/flattener_dicos/60extra_group/extra_dirs/extra/00-base.xml +++ b/tests/flattener_dicos/60extra_group/extra_dirs/extra/00-base.xml @@ -12,8 +12,8 @@ - - mode + + mode diff --git a/tests/flattener_dicos/70container_pathaccess_masterslaves/00-base.xml b/tests/flattener_dicos/70container_pathaccess_masterslaves/00-base.xml index 44322da3..1ab25a5d 100644 --- a/tests/flattener_dicos/70container_pathaccess_masterslaves/00-base.xml +++ b/tests/flattener_dicos/70container_pathaccess_masterslaves/00-base.xml @@ -20,8 +20,8 @@ - - nut_monitor_host + + nut_monitor_host diff --git a/tests/flattener_dicos/80condition_itself/00-base.xml b/tests/flattener_dicos/80condition_itself/00-base.xml index dbe0f58a..99fb6ba1 100644 --- a/tests/flattener_dicos/80condition_itself/00-base.xml +++ b/tests/flattener_dicos/80condition_itself/00-base.xml @@ -7,7 +7,7 @@ - master-master + leader-leader replicationType diff --git a/tests/flattener_dicos/80family_several/00-base.xml b/tests/flattener_dicos/80family_several/00-base.xml index 194230c4..2422864a 100644 --- a/tests/flattener_dicos/80family_several/00-base.xml +++ b/tests/flattener_dicos/80family_several/00-base.xml @@ -10,22 +10,22 @@ - - - + + + - + valfill - - slave1 + + follower1 - - slave1 - slave2 + + follower1 + follower2 diff --git a/tests/flattener_dicos/80leadership_none_slave_between_slave/00-base.xml b/tests/flattener_dicos/80leadership_none_slave_between_slave/00-base.xml index cb88b2f0..3157fc88 100644 --- a/tests/flattener_dicos/80leadership_none_slave_between_slave/00-base.xml +++ b/tests/flattener_dicos/80leadership_none_slave_between_slave/00-base.xml @@ -5,25 +5,25 @@ - + non - - + + - + valfill - - slave1 + + follower1 - - slave1 - slave2 + + follower1 + follower2 diff --git a/tests/flattener_dicos/80leadership_not_ordered/00-base.xml b/tests/flattener_dicos/80leadership_not_ordered/00-base.xml index 71254809..742dfe13 100644 --- a/tests/flattener_dicos/80leadership_not_ordered/00-base.xml +++ b/tests/flattener_dicos/80leadership_not_ordered/00-base.xml @@ -10,22 +10,22 @@ - - - + + + - + valfill - - slave1 + + follower1 - - slave2 - slave1 + + follower2 + follower1 diff --git a/tests/flattener_dicos/80leadership_not_same_family/00-base.xml b/tests/flattener_dicos/80leadership_not_same_family/00-base.xml index 52ae2ce7..c2753816 100644 --- a/tests/flattener_dicos/80leadership_not_same_family/00-base.xml +++ b/tests/flattener_dicos/80leadership_not_same_family/00-base.xml @@ -10,24 +10,24 @@ - - + + - + - + valfill - - slave1 + + follower1 - - slave1 - slave2 + + follower1 + follower2 diff --git a/tests/flattener_dicos/80leadership_notmulti2/00-base.xml b/tests/flattener_dicos/80leadership_notmulti2/00-base.xml index 8568956e..48377ba3 100644 --- a/tests/flattener_dicos/80leadership_notmulti2/00-base.xml +++ b/tests/flattener_dicos/80leadership_notmulti2/00-base.xml @@ -10,22 +10,22 @@ - - - + + + - + valfill - - slave1 + + follower1 - - slave1 - slave2 + + follower1 + follower2 diff --git a/tests/flattener_dicos/80masterslave_auto_save/00-base.xml b/tests/flattener_dicos/80masterslave_auto_save/00-base.xml index df5350aa..2a817fe9 100644 --- a/tests/flattener_dicos/80masterslave_auto_save/00-base.xml +++ b/tests/flattener_dicos/80masterslave_auto_save/00-base.xml @@ -8,22 +8,22 @@ non - - - + + + - + valfill - - slave1 + + follower1 - - slave1 - slave2 + + follower1 + follower2 diff --git a/tests/flattener_dicos/80masterslave_notexists/00-base.xml b/tests/flattener_dicos/80masterslave_notexists/00-base.xml index 35e7f43a..ce53a30a 100644 --- a/tests/flattener_dicos/80masterslave_notexists/00-base.xml +++ b/tests/flattener_dicos/80masterslave_notexists/00-base.xml @@ -8,26 +8,26 @@ non - - - + + + - + valfill - - slave1 + + follower1 - - slave1 - slave2 + + follower1 + follower2 - - slave3 - slave4 + + follower3 + follower4 diff --git a/tests/flattener_dicos/80masterslaves_autofreeze/00-base.xml b/tests/flattener_dicos/80masterslaves_autofreeze/00-base.xml index 404c029a..70dec0a9 100644 --- a/tests/flattener_dicos/80masterslaves_autofreeze/00-base.xml +++ b/tests/flattener_dicos/80masterslaves_autofreeze/00-base.xml @@ -5,22 +5,22 @@ - - - + + + - + valfill - - slave1 + + follower1 - - slave1 - slave2 + + follower1 + follower2 diff --git a/tests/flattener_dicos/80masterslaves_notmulti/00-base.xml b/tests/flattener_dicos/80masterslaves_notmulti/00-base.xml index 722ef04d..7226ba04 100644 --- a/tests/flattener_dicos/80masterslaves_notmulti/00-base.xml +++ b/tests/flattener_dicos/80masterslaves_notmulti/00-base.xml @@ -5,22 +5,22 @@ - - - + + + - + valfill - - slave1 + + follower1 - - slave1 - slave2 + + follower1 + follower2 From d47d1fde624c4d6c494e6f2a435092b1cb854910 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Tue, 21 Apr 2020 09:22:45 +0200 Subject: [PATCH 05/32] support submulti with follower --- src/rougail/loader.py | 17 ++++++---- .../00-base.xml | 0 .../01-base.xml | 0 .../makedict/base.json | 0 .../result/00-base.xml | 0 .../00-base.xml | 0 .../makedict/base.json | 0 .../result/00-base.xml | 0 .../00-base.xml | 0 .../makedict/base.json | 0 .../result/00-base.xml | 0 .../00-base.xml | 0 .../makedict/base.json | 0 .../result/00-base.xml | 0 .../00-base.xml | 0 .../makedict/base.json | 0 .../result/00-base.xml | 0 .../00-base.xml | 0 .../makedict/base.json | 0 .../result/00-base.xml | 0 .../00-base.xml | 0 .../makedict/base.json | 0 .../result/00-base.xml | 0 .../00-base.xml | 0 .../makedict/base.json | 0 .../result/00-base.xml | 0 .../00-base.xml | 0 .../makedict/base.json | 0 .../result/00-base.xml | 0 .../00-base.xml | 0 .../makedict/base.json | 0 .../result/00-base.xml | 0 .../00-base.xml | 0 .../makedict/base.json | 0 .../result/00-base.xml | 0 .../00-base.xml | 0 .../makedict/base.json | 0 .../result/00-base.xml | 0 .../00-base.xml | 33 ++++++++++++++++++ .../makedict/base.json | 1 + .../result/00-base.xml | 33 ++++++++++++++++++ .../00-base.xml | 0 .../makedict/base.json | 0 .../result/00-base.xml | 0 .../00-base.xml | 0 .../makedict/base.json | 0 .../result/00-base.xml | 0 .../00-base.xml | 0 .../01-base.xml | 0 .../makedict/base.json | 0 .../result/00-base.xml | 0 .../10load_leadership_submulti/00-base.xml | 34 +++++++++++++++++++ .../makedict/base.json | 1 + .../result/00-base.xml | 34 +++++++++++++++++++ .../10load_submulti_two_value/00-base.xml | 23 +++++++++++++ .../makedict/base.json | 1 + .../result/00-base.xml | 17 ++++++++++ .../00-base.xml | 0 .../makedict/base.json | 0 .../result/00-base.xml | 0 .../00-base.xml | 0 .../makedict/base.json | 0 .../result/00-base.xml | 0 .../00-base.xml | 0 .../makedict/base.json | 0 .../result/00-base.xml | 0 .../00-base.xml | 0 .../makedict/base.json | 0 .../result/00-base.xml | 0 .../00-base.xml | 0 .../makedict/base.json | 0 .../result/00-base.xml | 0 .../00-base.xml | 0 .../00-base.xml | 0 .../00-base.xml | 0 .../00-base.xml | 0 .../00-base.xml | 0 tests/test_flattener.py | 6 ++-- tests/test_makedict.py | 2 +- 79 files changed, 192 insertions(+), 10 deletions(-) rename tests/flattener_dicos/{10load_masterslaves => 10leadership_append}/00-base.xml (100%) rename tests/flattener_dicos/{10masterslaves_append => 10leadership_append}/01-base.xml (100%) rename tests/flattener_dicos/{10masterslaves_append => 10leadership_append}/makedict/base.json (100%) rename tests/flattener_dicos/{10masterslaves_append => 10leadership_append}/result/00-base.xml (100%) rename tests/flattener_dicos/{10masterslaves_auto => 10leadership_auto}/00-base.xml (100%) rename tests/flattener_dicos/{10masterslaves_auto => 10leadership_auto}/makedict/base.json (100%) rename tests/flattener_dicos/{10masterslaves_auto => 10leadership_auto}/result/00-base.xml (100%) rename tests/flattener_dicos/{10masterslaves_automaster => 10leadership_autoleader}/00-base.xml (100%) rename tests/flattener_dicos/{10masterslaves_automaster => 10leadership_autoleader}/makedict/base.json (100%) rename tests/flattener_dicos/{10masterslaves_automaster => 10leadership_autoleader}/result/00-base.xml (100%) rename tests/flattener_dicos/{10masterslaves_automaster_expert => 10leadership_autoleader_expert}/00-base.xml (100%) rename tests/flattener_dicos/{10masterslaves_automaster_expert => 10leadership_autoleader_expert}/makedict/base.json (100%) rename tests/flattener_dicos/{10masterslaves_automaster_expert => 10leadership_autoleader_expert}/result/00-base.xml (100%) rename tests/flattener_dicos/{10masterslave_autosaveexpert => 10leadership_autosaveexpert}/00-base.xml (100%) rename tests/flattener_dicos/{10masterslave_autosaveexpert => 10leadership_autosaveexpert}/makedict/base.json (100%) rename tests/flattener_dicos/{10masterslave_autosaveexpert => 10leadership_autosaveexpert}/result/00-base.xml (100%) rename tests/flattener_dicos/{10masterslaves_familyaccent => 10leadership_familyaccent}/00-base.xml (100%) rename tests/flattener_dicos/{10masterslave_mandatory => 10leadership_familyaccent}/makedict/base.json (100%) rename tests/flattener_dicos/{10masterslaves_familyaccent => 10leadership_familyaccent}/result/00-base.xml (100%) rename tests/flattener_dicos/{10masterslave_mastermandatory => 10leadership_leadermandatory}/00-base.xml (100%) rename tests/flattener_dicos/{10masterslave_mastermandatory => 10leadership_leadermandatory}/makedict/base.json (100%) rename tests/flattener_dicos/{10masterslave_mastermandatory => 10leadership_leadermandatory}/result/00-base.xml (100%) rename tests/flattener_dicos/{10masterslave_mandatory => 10leadership_mandatory}/00-base.xml (100%) rename tests/flattener_dicos/{10masterslaves_familyaccent => 10leadership_mandatory}/makedict/base.json (100%) rename tests/flattener_dicos/{10masterslave_mandatory => 10leadership_mandatory}/result/00-base.xml (100%) rename tests/flattener_dicos/{10masterslave_mandatoryslave => 10leadership_mandatoryfollower}/00-base.xml (100%) rename tests/flattener_dicos/{10masterslave_mandatoryslave => 10leadership_mandatoryfollower}/makedict/base.json (100%) rename tests/flattener_dicos/{10masterslave_mandatoryslave => 10leadership_mandatoryfollower}/result/00-base.xml (100%) rename tests/flattener_dicos/{10masterslave_multi => 10leadership_multi}/00-base.xml (100%) rename tests/flattener_dicos/{10masterslave_multi => 10leadership_multi}/makedict/base.json (100%) rename tests/flattener_dicos/{10masterslave_multi => 10leadership_multi}/result/00-base.xml (100%) rename tests/flattener_dicos/{10masterslaves_append => 10load_leadership}/00-base.xml (100%) rename tests/flattener_dicos/{10load_masterslaves => 10load_leadership}/makedict/base.json (100%) rename tests/flattener_dicos/{10load_masterslaves => 10load_leadership}/result/00-base.xml (100%) rename tests/flattener_dicos/{10load_masterslaves_default_multi => 10load_leadership_default_multi}/00-base.xml (100%) rename tests/flattener_dicos/{10load_masterslaves_default_multi => 10load_leadership_default_multi}/makedict/base.json (100%) rename tests/flattener_dicos/{10load_masterslaves_default_multi => 10load_leadership_default_multi}/result/00-base.xml (100%) create mode 100644 tests/flattener_dicos/10load_leadership_default_submulti/00-base.xml create mode 100644 tests/flattener_dicos/10load_leadership_default_submulti/makedict/base.json create mode 100644 tests/flattener_dicos/10load_leadership_default_submulti/result/00-base.xml rename tests/flattener_dicos/{10load_masterslaves_defaultmulti_master => 10load_leadership_defaultmulti_leader}/00-base.xml (100%) rename tests/flattener_dicos/{10load_masterslaves_defaultmulti_master => 10load_leadership_defaultmulti_leader}/makedict/base.json (100%) rename tests/flattener_dicos/{10load_masterslaves_defaultmulti_master => 10load_leadership_defaultmulti_leader}/result/00-base.xml (100%) rename tests/flattener_dicos/{10load_masterslaves_description => 10load_leadership_description}/00-base.xml (100%) rename tests/flattener_dicos/{10load_masterslaves_description => 10load_leadership_description}/makedict/base.json (100%) rename tests/flattener_dicos/{10load_masterslaves_description => 10load_leadership_description}/result/00-base.xml (100%) rename tests/flattener_dicos/{10load_masterslaves_normalize_family => 10load_leadership_normalize_family}/00-base.xml (100%) rename tests/flattener_dicos/{10load_masterslaves_normalize_family => 10load_leadership_normalize_family}/01-base.xml (100%) rename tests/flattener_dicos/{10load_masterslaves_normalize_family => 10load_leadership_normalize_family}/makedict/base.json (100%) rename tests/flattener_dicos/{10load_masterslaves_normalize_family => 10load_leadership_normalize_family}/result/00-base.xml (100%) create mode 100644 tests/flattener_dicos/10load_leadership_submulti/00-base.xml create mode 100644 tests/flattener_dicos/10load_leadership_submulti/makedict/base.json create mode 100644 tests/flattener_dicos/10load_leadership_submulti/result/00-base.xml create mode 100644 tests/flattener_dicos/10load_submulti_two_value/00-base.xml create mode 100644 tests/flattener_dicos/10load_submulti_two_value/makedict/base.json create mode 100644 tests/flattener_dicos/10load_submulti_two_value/result/00-base.xml rename tests/flattener_dicos/{10valid_enum_master => 10valid_enum_leader}/00-base.xml (100%) rename tests/flattener_dicos/{10valid_enum_master => 10valid_enum_leader}/makedict/base.json (100%) rename tests/flattener_dicos/{10valid_enum_master => 10valid_enum_leader}/result/00-base.xml (100%) rename tests/flattener_dicos/{20family_modemasterslaves => 20family_modeleadership}/00-base.xml (100%) rename tests/flattener_dicos/{20family_modemasterslaves => 20family_modeleadership}/makedict/base.json (100%) rename tests/flattener_dicos/{20family_modemasterslaves => 20family_modeleadership}/result/00-base.xml (100%) rename tests/flattener_dicos/{40ifin_masterslaves => 40ifin_leadership}/00-base.xml (100%) rename tests/flattener_dicos/{40ifin_masterslaves => 40ifin_leadership}/makedict/base.json (100%) rename tests/flattener_dicos/{40ifin_masterslaves => 40ifin_leadership}/result/00-base.xml (100%) rename tests/flattener_dicos/{40ifin_masterslavesauto => 40ifin_leadershipauto}/00-base.xml (100%) rename tests/flattener_dicos/{40ifin_masterslavesauto => 40ifin_leadershipauto}/makedict/base.json (100%) rename tests/flattener_dicos/{40ifin_masterslavesauto => 40ifin_leadershipauto}/result/00-base.xml (100%) rename tests/flattener_dicos/{70container_pathaccess_masterslaves => 70container_pathaccess_leadership}/00-base.xml (100%) rename tests/flattener_dicos/{70container_pathaccess_masterslaves => 70container_pathaccess_leadership}/makedict/base.json (100%) rename tests/flattener_dicos/{70container_pathaccess_masterslaves => 70container_pathaccess_leadership}/result/00-base.xml (100%) rename tests/flattener_dicos/{80masterslave_auto_save => 80leadership_auto_save}/00-base.xml (100%) rename tests/flattener_dicos/{80masterslaves_autofreeze => 80leadership_autofreeze}/00-base.xml (100%) rename tests/flattener_dicos/{80leadership_none_slave_between_slave => 80leadership_none_follower_between_follower}/00-base.xml (100%) rename tests/flattener_dicos/{80masterslave_notexists => 80leadership_notexists}/00-base.xml (100%) rename tests/flattener_dicos/{80masterslaves_notmulti => 80leadership_notmulti}/00-base.xml (100%) diff --git a/src/rougail/loader.py b/src/rougail/loader.py index 097a4360..d45a0cde 100644 --- a/src/rougail/loader.py +++ b/src/rougail/loader.py @@ -385,18 +385,21 @@ class Variable(Common): if 'default' not in self.attrib: self.attrib['default'] = [] value = convert_tiramisu_value(child.text, type_) - if not isinstance(value, list) and not is_follower: - value = [value] - self.attrib['default'].append(value) - if 'default_multi' not in self.attrib and not is_leader: - self.attrib['default_multi'] = value + if not is_follower: + if not isinstance(value, list): + dvalue = [value] + else: + dvalue = value + self.attrib['default'].append(dvalue) + if value and 'default_multi' not in self.attrib and not is_leader: + self.attrib['default_multi'] = [] + if not is_leader: + self.attrib['default_multi'].append(value) else: if 'default' in self.attrib: raise CreoleLoaderError(_('default value already set for {}' '').format(self.attrib['path'])) value = convert_tiramisu_value(child.text, type_) - if value is None: # and (elt.attrib['type'] != 'choice' or value not in self.attrib['values']): - value = u'' if is_follower: self.attrib['default_multi'] = value else: diff --git a/tests/flattener_dicos/10load_masterslaves/00-base.xml b/tests/flattener_dicos/10leadership_append/00-base.xml similarity index 100% rename from tests/flattener_dicos/10load_masterslaves/00-base.xml rename to tests/flattener_dicos/10leadership_append/00-base.xml diff --git a/tests/flattener_dicos/10masterslaves_append/01-base.xml b/tests/flattener_dicos/10leadership_append/01-base.xml similarity index 100% rename from tests/flattener_dicos/10masterslaves_append/01-base.xml rename to tests/flattener_dicos/10leadership_append/01-base.xml diff --git a/tests/flattener_dicos/10masterslaves_append/makedict/base.json b/tests/flattener_dicos/10leadership_append/makedict/base.json similarity index 100% rename from tests/flattener_dicos/10masterslaves_append/makedict/base.json rename to tests/flattener_dicos/10leadership_append/makedict/base.json diff --git a/tests/flattener_dicos/10masterslaves_append/result/00-base.xml b/tests/flattener_dicos/10leadership_append/result/00-base.xml similarity index 100% rename from tests/flattener_dicos/10masterslaves_append/result/00-base.xml rename to tests/flattener_dicos/10leadership_append/result/00-base.xml diff --git a/tests/flattener_dicos/10masterslaves_auto/00-base.xml b/tests/flattener_dicos/10leadership_auto/00-base.xml similarity index 100% rename from tests/flattener_dicos/10masterslaves_auto/00-base.xml rename to tests/flattener_dicos/10leadership_auto/00-base.xml diff --git a/tests/flattener_dicos/10masterslaves_auto/makedict/base.json b/tests/flattener_dicos/10leadership_auto/makedict/base.json similarity index 100% rename from tests/flattener_dicos/10masterslaves_auto/makedict/base.json rename to tests/flattener_dicos/10leadership_auto/makedict/base.json diff --git a/tests/flattener_dicos/10masterslaves_auto/result/00-base.xml b/tests/flattener_dicos/10leadership_auto/result/00-base.xml similarity index 100% rename from tests/flattener_dicos/10masterslaves_auto/result/00-base.xml rename to tests/flattener_dicos/10leadership_auto/result/00-base.xml diff --git a/tests/flattener_dicos/10masterslaves_automaster/00-base.xml b/tests/flattener_dicos/10leadership_autoleader/00-base.xml similarity index 100% rename from tests/flattener_dicos/10masterslaves_automaster/00-base.xml rename to tests/flattener_dicos/10leadership_autoleader/00-base.xml diff --git a/tests/flattener_dicos/10masterslaves_automaster/makedict/base.json b/tests/flattener_dicos/10leadership_autoleader/makedict/base.json similarity index 100% rename from tests/flattener_dicos/10masterslaves_automaster/makedict/base.json rename to tests/flattener_dicos/10leadership_autoleader/makedict/base.json diff --git a/tests/flattener_dicos/10masterslaves_automaster/result/00-base.xml b/tests/flattener_dicos/10leadership_autoleader/result/00-base.xml similarity index 100% rename from tests/flattener_dicos/10masterslaves_automaster/result/00-base.xml rename to tests/flattener_dicos/10leadership_autoleader/result/00-base.xml diff --git a/tests/flattener_dicos/10masterslaves_automaster_expert/00-base.xml b/tests/flattener_dicos/10leadership_autoleader_expert/00-base.xml similarity index 100% rename from tests/flattener_dicos/10masterslaves_automaster_expert/00-base.xml rename to tests/flattener_dicos/10leadership_autoleader_expert/00-base.xml diff --git a/tests/flattener_dicos/10masterslaves_automaster_expert/makedict/base.json b/tests/flattener_dicos/10leadership_autoleader_expert/makedict/base.json similarity index 100% rename from tests/flattener_dicos/10masterslaves_automaster_expert/makedict/base.json rename to tests/flattener_dicos/10leadership_autoleader_expert/makedict/base.json diff --git a/tests/flattener_dicos/10masterslaves_automaster_expert/result/00-base.xml b/tests/flattener_dicos/10leadership_autoleader_expert/result/00-base.xml similarity index 100% rename from tests/flattener_dicos/10masterslaves_automaster_expert/result/00-base.xml rename to tests/flattener_dicos/10leadership_autoleader_expert/result/00-base.xml diff --git a/tests/flattener_dicos/10masterslave_autosaveexpert/00-base.xml b/tests/flattener_dicos/10leadership_autosaveexpert/00-base.xml similarity index 100% rename from tests/flattener_dicos/10masterslave_autosaveexpert/00-base.xml rename to tests/flattener_dicos/10leadership_autosaveexpert/00-base.xml diff --git a/tests/flattener_dicos/10masterslave_autosaveexpert/makedict/base.json b/tests/flattener_dicos/10leadership_autosaveexpert/makedict/base.json similarity index 100% rename from tests/flattener_dicos/10masterslave_autosaveexpert/makedict/base.json rename to tests/flattener_dicos/10leadership_autosaveexpert/makedict/base.json diff --git a/tests/flattener_dicos/10masterslave_autosaveexpert/result/00-base.xml b/tests/flattener_dicos/10leadership_autosaveexpert/result/00-base.xml similarity index 100% rename from tests/flattener_dicos/10masterslave_autosaveexpert/result/00-base.xml rename to tests/flattener_dicos/10leadership_autosaveexpert/result/00-base.xml diff --git a/tests/flattener_dicos/10masterslaves_familyaccent/00-base.xml b/tests/flattener_dicos/10leadership_familyaccent/00-base.xml similarity index 100% rename from tests/flattener_dicos/10masterslaves_familyaccent/00-base.xml rename to tests/flattener_dicos/10leadership_familyaccent/00-base.xml diff --git a/tests/flattener_dicos/10masterslave_mandatory/makedict/base.json b/tests/flattener_dicos/10leadership_familyaccent/makedict/base.json similarity index 100% rename from tests/flattener_dicos/10masterslave_mandatory/makedict/base.json rename to tests/flattener_dicos/10leadership_familyaccent/makedict/base.json diff --git a/tests/flattener_dicos/10masterslaves_familyaccent/result/00-base.xml b/tests/flattener_dicos/10leadership_familyaccent/result/00-base.xml similarity index 100% rename from tests/flattener_dicos/10masterslaves_familyaccent/result/00-base.xml rename to tests/flattener_dicos/10leadership_familyaccent/result/00-base.xml diff --git a/tests/flattener_dicos/10masterslave_mastermandatory/00-base.xml b/tests/flattener_dicos/10leadership_leadermandatory/00-base.xml similarity index 100% rename from tests/flattener_dicos/10masterslave_mastermandatory/00-base.xml rename to tests/flattener_dicos/10leadership_leadermandatory/00-base.xml diff --git a/tests/flattener_dicos/10masterslave_mastermandatory/makedict/base.json b/tests/flattener_dicos/10leadership_leadermandatory/makedict/base.json similarity index 100% rename from tests/flattener_dicos/10masterslave_mastermandatory/makedict/base.json rename to tests/flattener_dicos/10leadership_leadermandatory/makedict/base.json diff --git a/tests/flattener_dicos/10masterslave_mastermandatory/result/00-base.xml b/tests/flattener_dicos/10leadership_leadermandatory/result/00-base.xml similarity index 100% rename from tests/flattener_dicos/10masterslave_mastermandatory/result/00-base.xml rename to tests/flattener_dicos/10leadership_leadermandatory/result/00-base.xml diff --git a/tests/flattener_dicos/10masterslave_mandatory/00-base.xml b/tests/flattener_dicos/10leadership_mandatory/00-base.xml similarity index 100% rename from tests/flattener_dicos/10masterslave_mandatory/00-base.xml rename to tests/flattener_dicos/10leadership_mandatory/00-base.xml diff --git a/tests/flattener_dicos/10masterslaves_familyaccent/makedict/base.json b/tests/flattener_dicos/10leadership_mandatory/makedict/base.json similarity index 100% rename from tests/flattener_dicos/10masterslaves_familyaccent/makedict/base.json rename to tests/flattener_dicos/10leadership_mandatory/makedict/base.json diff --git a/tests/flattener_dicos/10masterslave_mandatory/result/00-base.xml b/tests/flattener_dicos/10leadership_mandatory/result/00-base.xml similarity index 100% rename from tests/flattener_dicos/10masterslave_mandatory/result/00-base.xml rename to tests/flattener_dicos/10leadership_mandatory/result/00-base.xml diff --git a/tests/flattener_dicos/10masterslave_mandatoryslave/00-base.xml b/tests/flattener_dicos/10leadership_mandatoryfollower/00-base.xml similarity index 100% rename from tests/flattener_dicos/10masterslave_mandatoryslave/00-base.xml rename to tests/flattener_dicos/10leadership_mandatoryfollower/00-base.xml diff --git a/tests/flattener_dicos/10masterslave_mandatoryslave/makedict/base.json b/tests/flattener_dicos/10leadership_mandatoryfollower/makedict/base.json similarity index 100% rename from tests/flattener_dicos/10masterslave_mandatoryslave/makedict/base.json rename to tests/flattener_dicos/10leadership_mandatoryfollower/makedict/base.json diff --git a/tests/flattener_dicos/10masterslave_mandatoryslave/result/00-base.xml b/tests/flattener_dicos/10leadership_mandatoryfollower/result/00-base.xml similarity index 100% rename from tests/flattener_dicos/10masterslave_mandatoryslave/result/00-base.xml rename to tests/flattener_dicos/10leadership_mandatoryfollower/result/00-base.xml diff --git a/tests/flattener_dicos/10masterslave_multi/00-base.xml b/tests/flattener_dicos/10leadership_multi/00-base.xml similarity index 100% rename from tests/flattener_dicos/10masterslave_multi/00-base.xml rename to tests/flattener_dicos/10leadership_multi/00-base.xml diff --git a/tests/flattener_dicos/10masterslave_multi/makedict/base.json b/tests/flattener_dicos/10leadership_multi/makedict/base.json similarity index 100% rename from tests/flattener_dicos/10masterslave_multi/makedict/base.json rename to tests/flattener_dicos/10leadership_multi/makedict/base.json diff --git a/tests/flattener_dicos/10masterslave_multi/result/00-base.xml b/tests/flattener_dicos/10leadership_multi/result/00-base.xml similarity index 100% rename from tests/flattener_dicos/10masterslave_multi/result/00-base.xml rename to tests/flattener_dicos/10leadership_multi/result/00-base.xml diff --git a/tests/flattener_dicos/10masterslaves_append/00-base.xml b/tests/flattener_dicos/10load_leadership/00-base.xml similarity index 100% rename from tests/flattener_dicos/10masterslaves_append/00-base.xml rename to tests/flattener_dicos/10load_leadership/00-base.xml diff --git a/tests/flattener_dicos/10load_masterslaves/makedict/base.json b/tests/flattener_dicos/10load_leadership/makedict/base.json similarity index 100% rename from tests/flattener_dicos/10load_masterslaves/makedict/base.json rename to tests/flattener_dicos/10load_leadership/makedict/base.json diff --git a/tests/flattener_dicos/10load_masterslaves/result/00-base.xml b/tests/flattener_dicos/10load_leadership/result/00-base.xml similarity index 100% rename from tests/flattener_dicos/10load_masterslaves/result/00-base.xml rename to tests/flattener_dicos/10load_leadership/result/00-base.xml diff --git a/tests/flattener_dicos/10load_masterslaves_default_multi/00-base.xml b/tests/flattener_dicos/10load_leadership_default_multi/00-base.xml similarity index 100% rename from tests/flattener_dicos/10load_masterslaves_default_multi/00-base.xml rename to tests/flattener_dicos/10load_leadership_default_multi/00-base.xml diff --git a/tests/flattener_dicos/10load_masterslaves_default_multi/makedict/base.json b/tests/flattener_dicos/10load_leadership_default_multi/makedict/base.json similarity index 100% rename from tests/flattener_dicos/10load_masterslaves_default_multi/makedict/base.json rename to tests/flattener_dicos/10load_leadership_default_multi/makedict/base.json diff --git a/tests/flattener_dicos/10load_masterslaves_default_multi/result/00-base.xml b/tests/flattener_dicos/10load_leadership_default_multi/result/00-base.xml similarity index 100% rename from tests/flattener_dicos/10load_masterslaves_default_multi/result/00-base.xml rename to tests/flattener_dicos/10load_leadership_default_multi/result/00-base.xml diff --git a/tests/flattener_dicos/10load_leadership_default_submulti/00-base.xml b/tests/flattener_dicos/10load_leadership_default_submulti/00-base.xml new file mode 100644 index 00000000..e161f0de --- /dev/null +++ b/tests/flattener_dicos/10load_leadership_default_submulti/00-base.xml @@ -0,0 +1,33 @@ + + + + + + + + + non + + + leader + + + value + + + value1 + value2 + + + + + + + follower1 + follower2 + + + + + + diff --git a/tests/flattener_dicos/10load_leadership_default_submulti/makedict/base.json b/tests/flattener_dicos/10load_leadership_default_submulti/makedict/base.json new file mode 100644 index 00000000..7c8f0444 --- /dev/null +++ b/tests/flattener_dicos/10load_leadership_default_submulti/makedict/base.json @@ -0,0 +1 @@ +{"creole.general.mode_conteneur_actif": ["non"], "creole.general.leader.leader": ["leader"], "creole.general.leader.follower1": [["value"]], "creole.general.leader.follower2": [["value1", "value2"]]} diff --git a/tests/flattener_dicos/10load_leadership_default_submulti/result/00-base.xml b/tests/flattener_dicos/10load_leadership_default_submulti/result/00-base.xml new file mode 100644 index 00000000..e3db58a9 --- /dev/null +++ b/tests/flattener_dicos/10load_leadership_default_submulti/result/00-base.xml @@ -0,0 +1,33 @@ + + + + + normal + + oui + non + mandatory + normal + non + + + normal + + mandatory + leader + + + mandatory + normal + value + + + mandatory + normal + value1 + value2 + + + + + diff --git a/tests/flattener_dicos/10load_masterslaves_defaultmulti_master/00-base.xml b/tests/flattener_dicos/10load_leadership_defaultmulti_leader/00-base.xml similarity index 100% rename from tests/flattener_dicos/10load_masterslaves_defaultmulti_master/00-base.xml rename to tests/flattener_dicos/10load_leadership_defaultmulti_leader/00-base.xml diff --git a/tests/flattener_dicos/10load_masterslaves_defaultmulti_master/makedict/base.json b/tests/flattener_dicos/10load_leadership_defaultmulti_leader/makedict/base.json similarity index 100% rename from tests/flattener_dicos/10load_masterslaves_defaultmulti_master/makedict/base.json rename to tests/flattener_dicos/10load_leadership_defaultmulti_leader/makedict/base.json diff --git a/tests/flattener_dicos/10load_masterslaves_defaultmulti_master/result/00-base.xml b/tests/flattener_dicos/10load_leadership_defaultmulti_leader/result/00-base.xml similarity index 100% rename from tests/flattener_dicos/10load_masterslaves_defaultmulti_master/result/00-base.xml rename to tests/flattener_dicos/10load_leadership_defaultmulti_leader/result/00-base.xml diff --git a/tests/flattener_dicos/10load_masterslaves_description/00-base.xml b/tests/flattener_dicos/10load_leadership_description/00-base.xml similarity index 100% rename from tests/flattener_dicos/10load_masterslaves_description/00-base.xml rename to tests/flattener_dicos/10load_leadership_description/00-base.xml diff --git a/tests/flattener_dicos/10load_masterslaves_description/makedict/base.json b/tests/flattener_dicos/10load_leadership_description/makedict/base.json similarity index 100% rename from tests/flattener_dicos/10load_masterslaves_description/makedict/base.json rename to tests/flattener_dicos/10load_leadership_description/makedict/base.json diff --git a/tests/flattener_dicos/10load_masterslaves_description/result/00-base.xml b/tests/flattener_dicos/10load_leadership_description/result/00-base.xml similarity index 100% rename from tests/flattener_dicos/10load_masterslaves_description/result/00-base.xml rename to tests/flattener_dicos/10load_leadership_description/result/00-base.xml diff --git a/tests/flattener_dicos/10load_masterslaves_normalize_family/00-base.xml b/tests/flattener_dicos/10load_leadership_normalize_family/00-base.xml similarity index 100% rename from tests/flattener_dicos/10load_masterslaves_normalize_family/00-base.xml rename to tests/flattener_dicos/10load_leadership_normalize_family/00-base.xml diff --git a/tests/flattener_dicos/10load_masterslaves_normalize_family/01-base.xml b/tests/flattener_dicos/10load_leadership_normalize_family/01-base.xml similarity index 100% rename from tests/flattener_dicos/10load_masterslaves_normalize_family/01-base.xml rename to tests/flattener_dicos/10load_leadership_normalize_family/01-base.xml diff --git a/tests/flattener_dicos/10load_masterslaves_normalize_family/makedict/base.json b/tests/flattener_dicos/10load_leadership_normalize_family/makedict/base.json similarity index 100% rename from tests/flattener_dicos/10load_masterslaves_normalize_family/makedict/base.json rename to tests/flattener_dicos/10load_leadership_normalize_family/makedict/base.json diff --git a/tests/flattener_dicos/10load_masterslaves_normalize_family/result/00-base.xml b/tests/flattener_dicos/10load_leadership_normalize_family/result/00-base.xml similarity index 100% rename from tests/flattener_dicos/10load_masterslaves_normalize_family/result/00-base.xml rename to tests/flattener_dicos/10load_leadership_normalize_family/result/00-base.xml diff --git a/tests/flattener_dicos/10load_leadership_submulti/00-base.xml b/tests/flattener_dicos/10load_leadership_submulti/00-base.xml new file mode 100644 index 00000000..3d4b93ed --- /dev/null +++ b/tests/flattener_dicos/10load_leadership_submulti/00-base.xml @@ -0,0 +1,34 @@ + + + + + + + + + non + + + + + + + + + + + + valfill + + + follower1 + + + follower1 + follower2 + + + + + + diff --git a/tests/flattener_dicos/10load_leadership_submulti/makedict/base.json b/tests/flattener_dicos/10load_leadership_submulti/makedict/base.json new file mode 100644 index 00000000..7637dca2 --- /dev/null +++ b/tests/flattener_dicos/10load_leadership_submulti/makedict/base.json @@ -0,0 +1 @@ +{"creole.general.mode_conteneur_actif": "non", "creole.general1.leader.leader": [], "creole.general1.leader.follower1": [], "creole.general1.leader.follower2": []} diff --git a/tests/flattener_dicos/10load_leadership_submulti/result/00-base.xml b/tests/flattener_dicos/10load_leadership_submulti/result/00-base.xml new file mode 100644 index 00000000..12ae000d --- /dev/null +++ b/tests/flattener_dicos/10load_leadership_submulti/result/00-base.xml @@ -0,0 +1,34 @@ + + + + + normal + + oui + non + mandatory + normal + non + + + + normal + + normal + + + normal + + valfill + + + + normal + + creole.general1.leader.follower1 + + + + + + diff --git a/tests/flattener_dicos/10load_submulti_two_value/00-base.xml b/tests/flattener_dicos/10load_submulti_two_value/00-base.xml new file mode 100644 index 00000000..49c2fe25 --- /dev/null +++ b/tests/flattener_dicos/10load_submulti_two_value/00-base.xml @@ -0,0 +1,23 @@ + + + + + + + + + non + oui + + + + + + + + + + + + diff --git a/tests/flattener_dicos/10load_submulti_two_value/makedict/base.json b/tests/flattener_dicos/10load_submulti_two_value/makedict/base.json new file mode 100644 index 00000000..a36d5a83 --- /dev/null +++ b/tests/flattener_dicos/10load_submulti_two_value/makedict/base.json @@ -0,0 +1 @@ +{"creole.general.mode_conteneur_actif": [["non"], ["oui"]]} diff --git a/tests/flattener_dicos/10load_submulti_two_value/result/00-base.xml b/tests/flattener_dicos/10load_submulti_two_value/result/00-base.xml new file mode 100644 index 00000000..ef247d1b --- /dev/null +++ b/tests/flattener_dicos/10load_submulti_two_value/result/00-base.xml @@ -0,0 +1,17 @@ + + + + + normal + + oui + non + mandatory + normal + non + oui + + + + + diff --git a/tests/flattener_dicos/10valid_enum_master/00-base.xml b/tests/flattener_dicos/10valid_enum_leader/00-base.xml similarity index 100% rename from tests/flattener_dicos/10valid_enum_master/00-base.xml rename to tests/flattener_dicos/10valid_enum_leader/00-base.xml diff --git a/tests/flattener_dicos/10valid_enum_master/makedict/base.json b/tests/flattener_dicos/10valid_enum_leader/makedict/base.json similarity index 100% rename from tests/flattener_dicos/10valid_enum_master/makedict/base.json rename to tests/flattener_dicos/10valid_enum_leader/makedict/base.json diff --git a/tests/flattener_dicos/10valid_enum_master/result/00-base.xml b/tests/flattener_dicos/10valid_enum_leader/result/00-base.xml similarity index 100% rename from tests/flattener_dicos/10valid_enum_master/result/00-base.xml rename to tests/flattener_dicos/10valid_enum_leader/result/00-base.xml diff --git a/tests/flattener_dicos/20family_modemasterslaves/00-base.xml b/tests/flattener_dicos/20family_modeleadership/00-base.xml similarity index 100% rename from tests/flattener_dicos/20family_modemasterslaves/00-base.xml rename to tests/flattener_dicos/20family_modeleadership/00-base.xml diff --git a/tests/flattener_dicos/20family_modemasterslaves/makedict/base.json b/tests/flattener_dicos/20family_modeleadership/makedict/base.json similarity index 100% rename from tests/flattener_dicos/20family_modemasterslaves/makedict/base.json rename to tests/flattener_dicos/20family_modeleadership/makedict/base.json diff --git a/tests/flattener_dicos/20family_modemasterslaves/result/00-base.xml b/tests/flattener_dicos/20family_modeleadership/result/00-base.xml similarity index 100% rename from tests/flattener_dicos/20family_modemasterslaves/result/00-base.xml rename to tests/flattener_dicos/20family_modeleadership/result/00-base.xml diff --git a/tests/flattener_dicos/40ifin_masterslaves/00-base.xml b/tests/flattener_dicos/40ifin_leadership/00-base.xml similarity index 100% rename from tests/flattener_dicos/40ifin_masterslaves/00-base.xml rename to tests/flattener_dicos/40ifin_leadership/00-base.xml diff --git a/tests/flattener_dicos/40ifin_masterslaves/makedict/base.json b/tests/flattener_dicos/40ifin_leadership/makedict/base.json similarity index 100% rename from tests/flattener_dicos/40ifin_masterslaves/makedict/base.json rename to tests/flattener_dicos/40ifin_leadership/makedict/base.json diff --git a/tests/flattener_dicos/40ifin_masterslaves/result/00-base.xml b/tests/flattener_dicos/40ifin_leadership/result/00-base.xml similarity index 100% rename from tests/flattener_dicos/40ifin_masterslaves/result/00-base.xml rename to tests/flattener_dicos/40ifin_leadership/result/00-base.xml diff --git a/tests/flattener_dicos/40ifin_masterslavesauto/00-base.xml b/tests/flattener_dicos/40ifin_leadershipauto/00-base.xml similarity index 100% rename from tests/flattener_dicos/40ifin_masterslavesauto/00-base.xml rename to tests/flattener_dicos/40ifin_leadershipauto/00-base.xml diff --git a/tests/flattener_dicos/40ifin_masterslavesauto/makedict/base.json b/tests/flattener_dicos/40ifin_leadershipauto/makedict/base.json similarity index 100% rename from tests/flattener_dicos/40ifin_masterslavesauto/makedict/base.json rename to tests/flattener_dicos/40ifin_leadershipauto/makedict/base.json diff --git a/tests/flattener_dicos/40ifin_masterslavesauto/result/00-base.xml b/tests/flattener_dicos/40ifin_leadershipauto/result/00-base.xml similarity index 100% rename from tests/flattener_dicos/40ifin_masterslavesauto/result/00-base.xml rename to tests/flattener_dicos/40ifin_leadershipauto/result/00-base.xml diff --git a/tests/flattener_dicos/70container_pathaccess_masterslaves/00-base.xml b/tests/flattener_dicos/70container_pathaccess_leadership/00-base.xml similarity index 100% rename from tests/flattener_dicos/70container_pathaccess_masterslaves/00-base.xml rename to tests/flattener_dicos/70container_pathaccess_leadership/00-base.xml diff --git a/tests/flattener_dicos/70container_pathaccess_masterslaves/makedict/base.json b/tests/flattener_dicos/70container_pathaccess_leadership/makedict/base.json similarity index 100% rename from tests/flattener_dicos/70container_pathaccess_masterslaves/makedict/base.json rename to tests/flattener_dicos/70container_pathaccess_leadership/makedict/base.json diff --git a/tests/flattener_dicos/70container_pathaccess_masterslaves/result/00-base.xml b/tests/flattener_dicos/70container_pathaccess_leadership/result/00-base.xml similarity index 100% rename from tests/flattener_dicos/70container_pathaccess_masterslaves/result/00-base.xml rename to tests/flattener_dicos/70container_pathaccess_leadership/result/00-base.xml diff --git a/tests/flattener_dicos/80masterslave_auto_save/00-base.xml b/tests/flattener_dicos/80leadership_auto_save/00-base.xml similarity index 100% rename from tests/flattener_dicos/80masterslave_auto_save/00-base.xml rename to tests/flattener_dicos/80leadership_auto_save/00-base.xml diff --git a/tests/flattener_dicos/80masterslaves_autofreeze/00-base.xml b/tests/flattener_dicos/80leadership_autofreeze/00-base.xml similarity index 100% rename from tests/flattener_dicos/80masterslaves_autofreeze/00-base.xml rename to tests/flattener_dicos/80leadership_autofreeze/00-base.xml diff --git a/tests/flattener_dicos/80leadership_none_slave_between_slave/00-base.xml b/tests/flattener_dicos/80leadership_none_follower_between_follower/00-base.xml similarity index 100% rename from tests/flattener_dicos/80leadership_none_slave_between_slave/00-base.xml rename to tests/flattener_dicos/80leadership_none_follower_between_follower/00-base.xml diff --git a/tests/flattener_dicos/80masterslave_notexists/00-base.xml b/tests/flattener_dicos/80leadership_notexists/00-base.xml similarity index 100% rename from tests/flattener_dicos/80masterslave_notexists/00-base.xml rename to tests/flattener_dicos/80leadership_notexists/00-base.xml diff --git a/tests/flattener_dicos/80masterslaves_notmulti/00-base.xml b/tests/flattener_dicos/80leadership_notmulti/00-base.xml similarity index 100% rename from tests/flattener_dicos/80masterslaves_notmulti/00-base.xml rename to tests/flattener_dicos/80leadership_notmulti/00-base.xml diff --git a/tests/test_flattener.py b/tests/test_flattener.py index 7de333c1..9fa081df 100644 --- a/tests/test_flattener.py +++ b/tests/test_flattener.py @@ -65,7 +65,7 @@ def compare_xml(exported_xmlfile, expected_xmlfile): raise err -def launch_flattener(test_dir): +def launch_flattener(test_dir, test_ok=False): eolobj = objspace.CreoleObjSpace(dtdfilename) dirs = [test_dir] subfolder = join(test_dir, 'subfolder') @@ -85,6 +85,8 @@ def launch_flattener(test_dir): if isfile(result_file): # eolobj.save(result_file) compare_xml(destfile, result_file) + elif test_ok: + raise Exception(f'no test found for {test_dir}') def fake_traduc(txt): @@ -105,7 +107,7 @@ def teardown_module(module): def test_dictionary(test_dir): test_dir = join(dico_dirs, test_dir) - launch_flattener(test_dir) + launch_flattener(test_dir, True) def test_error_dictionary(test_dir_error): diff --git a/tests/test_makedict.py b/tests/test_makedict.py index ad06af80..dcbc16d1 100644 --- a/tests/test_makedict.py +++ b/tests/test_makedict.py @@ -24,7 +24,7 @@ for test in listdir(dico_dirs): excludes = set([]) #excludes = set(['70container_services']) test_ok -= excludes -#test_ok = ['70container_services'] +#test_ok = ['10load_leadership_default_submulti'] test_ok = list(test_ok) From 5b4b43d5f492734b646dafb6d40e27c151813b3a Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 23 Apr 2020 07:34:34 +0200 Subject: [PATCH 06/32] is not necessarily a template + add tag to override systemd service --- src/rougail/annotator.py | 5 +- src/rougail/data/rougail.dtd | 7 +- src/rougail/template.py | 72 ++++++++++++------- .../11disabled_if_in_filelist/00-base.xml | 2 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 6 +- .../00-base.xml | 2 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 6 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 8 +++ .../makedict/base.json | 2 +- .../result/00-base.xml | 4 ++ .../makedict/base.json | 2 +- .../result/00-base.xml | 4 ++ .../makedict/base.json | 2 +- .../result/00-base.xml | 4 ++ .../makedict/base.json | 2 +- .../result/00-base.xml | 4 ++ .../makedict/base.json | 2 +- .../result/00-base.xml | 4 ++ .../20notemplating/00-base.xml | 20 ++++++ .../20notemplating/makedict/base.json | 1 + .../20notemplating/result/00-base.xml | 61 ++++++++++++++++ tests/flattener_dicos/20override/00-base.xml | 20 ++++++ .../20override/makedict/base.json | 1 + .../20override/result/00-base.xml | 41 +++++++++++ .../60extra_group/makedict/base.json | 2 +- .../60extra_group/result/00-base.xml | 4 ++ .../60extra_help/makedict/base.json | 2 +- .../60extra_help/result/00-base.xml | 4 ++ .../70container_files/makedict/base.json | 2 +- .../70container_files/result/00-base.xml | 4 ++ .../makedict/base.json | 2 +- .../result/00-base.xml | 4 ++ .../makedict/base.json | 2 +- .../result/00-base.xml | 4 ++ .../70container_filesmulti/makedict/base.json | 2 +- .../70container_filesmulti/result/00-base.xml | 8 +++ .../makedict/base.json | 2 +- .../result/00-base.xml | 4 ++ .../70container_filesrm/makedict/base.json | 2 +- .../70container_filesrm/result/00-base.xml | 4 ++ .../11disabled_if_in_filelist/00-base.xml | 4 ++ .../00-base.xml | 6 +- .../result/rougail.conf | 1 + tests/templates/20notemplating/00-base.xml | 61 ++++++++++++++++ .../templates/20notemplating/result/etc/file | 1 + .../20notemplating/result/rougail.conf | 2 + tests/templates/20notemplating/tmpl/file | 1 + tests/templates/20override/00-base.xml | 41 +++++++++++ .../templates/20override/result/rougail.conf | 1 + .../result/system/test.service.d/rougail.conf | 1 + tests/templates/20override/tmpl/test.service | 1 + tests/templates/60extra_group/00-base.xml | 4 ++ tests/templates/70container_files/00-base.xml | 4 ++ .../00-base.xml | 4 ++ .../00-base.xml | 4 ++ tests/test_flattener.py | 2 +- tests/test_makedict.py | 12 ++-- tests/test_template.py | 5 +- 61 files changed, 438 insertions(+), 57 deletions(-) create mode 100644 tests/flattener_dicos/20notemplating/00-base.xml create mode 100644 tests/flattener_dicos/20notemplating/makedict/base.json create mode 100644 tests/flattener_dicos/20notemplating/result/00-base.xml create mode 100644 tests/flattener_dicos/20override/00-base.xml create mode 100644 tests/flattener_dicos/20override/makedict/base.json create mode 100644 tests/flattener_dicos/20override/result/00-base.xml create mode 100644 tests/templates/11disabled_if_in_filelist_disabled/result/rougail.conf create mode 100644 tests/templates/20notemplating/00-base.xml create mode 100644 tests/templates/20notemplating/result/etc/file create mode 100644 tests/templates/20notemplating/result/rougail.conf create mode 100644 tests/templates/20notemplating/tmpl/file create mode 100644 tests/templates/20override/00-base.xml create mode 100644 tests/templates/20override/result/rougail.conf create mode 100644 tests/templates/20override/result/system/test.service.d/rougail.conf create mode 100644 tests/templates/20override/tmpl/test.service diff --git a/src/rougail/annotator.py b/src/rougail/annotator.py index 0c0e6185..0edc0e44 100644 --- a/src/rougail/annotator.py +++ b/src/rougail/annotator.py @@ -242,8 +242,11 @@ class ServiceAnnotator: ) return variable + def _update_override(self, file_, index, service_path): + self._update_file(file_, index, service_path) + def _update_file(self, file_, index, service_path): - if file_.file_type == "UnicodeOption": + if not hasattr(file_, 'file_type') or file_.file_type == "UnicodeOption": if not hasattr(file_, 'source'): file_.source = basename(file_.name) elif not hasattr(file_, 'source'): diff --git a/src/rougail/data/rougail.dtd b/src/rougail/data/rougail.dtd index df054016..555c7397 100644 --- a/src/rougail/data/rougail.dtd +++ b/src/rougail/data/rougail.dtd @@ -66,7 +66,7 @@ - + @@ -109,6 +109,7 @@ + @@ -118,6 +119,10 @@ + + + + diff --git a/src/rougail/template.py b/src/rougail/template.py index 928e7f70..e9e9a0ed 100644 --- a/src/rougail/template.py +++ b/src/rougail/template.py @@ -261,11 +261,14 @@ class CreoleTemplateEngine: eosfunc_file: str, distrib_dir: str, tmp_dir: str, - dest_dir:str) -> None: + dest_dir: str, + tmpfile_name: str, + ) -> None: self.config = config self.dest_dir = dest_dir self.tmp_dir = tmp_dir self.distrib_dir = distrib_dir + self.tmpfile_name = tmpfile_name eos = {} if eosfunc_file is not None: eosfunc = imp.load_source('eosfunc', eosfunc_file) @@ -342,6 +345,7 @@ class CreoleTemplateEngine: self.patch_template(filename) def process(self, + source: str, destfilename: str, filevar: Dict, variable: Any): @@ -350,8 +354,7 @@ class CreoleTemplateEngine: # full path of the destination file log.info(_(f"Cheetah processing: '{destfilename}'")) try: - cheetah_template = CheetahTemplate(join(self.tmp_dir, - filevar['source']), + cheetah_template = CheetahTemplate(source, self.creole_variables_dict, self.eosfunc, destfilename, @@ -368,19 +371,24 @@ class CreoleTemplateEngine: def instance_file(self, filevar: Dict, - systemd_rights: list) -> None: + systemd_rights: list, + override: bool, + service_name: str) -> None: """Run templatisation on one file """ log.info(_("Instantiating file '{filename}'")) - filenames = filevar['name'] if 'variable' in filevar: variable = filevar['variable'] else: variable = None - if not isinstance(filenames, list): - filenames = [filenames] - if variable: - variable = [variable] + if override: + filenames = [f'/system/{service_name}.service.d/rougail.conf'] + else: + filenames = filevar['name'] + if not isinstance(filenames, list): + filenames = [filenames] + if variable: + variable = [variable] for idx, filename in enumerate(filenames): destfilename = join(self.dest_dir, filename[1:]) @@ -389,11 +397,17 @@ class CreoleTemplateEngine: var = variable[idx] else: var = None - self.process(destfilename, - filevar, - var) - systemd_rights.append(f'C {filename} {filevar["mode"]} {filevar["owner"]} {filevar["group"]} - -') - systemd_rights.append(f'z {filename} - - - - -') + source = join(self.tmp_dir, filevar['source']) + if filevar['templating']: + self.process(source, + destfilename, + filevar, + var) + else: + copy(source, destfilename) + if not override and self.tmpfile_name: + systemd_rights.append(f'C {filename} {filevar["mode"]} {filevar["owner"]} {filevar["group"]} - -') + systemd_rights.append(f'z {filename} - - - - -') async def instance_files(self) -> None: """Run templatisation on all files @@ -411,33 +425,41 @@ class CreoleTemplateEngine: self.prepare_template(join(self.distrib_dir, template)) systemd_rights = [] for service_obj in await self.config.option('services').list('all'): + service_name = await service_obj.option.doc() for fills in await service_obj.list('all'): - if await fills.option.name() == 'files': + if await fills.option.name() in ['files', 'overrides']: for fill_obj in await fills.list('all'): fill = await fill_obj.value.dict() filename = fill['source'] distib_file = join(self.distrib_dir, filename) if not isfile(distib_file): raise FileNotFound(_(f"File {distib_file} does not exist.")) - if fill.get('activate', False): + override = await fills.option.name() == 'overrides' + if override or fill.get('activate', False): self.instance_file(fill, - systemd_rights) + systemd_rights, + override, + service_name, + ) else: log.debug(_("Instantiation of file '{filename}' disabled")) - with open(join(self.dest_dir, 'rougail.conf'), 'w') as fh: - fh.write('\n'.join(systemd_rights)) - fh.write('\n') + if self.tmpfile_name: + with open(self.tmpfile_name, 'w') as fh: + fh.write('\n'.join(systemd_rights)) + fh.write('\n') async def generate(config: Config, - eosfunc_file: str, - distrib_dir: str, - tmp_dir: str, - dest_dir: str) -> None: + eosfunc_file: str, + distrib_dir: str, + tmp_dir: str, + dest_dir: str, + tmpfile_name: str=None) -> None: engine = CreoleTemplateEngine(config, eosfunc_file, distrib_dir, tmp_dir, - dest_dir) + dest_dir, + tmpfile_name) await engine.instance_files() diff --git a/tests/flattener_dicos/11disabled_if_in_filelist/00-base.xml b/tests/flattener_dicos/11disabled_if_in_filelist/00-base.xml index 03c6b9d3..e9e2d1cd 100644 --- a/tests/flattener_dicos/11disabled_if_in_filelist/00-base.xml +++ b/tests/flattener_dicos/11disabled_if_in_filelist/00-base.xml @@ -3,7 +3,7 @@ - + diff --git a/tests/flattener_dicos/11disabled_if_in_filelist/makedict/base.json b/tests/flattener_dicos/11disabled_if_in_filelist/makedict/base.json index 4547d403..ef363b98 100644 --- a/tests/flattener_dicos/11disabled_if_in_filelist/makedict/base.json +++ b/tests/flattener_dicos/11disabled_if_in_filelist/makedict/base.json @@ -1 +1 @@ -{"creole.general.condition": "non", "creole.general.mode_conteneur_actif": "non", "creole.general.mode_conteneur_actif2": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file", "services.service0.files.file0.activate": true} +{"creole.general.condition": "non", "creole.general.mode_conteneur_actif": "non", "creole.general.mode_conteneur_actif2": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file", "services.service0.files.file0.templating": true, "services.service0.files.file0.activate": true} diff --git a/tests/flattener_dicos/11disabled_if_in_filelist/result/00-base.xml b/tests/flattener_dicos/11disabled_if_in_filelist/result/00-base.xml index 55b84d67..902c09b3 100644 --- a/tests/flattener_dicos/11disabled_if_in_filelist/result/00-base.xml +++ b/tests/flattener_dicos/11disabled_if_in_filelist/result/00-base.xml @@ -18,7 +18,7 @@ mandatory - /tmp/file + /etc/file mandatory @@ -32,6 +32,10 @@ mandatory file + + mandatory + True + mandatory disabled diff --git a/tests/flattener_dicos/11disabled_if_in_filelist_disabled/00-base.xml b/tests/flattener_dicos/11disabled_if_in_filelist_disabled/00-base.xml index 6ac8dfd3..3a9fbc96 100644 --- a/tests/flattener_dicos/11disabled_if_in_filelist_disabled/00-base.xml +++ b/tests/flattener_dicos/11disabled_if_in_filelist_disabled/00-base.xml @@ -3,7 +3,7 @@ - + diff --git a/tests/flattener_dicos/11disabled_if_in_filelist_disabled/makedict/base.json b/tests/flattener_dicos/11disabled_if_in_filelist_disabled/makedict/base.json index 93a8cfbd..624f287e 100644 --- a/tests/flattener_dicos/11disabled_if_in_filelist_disabled/makedict/base.json +++ b/tests/flattener_dicos/11disabled_if_in_filelist_disabled/makedict/base.json @@ -1 +1 @@ -{"creole.general.condition": "oui", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file"} +{"creole.general.condition": "oui", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file", "services.service0.files.file0.templating": true} diff --git a/tests/flattener_dicos/11disabled_if_in_filelist_disabled/result/00-base.xml b/tests/flattener_dicos/11disabled_if_in_filelist_disabled/result/00-base.xml index 1231859c..6faa8167 100644 --- a/tests/flattener_dicos/11disabled_if_in_filelist_disabled/result/00-base.xml +++ b/tests/flattener_dicos/11disabled_if_in_filelist_disabled/result/00-base.xml @@ -18,7 +18,7 @@ mandatory - /tmp/file + /etc/file mandatory @@ -32,6 +32,10 @@ mandatory file + + mandatory + True + mandatory disabled diff --git a/tests/flattener_dicos/11disabled_if_in_filelist_multi/makedict/base.json b/tests/flattener_dicos/11disabled_if_in_filelist_multi/makedict/base.json index 1d5c76fa..02962674 100644 --- a/tests/flattener_dicos/11disabled_if_in_filelist_multi/makedict/base.json +++ b/tests/flattener_dicos/11disabled_if_in_filelist_multi/makedict/base.json @@ -1 +1 @@ -{"creole.general.condition": "non", "creole.general.mode_conteneur_actif": "non", "creole.general.mode_conteneur_actif2": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file1", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file1", "services.service0.files.file0.activate": true, "services.service0.files.file1.group": "root", "services.service0.files.file1.mkdir": false, "services.service0.files.file1.mode": "0644", "services.service0.files.file1.name": "/tmp/file2", "services.service0.files.file1.owner": "root", "services.service0.files.file1.rm": false, "services.service0.files.file1.source": "file2", "services.service0.files.file1.activate": true} +{"creole.general.condition": "non", "creole.general.mode_conteneur_actif": "non", "creole.general.mode_conteneur_actif2": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file1", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file1", "services.service0.files.file0.templating": true, "services.service0.files.file0.activate": true, "services.service0.files.file1.group": "root", "services.service0.files.file1.mkdir": false, "services.service0.files.file1.mode": "0644", "services.service0.files.file1.name": "/tmp/file2", "services.service0.files.file1.owner": "root", "services.service0.files.file1.rm": false, "services.service0.files.file1.source": "file2", "services.service0.files.file1.templating": true, "services.service0.files.file1.activate": true} diff --git a/tests/flattener_dicos/11disabled_if_in_filelist_multi/result/00-base.xml b/tests/flattener_dicos/11disabled_if_in_filelist_multi/result/00-base.xml index 4134df57..84ed62e6 100644 --- a/tests/flattener_dicos/11disabled_if_in_filelist_multi/result/00-base.xml +++ b/tests/flattener_dicos/11disabled_if_in_filelist_multi/result/00-base.xml @@ -32,6 +32,10 @@ mandatory file1 + + mandatory + True + mandatory disabled @@ -67,6 +71,10 @@ mandatory file2 + + mandatory + True + mandatory disabled diff --git a/tests/flattener_dicos/11disabledifin_filelist_notexist/makedict/base.json b/tests/flattener_dicos/11disabledifin_filelist_notexist/makedict/base.json index 4905fa3c..8c818688 100644 --- a/tests/flattener_dicos/11disabledifin_filelist_notexist/makedict/base.json +++ b/tests/flattener_dicos/11disabledifin_filelist_notexist/makedict/base.json @@ -1 +1 @@ -{"creole.general.condition": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file"} +{"creole.general.condition": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file", "services.service0.files.file0.templating": true} diff --git a/tests/flattener_dicos/11disabledifin_filelist_notexist/result/00-base.xml b/tests/flattener_dicos/11disabledifin_filelist_notexist/result/00-base.xml index 426106d8..44710af0 100644 --- a/tests/flattener_dicos/11disabledifin_filelist_notexist/result/00-base.xml +++ b/tests/flattener_dicos/11disabledifin_filelist_notexist/result/00-base.xml @@ -32,6 +32,10 @@ mandatory file + + mandatory + True + disabled mandatory diff --git a/tests/flattener_dicos/11disabledifnotin_filelist_notexist/makedict/base.json b/tests/flattener_dicos/11disabledifnotin_filelist_notexist/makedict/base.json index 4905fa3c..8c818688 100644 --- a/tests/flattener_dicos/11disabledifnotin_filelist_notexist/makedict/base.json +++ b/tests/flattener_dicos/11disabledifnotin_filelist_notexist/makedict/base.json @@ -1 +1 @@ -{"creole.general.condition": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file"} +{"creole.general.condition": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file", "services.service0.files.file0.templating": true} diff --git a/tests/flattener_dicos/11disabledifnotin_filelist_notexist/result/00-base.xml b/tests/flattener_dicos/11disabledifnotin_filelist_notexist/result/00-base.xml index 426106d8..44710af0 100644 --- a/tests/flattener_dicos/11disabledifnotin_filelist_notexist/result/00-base.xml +++ b/tests/flattener_dicos/11disabledifnotin_filelist_notexist/result/00-base.xml @@ -32,6 +32,10 @@ mandatory file + + mandatory + True + disabled mandatory diff --git a/tests/flattener_dicos/11disabledifnotin_filelist_notexist_multi/makedict/base.json b/tests/flattener_dicos/11disabledifnotin_filelist_notexist_multi/makedict/base.json index 4905fa3c..8c818688 100644 --- a/tests/flattener_dicos/11disabledifnotin_filelist_notexist_multi/makedict/base.json +++ b/tests/flattener_dicos/11disabledifnotin_filelist_notexist_multi/makedict/base.json @@ -1 +1 @@ -{"creole.general.condition": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file"} +{"creole.general.condition": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file", "services.service0.files.file0.templating": true} diff --git a/tests/flattener_dicos/11disabledifnotin_filelist_notexist_multi/result/00-base.xml b/tests/flattener_dicos/11disabledifnotin_filelist_notexist_multi/result/00-base.xml index 426106d8..44710af0 100644 --- a/tests/flattener_dicos/11disabledifnotin_filelist_notexist_multi/result/00-base.xml +++ b/tests/flattener_dicos/11disabledifnotin_filelist_notexist_multi/result/00-base.xml @@ -32,6 +32,10 @@ mandatory file + + mandatory + True + disabled mandatory diff --git a/tests/flattener_dicos/11disabledifnotin_filelist_notexist_validenum/makedict/base.json b/tests/flattener_dicos/11disabledifnotin_filelist_notexist_validenum/makedict/base.json index 4905fa3c..8c818688 100644 --- a/tests/flattener_dicos/11disabledifnotin_filelist_notexist_validenum/makedict/base.json +++ b/tests/flattener_dicos/11disabledifnotin_filelist_notexist_validenum/makedict/base.json @@ -1 +1 @@ -{"creole.general.condition": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file"} +{"creole.general.condition": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file", "services.service0.files.file0.templating": true} diff --git a/tests/flattener_dicos/11disabledifnotin_filelist_notexist_validenum/result/00-base.xml b/tests/flattener_dicos/11disabledifnotin_filelist_notexist_validenum/result/00-base.xml index 3d688747..8fa31afb 100644 --- a/tests/flattener_dicos/11disabledifnotin_filelist_notexist_validenum/result/00-base.xml +++ b/tests/flattener_dicos/11disabledifnotin_filelist_notexist_validenum/result/00-base.xml @@ -32,6 +32,10 @@ mandatory file + + mandatory + True + mandatory disabled diff --git a/tests/flattener_dicos/11multi_disabled_if_in_filelist/makedict/base.json b/tests/flattener_dicos/11multi_disabled_if_in_filelist/makedict/base.json index c0f41953..9c1367cf 100644 --- a/tests/flattener_dicos/11multi_disabled_if_in_filelist/makedict/base.json +++ b/tests/flattener_dicos/11multi_disabled_if_in_filelist/makedict/base.json @@ -1 +1 @@ -{"creole.general.condition": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file1", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file1"} +{"creole.general.condition": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file1", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file1", "services.service0.files.file0.templating": true} diff --git a/tests/flattener_dicos/11multi_disabled_if_in_filelist/result/00-base.xml b/tests/flattener_dicos/11multi_disabled_if_in_filelist/result/00-base.xml index db8f324d..1ed40d7f 100644 --- a/tests/flattener_dicos/11multi_disabled_if_in_filelist/result/00-base.xml +++ b/tests/flattener_dicos/11multi_disabled_if_in_filelist/result/00-base.xml @@ -32,6 +32,10 @@ mandatory file1 + + mandatory + True + disabled mandatory diff --git a/tests/flattener_dicos/20notemplating/00-base.xml b/tests/flattener_dicos/20notemplating/00-base.xml new file mode 100644 index 00000000..e77aea14 --- /dev/null +++ b/tests/flattener_dicos/20notemplating/00-base.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + non + + + + + + diff --git a/tests/flattener_dicos/20notemplating/makedict/base.json b/tests/flattener_dicos/20notemplating/makedict/base.json new file mode 100644 index 00000000..4ad98959 --- /dev/null +++ b/tests/flattener_dicos/20notemplating/makedict/base.json @@ -0,0 +1 @@ +{"creole.general.mode_conteneur_actif": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file", "services.service0.files.file0.templating": false, "services.service0.files.file0.activate": true} diff --git a/tests/flattener_dicos/20notemplating/result/00-base.xml b/tests/flattener_dicos/20notemplating/result/00-base.xml new file mode 100644 index 00000000..45e172cf --- /dev/null +++ b/tests/flattener_dicos/20notemplating/result/00-base.xml @@ -0,0 +1,61 @@ + + + + + + + + mandatory + root + + + mandatory + False + + + mandatory + 0644 + + + mandatory + /etc/file + + + mandatory + root + + + mandatory + False + + + mandatory + file + + + mandatory + False + + + mandatory + True + + + + basic + + + + + normal + + oui + non + mandatory + normal + non + + + + + diff --git a/tests/flattener_dicos/20override/00-base.xml b/tests/flattener_dicos/20override/00-base.xml new file mode 100644 index 00000000..f3606bf7 --- /dev/null +++ b/tests/flattener_dicos/20override/00-base.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + non + + + + + + diff --git a/tests/flattener_dicos/20override/makedict/base.json b/tests/flattener_dicos/20override/makedict/base.json new file mode 100644 index 00000000..84573e71 --- /dev/null +++ b/tests/flattener_dicos/20override/makedict/base.json @@ -0,0 +1 @@ +{"creole.general.mode_conteneur_actif": "non", "services.service0.overrides.override0.name": "test.service", "services.service0.overrides.override0.source": "test.service", "services.service0.overrides.override0.templating": true, "services.service0.overrides.override0.activate": true} diff --git a/tests/flattener_dicos/20override/result/00-base.xml b/tests/flattener_dicos/20override/result/00-base.xml new file mode 100644 index 00000000..f59d3cfa --- /dev/null +++ b/tests/flattener_dicos/20override/result/00-base.xml @@ -0,0 +1,41 @@ + + + + + + + + mandatory + test.service + + + mandatory + test.service + + + mandatory + True + + + mandatory + True + + + + basic + + + + + normal + + oui + non + mandatory + normal + non + + + + + diff --git a/tests/flattener_dicos/60extra_group/makedict/base.json b/tests/flattener_dicos/60extra_group/makedict/base.json index ba1fd644..dc38f83f 100644 --- a/tests/flattener_dicos/60extra_group/makedict/base.json +++ b/tests/flattener_dicos/60extra_group/makedict/base.json @@ -1 +1 @@ -{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.activate": true, "extra.ejabberd.description.description": ["test"], "extra.ejabberd.description.mode": ["pre"]} +{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.templating": true, "services.service0.files.file0.activate": true, "extra.ejabberd.description.description": ["test"], "extra.ejabberd.description.mode": ["pre"]} diff --git a/tests/flattener_dicos/60extra_group/result/00-base.xml b/tests/flattener_dicos/60extra_group/result/00-base.xml index e9553cfb..637c73ea 100644 --- a/tests/flattener_dicos/60extra_group/result/00-base.xml +++ b/tests/flattener_dicos/60extra_group/result/00-base.xml @@ -32,6 +32,10 @@ mandatory mailname + + mandatory + True + mandatory True diff --git a/tests/flattener_dicos/60extra_help/makedict/base.json b/tests/flattener_dicos/60extra_help/makedict/base.json index 7256b5c7..d2a9b000 100644 --- a/tests/flattener_dicos/60extra_help/makedict/base.json +++ b/tests/flattener_dicos/60extra_help/makedict/base.json @@ -1 +1 @@ -{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.activate": true, "extra.ejabberd.description": "Exportation de la base de ejabberd", "extra.ejabberd.day": null, "extra.ejabberd.mode": "pre"} +{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.templating": true, "services.service0.files.file0.activate": true, "extra.ejabberd.description": "Exportation de la base de ejabberd", "extra.ejabberd.day": null, "extra.ejabberd.mode": "pre"} diff --git a/tests/flattener_dicos/60extra_help/result/00-base.xml b/tests/flattener_dicos/60extra_help/result/00-base.xml index c46f11b8..5157061b 100644 --- a/tests/flattener_dicos/60extra_help/result/00-base.xml +++ b/tests/flattener_dicos/60extra_help/result/00-base.xml @@ -32,6 +32,10 @@ mandatory mailname + + mandatory + True + mandatory True diff --git a/tests/flattener_dicos/70container_files/makedict/base.json b/tests/flattener_dicos/70container_files/makedict/base.json index e0b00845..a6feb5b6 100644 --- a/tests/flattener_dicos/70container_files/makedict/base.json +++ b/tests/flattener_dicos/70container_files/makedict/base.json @@ -1 +1 @@ -{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.activate": true} +{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.templating": true, "services.service0.files.file0.activate": true} diff --git a/tests/flattener_dicos/70container_files/result/00-base.xml b/tests/flattener_dicos/70container_files/result/00-base.xml index 4d1291b8..21035916 100644 --- a/tests/flattener_dicos/70container_files/result/00-base.xml +++ b/tests/flattener_dicos/70container_files/result/00-base.xml @@ -32,6 +32,10 @@ mandatory mailname + + mandatory + True + mandatory True diff --git a/tests/flattener_dicos/70container_files_symlink_multi/makedict/base.json b/tests/flattener_dicos/70container_files_symlink_multi/makedict/base.json index 6db8313c..d8f26274 100644 --- a/tests/flattener_dicos/70container_files_symlink_multi/makedict/base.json +++ b/tests/flattener_dicos/70container_files_symlink_multi/makedict/base.json @@ -1 +1 @@ -{"creole.general.file_name": ["/etc/mailname", "/etc/mailname2"], "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": ["/etc/mailname", "/etc/mailname2"], "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.activate": true} +{"creole.general.file_name": ["/etc/mailname", "/etc/mailname2"], "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": ["/etc/mailname", "/etc/mailname2"], "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.templating": true, "services.service0.files.file0.activate": true} diff --git a/tests/flattener_dicos/70container_files_symlink_multi/result/00-base.xml b/tests/flattener_dicos/70container_files_symlink_multi/result/00-base.xml index ba720294..d3cc83bb 100644 --- a/tests/flattener_dicos/70container_files_symlink_multi/result/00-base.xml +++ b/tests/flattener_dicos/70container_files_symlink_multi/result/00-base.xml @@ -31,6 +31,10 @@ mandatory mailname + + mandatory + True + mandatory True diff --git a/tests/flattener_dicos/70container_files_symlink_multi_variable/makedict/base.json b/tests/flattener_dicos/70container_files_symlink_multi_variable/makedict/base.json index b5cd7854..616edcdb 100644 --- a/tests/flattener_dicos/70container_files_symlink_multi_variable/makedict/base.json +++ b/tests/flattener_dicos/70container_files_symlink_multi_variable/makedict/base.json @@ -1 +1 @@ -{"creole.general.file_name": ["/etc/mailname", "/etc/mailname2"], "creole.general.var": ["mailname", "mailname2"], "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": ["/etc/mailname", "/etc/mailname2"], "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.variable": ["mailname", "mailname2"], "services.service0.files.file0.activate": true} +{"creole.general.file_name": ["/etc/mailname", "/etc/mailname2"], "creole.general.var": ["mailname", "mailname2"], "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": ["/etc/mailname", "/etc/mailname2"], "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.templating": true, "services.service0.files.file0.variable": ["mailname", "mailname2"], "services.service0.files.file0.activate": true} diff --git a/tests/flattener_dicos/70container_files_symlink_multi_variable/result/00-base.xml b/tests/flattener_dicos/70container_files_symlink_multi_variable/result/00-base.xml index 478c116a..9111a927 100644 --- a/tests/flattener_dicos/70container_files_symlink_multi_variable/result/00-base.xml +++ b/tests/flattener_dicos/70container_files_symlink_multi_variable/result/00-base.xml @@ -31,6 +31,10 @@ mandatory mailname + + mandatory + True + mandatory diff --git a/tests/flattener_dicos/70container_filesmulti/makedict/base.json b/tests/flattener_dicos/70container_filesmulti/makedict/base.json index 67e63a50..c3de456b 100644 --- a/tests/flattener_dicos/70container_filesmulti/makedict/base.json +++ b/tests/flattener_dicos/70container_filesmulti/makedict/base.json @@ -1 +1 @@ -{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.activate": true, "services.service0.files.file1.group": "root", "services.service0.files.file1.mkdir": false, "services.service0.files.file1.mode": "0644", "services.service0.files.file1.name": "/etc/mailname2", "services.service0.files.file1.owner": "root", "services.service0.files.file1.rm": false, "services.service0.files.file1.source": "mailname2", "services.service0.files.file1.activate": true} +{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.templating": true, "services.service0.files.file0.activate": true, "services.service0.files.file1.group": "root", "services.service0.files.file1.mkdir": false, "services.service0.files.file1.mode": "0644", "services.service0.files.file1.name": "/etc/mailname2", "services.service0.files.file1.owner": "root", "services.service0.files.file1.rm": false, "services.service0.files.file1.source": "mailname2", "services.service0.files.file1.templating": true, "services.service0.files.file1.activate": true} diff --git a/tests/flattener_dicos/70container_filesmulti/result/00-base.xml b/tests/flattener_dicos/70container_filesmulti/result/00-base.xml index 778c82e3..5c5b10aa 100644 --- a/tests/flattener_dicos/70container_filesmulti/result/00-base.xml +++ b/tests/flattener_dicos/70container_filesmulti/result/00-base.xml @@ -32,6 +32,10 @@ mandatory mailname + + mandatory + True + mandatory True @@ -66,6 +70,10 @@ mandatory mailname2 + + mandatory + True + mandatory True diff --git a/tests/flattener_dicos/70container_filesredefine/makedict/base.json b/tests/flattener_dicos/70container_filesredefine/makedict/base.json index 59f72760..e668ece0 100644 --- a/tests/flattener_dicos/70container_filesredefine/makedict/base.json +++ b/tests/flattener_dicos/70container_filesredefine/makedict/base.json @@ -1 +1 @@ -{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname.new", "services.service0.files.file0.activate": true} +{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname.new", "services.service0.files.file0.templating": true, "services.service0.files.file0.activate": true} diff --git a/tests/flattener_dicos/70container_filesredefine/result/00-base.xml b/tests/flattener_dicos/70container_filesredefine/result/00-base.xml index 2f75ed75..55000c8a 100644 --- a/tests/flattener_dicos/70container_filesredefine/result/00-base.xml +++ b/tests/flattener_dicos/70container_filesredefine/result/00-base.xml @@ -32,6 +32,10 @@ mandatory mailname.new + + mandatory + True + mandatory True diff --git a/tests/flattener_dicos/70container_filesrm/makedict/base.json b/tests/flattener_dicos/70container_filesrm/makedict/base.json index 513e7ba8..5a9c9716 100644 --- a/tests/flattener_dicos/70container_filesrm/makedict/base.json +++ b/tests/flattener_dicos/70container_filesrm/makedict/base.json @@ -1 +1 @@ -{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": true, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.activate": true} +{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": true, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.templating": true, "services.service0.files.file0.activate": true} diff --git a/tests/flattener_dicos/70container_filesrm/result/00-base.xml b/tests/flattener_dicos/70container_filesrm/result/00-base.xml index e98ad2f1..ad0f1c88 100644 --- a/tests/flattener_dicos/70container_filesrm/result/00-base.xml +++ b/tests/flattener_dicos/70container_filesrm/result/00-base.xml @@ -32,6 +32,10 @@ mandatory mailname + + mandatory + True + mandatory True diff --git a/tests/templates/11disabled_if_in_filelist/00-base.xml b/tests/templates/11disabled_if_in_filelist/00-base.xml index f7f8c1a1..902c09b3 100644 --- a/tests/templates/11disabled_if_in_filelist/00-base.xml +++ b/tests/templates/11disabled_if_in_filelist/00-base.xml @@ -32,6 +32,10 @@ mandatory file + + mandatory + True + mandatory disabled diff --git a/tests/templates/11disabled_if_in_filelist_disabled/00-base.xml b/tests/templates/11disabled_if_in_filelist_disabled/00-base.xml index 1231859c..6faa8167 100644 --- a/tests/templates/11disabled_if_in_filelist_disabled/00-base.xml +++ b/tests/templates/11disabled_if_in_filelist_disabled/00-base.xml @@ -18,7 +18,7 @@ mandatory - /tmp/file + /etc/file mandatory @@ -32,6 +32,10 @@ mandatory file + + mandatory + True + mandatory disabled diff --git a/tests/templates/11disabled_if_in_filelist_disabled/result/rougail.conf b/tests/templates/11disabled_if_in_filelist_disabled/result/rougail.conf new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/tests/templates/11disabled_if_in_filelist_disabled/result/rougail.conf @@ -0,0 +1 @@ + diff --git a/tests/templates/20notemplating/00-base.xml b/tests/templates/20notemplating/00-base.xml new file mode 100644 index 00000000..45e172cf --- /dev/null +++ b/tests/templates/20notemplating/00-base.xml @@ -0,0 +1,61 @@ + + + + + + + + mandatory + root + + + mandatory + False + + + mandatory + 0644 + + + mandatory + /etc/file + + + mandatory + root + + + mandatory + False + + + mandatory + file + + + mandatory + False + + + mandatory + True + + + + basic + + + + + normal + + oui + non + mandatory + normal + non + + + + + diff --git a/tests/templates/20notemplating/result/etc/file b/tests/templates/20notemplating/result/etc/file new file mode 100644 index 00000000..5113d9aa --- /dev/null +++ b/tests/templates/20notemplating/result/etc/file @@ -0,0 +1 @@ +%%condition diff --git a/tests/templates/20notemplating/result/rougail.conf b/tests/templates/20notemplating/result/rougail.conf new file mode 100644 index 00000000..481d9601 --- /dev/null +++ b/tests/templates/20notemplating/result/rougail.conf @@ -0,0 +1,2 @@ +C /etc/file 0644 root root - - +z /etc/file - - - - - diff --git a/tests/templates/20notemplating/tmpl/file b/tests/templates/20notemplating/tmpl/file new file mode 100644 index 00000000..5113d9aa --- /dev/null +++ b/tests/templates/20notemplating/tmpl/file @@ -0,0 +1 @@ +%%condition diff --git a/tests/templates/20override/00-base.xml b/tests/templates/20override/00-base.xml new file mode 100644 index 00000000..f59d3cfa --- /dev/null +++ b/tests/templates/20override/00-base.xml @@ -0,0 +1,41 @@ + + + + + + + + mandatory + test.service + + + mandatory + test.service + + + mandatory + True + + + mandatory + True + + + + basic + + + + + normal + + oui + non + mandatory + normal + non + + + + + diff --git a/tests/templates/20override/result/rougail.conf b/tests/templates/20override/result/rougail.conf new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/tests/templates/20override/result/rougail.conf @@ -0,0 +1 @@ + diff --git a/tests/templates/20override/result/system/test.service.d/rougail.conf b/tests/templates/20override/result/system/test.service.d/rougail.conf new file mode 100644 index 00000000..d907505b --- /dev/null +++ b/tests/templates/20override/result/system/test.service.d/rougail.conf @@ -0,0 +1 @@ +non diff --git a/tests/templates/20override/tmpl/test.service b/tests/templates/20override/tmpl/test.service new file mode 100644 index 00000000..a29cfeaf --- /dev/null +++ b/tests/templates/20override/tmpl/test.service @@ -0,0 +1 @@ +%%mode_conteneur_actif diff --git a/tests/templates/60extra_group/00-base.xml b/tests/templates/60extra_group/00-base.xml index e9553cfb..637c73ea 100644 --- a/tests/templates/60extra_group/00-base.xml +++ b/tests/templates/60extra_group/00-base.xml @@ -32,6 +32,10 @@ mandatory mailname + + mandatory + True + mandatory True diff --git a/tests/templates/70container_files/00-base.xml b/tests/templates/70container_files/00-base.xml index 4d1291b8..21035916 100644 --- a/tests/templates/70container_files/00-base.xml +++ b/tests/templates/70container_files/00-base.xml @@ -32,6 +32,10 @@ mandatory mailname + + mandatory + True + mandatory True diff --git a/tests/templates/70container_files_symlink_multi/00-base.xml b/tests/templates/70container_files_symlink_multi/00-base.xml index ba720294..d3cc83bb 100644 --- a/tests/templates/70container_files_symlink_multi/00-base.xml +++ b/tests/templates/70container_files_symlink_multi/00-base.xml @@ -31,6 +31,10 @@ mandatory mailname + + mandatory + True + mandatory True diff --git a/tests/templates/70container_files_symlink_multi_variable/00-base.xml b/tests/templates/70container_files_symlink_multi_variable/00-base.xml index 478c116a..9111a927 100644 --- a/tests/templates/70container_files_symlink_multi_variable/00-base.xml +++ b/tests/templates/70container_files_symlink_multi_variable/00-base.xml @@ -31,6 +31,10 @@ mandatory mailname + + mandatory + True + mandatory diff --git a/tests/test_flattener.py b/tests/test_flattener.py index 9fa081df..4e984a48 100644 --- a/tests/test_flattener.py +++ b/tests/test_flattener.py @@ -83,7 +83,7 @@ def launch_flattener(test_dir, test_ok=False): eolobj.save(destfile) result_file = join(test_dir, 'result/00-base.xml') if isfile(result_file): - # eolobj.save(result_file) + eolobj.save(result_file) compare_xml(destfile, result_file) elif test_ok: raise Exception(f'no test found for {test_dir}') diff --git a/tests/test_makedict.py b/tests/test_makedict.py index dcbc16d1..2256573f 100644 --- a/tests/test_makedict.py +++ b/tests/test_makedict.py @@ -50,12 +50,12 @@ async def launch_flattener(test_dir): await config.property.read_write() config_dict = await config.value.dict() # if not isfile(makedict_file) and config_dict: - #if config_dict: - # if not isdir(makedict_dir): - # mkdir(makedict_dir) - # with open(makedict_file, 'w') as fh: - # dump(config_dict, fh) - # fh.write('\n') + if config_dict: + if not isdir(makedict_dir): + mkdir(makedict_dir) + with open(makedict_file, 'w') as fh: + dump(config_dict, fh) + fh.write('\n') if not isfile(makedict_file): if config_dict: raise Exception('dict is not empty') diff --git a/tests/test_template.py b/tests/test_template.py index 05131657..3e5f7d5a 100644 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -54,10 +54,11 @@ async def test_dictionary(test_dir): funcs_file, distrib_dir, tmp_dir, - dest_dir) + dest_dir, + join(dest_dir, 'rougail.conf')) list_templates = set() - if isdir(join(dest_dir, 'etc')): + if isdir(dest_dir): find_files(join(dest_dir), [], list_templates) list_results = set() if isdir(join(test_dir, 'result')): From dfa0b5678b439ebb93c5ed15323dc1461c74a2a4 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Wed, 29 Apr 2020 14:06:29 +0200 Subject: [PATCH 07/32] add override and factory support --- src/rougail/template.py | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/rougail/template.py b/src/rougail/template.py index e9e9a0ed..ce214061 100644 --- a/src/rougail/template.py +++ b/src/rougail/template.py @@ -262,13 +262,17 @@ class CreoleTemplateEngine: distrib_dir: str, tmp_dir: str, dest_dir: str, + override_dest_dir: str, tmpfile_name: str, + factory_prefix: str, ) -> None: self.config = config self.dest_dir = dest_dir + self.override_dest_dir = override_dest_dir self.tmp_dir = tmp_dir self.distrib_dir = distrib_dir self.tmpfile_name = tmpfile_name + self.factory_prefix = factory_prefix eos = {} if eosfunc_file is not None: eosfunc = imp.load_source('eosfunc', eosfunc_file) @@ -382,7 +386,7 @@ class CreoleTemplateEngine: else: variable = None if override: - filenames = [f'/system/{service_name}.service.d/rougail.conf'] + filenames = [f'/systemd/system/{service_name}.service.d/rougail.conf'] else: filenames = filevar['name'] if not isinstance(filenames, list): @@ -390,8 +394,10 @@ class CreoleTemplateEngine: if variable: variable = [variable] for idx, filename in enumerate(filenames): - destfilename = join(self.dest_dir, - filename[1:]) + if override: + destfilename = join(self.override_dest_dir, filename[1:]) + else: + destfilename = join(self.dest_dir, filename[1:]) makedirs(dirname(destfilename), exist_ok=True) if variable: var = variable[idx] @@ -406,7 +412,7 @@ class CreoleTemplateEngine: else: copy(source, destfilename) if not override and self.tmpfile_name: - systemd_rights.append(f'C {filename} {filevar["mode"]} {filevar["owner"]} {filevar["group"]} - -') + systemd_rights.append(f'C {filename} {filevar["mode"]} {filevar["owner"]} {filevar["group"]} - {self.factory_prefix}{filename}') systemd_rights.append(f'z {filename} - - - - -') async def instance_files(self) -> None: @@ -455,11 +461,22 @@ async def generate(config: Config, distrib_dir: str, tmp_dir: str, dest_dir: str, - tmpfile_name: str=None) -> None: + override_dest_dir: str, + tmpfile_name: str=None, + factory_prefix: str=None, + ) -> None: + if not tmpfile_name and factory_prefix: + raise Exception(_(f'only specify factory_prefix if tmpfile_name is set')) + if tmpfile_name and not factory_prefix: + raise Exception(_(f'if tmpfile_name is specify, set factory_prefix too')) + engine = CreoleTemplateEngine(config, eosfunc_file, distrib_dir, tmp_dir, dest_dir, - tmpfile_name) + override_dest_dir, + tmpfile_name, + factory_prefix, + ) await engine.instance_files() From 2e0e17705be0bfaa3ee46c055414c7c133b5ac86 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Tue, 26 May 2020 15:41:17 +0200 Subject: [PATCH 08/32] better test with valid_enum and number --- src/rougail/annotator.py | 15 +++++++-- src/rougail/i18n.py | 4 +-- .../88valid_enum_not_number/00-base.xml | 2 +- .../00-base.xml | 32 +++++++++++++++++++ tests/test_flattener.py | 2 +- 5 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 tests/flattener_dicos/88valid_enum_numberdefaultstring/00-base.xml diff --git a/src/rougail/annotator.py b/src/rougail/annotator.py index 0edc0e44..d4219777 100644 --- a/src/rougail/annotator.py +++ b/src/rougail/annotator.py @@ -75,6 +75,7 @@ KEY_TYPE = {'variable': 'symlink', TYPE_PARAM_CHECK = ('string', 'python', 'eole', 'variable') TYPE_PARAM_CONDITION = ('string', 'python', 'number', 'eole', 'variable') TYPE_PARAM_FILL = ('string', 'eole', 'number', 'context', 'variable') +CONVERSION = {'number': int} ERASED_FAMILY_ACTION_ATTRIBUTES = ('index', 'action') @@ -685,7 +686,13 @@ class SpaceAnnotator(object): choices = [] for value in values: choice = self.objectspace.choice() - choice.name = str(value) + try: + if type_ in CONVERSION: + choice.name = CONVERSION[type_](value) + else: + choice.name = str(value) + except: + raise CreoleDictConsistencyError(_(f'unable to change type of a valid_enum entry "{value}" is not a valid "{type_}" for "{variable.name}"')) choices.append(choice.name) choice.type = type_ variable.choice.append(choice) @@ -694,7 +701,11 @@ class SpaceAnnotator(object): if hasattr(variable, 'value'): for value in variable.value: value.type = type_ - if value.name not in choices: + if type_ in CONVERSION: + cvalue = CONVERSION[type_](value.name) + else: + cvalue = value.name + if cvalue not in choices: raise CreoleDictConsistencyError(_('value "{}" of variable "{}" is not in list of all expected values ({})').format(value.name, variable.name, choices)) else: new_value = self.objectspace.value() diff --git a/src/rougail/i18n.py b/src/rougail/i18n.py index db1716c9..76758cd3 100644 --- a/src/rougail/i18n.py +++ b/src/rougail/i18n.py @@ -44,8 +44,8 @@ mo_location = LOCALE_DIR gettext.find(APP_NAME, mo_location) gettext.textdomain(APP_NAME) -gettext.bind_textdomain_codeset(APP_NAME, "UTF-8") -gettext.translation(APP_NAME, fallback=True) +#gettext.bind_textdomain_codeset(APP_NAME, "UTF-8") +#gettext.translation(APP_NAME, fallback=True) t = gettext.translation(APP_NAME, fallback=True) diff --git a/tests/flattener_dicos/88valid_enum_not_number/00-base.xml b/tests/flattener_dicos/88valid_enum_not_number/00-base.xml index 36914af4..67db377c 100644 --- a/tests/flattener_dicos/88valid_enum_not_number/00-base.xml +++ b/tests/flattener_dicos/88valid_enum_not_number/00-base.xml @@ -17,7 +17,7 @@ - [i for i in range(3, 13)] + ['a', 'b', 'c'] diff --git a/tests/flattener_dicos/88valid_enum_numberdefaultstring/00-base.xml b/tests/flattener_dicos/88valid_enum_numberdefaultstring/00-base.xml new file mode 100644 index 00000000..92f61c26 --- /dev/null +++ b/tests/flattener_dicos/88valid_enum_numberdefaultstring/00-base.xml @@ -0,0 +1,32 @@ + + + + + + + + + non + + + + + a + + + + + + + + [1, 2, 3] + + + + + bla bla bla + + + + diff --git a/tests/test_flattener.py b/tests/test_flattener.py index 4e984a48..532067d5 100644 --- a/tests/test_flattener.py +++ b/tests/test_flattener.py @@ -83,7 +83,7 @@ def launch_flattener(test_dir, test_ok=False): eolobj.save(destfile) result_file = join(test_dir, 'result/00-base.xml') if isfile(result_file): - eolobj.save(result_file) + #eolobj.save(result_file) compare_xml(destfile, result_file) elif test_ok: raise Exception(f'no test found for {test_dir}') From ef5297a4e458fd3b26b1f0146a0bc7b1c8ebc45f Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 6 Jul 2020 19:47:45 +0200 Subject: [PATCH 09/32] refactor --- src/rougail/annotator.py | 636 +++++--------- src/rougail/data/rougail.dtd | 22 +- src/rougail/objspace.py | 806 +++++++----------- src/rougail/path.py | 182 ++++ src/rougail/xmlreflector.py | 77 +- tests/eosfunc/test.py | 4 + .../00empty/result/00-base.xml | 8 +- .../00load_autofreeze/result/00-base.xml | 4 +- .../result/00-base.xml | 4 +- .../00load_autosave/result/00-base.xml | 4 +- .../00load_autosaveexpert/result/00-base.xml | 4 +- .../00load_comment/makedict/base.json | 1 + .../00load_comment/result/00-base.xml | 4 +- .../00load_notype/makedict/base.json | 2 +- .../00load_notype/result/00-base.xml | 4 +- .../00load_save/makedict/base.json | 1 + .../00load_save/result/00-base.xml | 4 +- .../00load_subfolder/makedict/base.json | 1 + .../00load_subfolder/result/00-base.xml | 4 +- tests/flattener_dicos/01auto_base/00-base.xml | 4 +- .../01auto_base/makedict/base.json | 2 +- .../01auto_base/result/00-base.xml | 4 +- .../01auto_withoutparam/00-base.xml | 4 +- .../01auto_withoutparam/makedict/base.json | 2 +- .../01auto_withoutparam/result/00-base.xml | 4 +- .../01base_multi/makedict/base.json | 1 + .../01base_multi/result/00-base.xml | 4 +- .../01base_submulti/makedict/base.json | 1 + .../01base_submulti/result/00-base.xml | 4 +- .../01fill_autofreeze/result/00-base.xml | 4 +- .../01fill_autosave/result/00-base.xml | 4 +- .../01fill_base/makedict/base.json | 2 +- .../01fill_base/result/00-base.xml | 4 +- .../01fill_baseaccent/makedict/base.json | 2 +- .../01fill_baseaccent/result/00-base.xml | 4 +- .../01fill_mandatory/result/00-base.xml | 4 +- .../01fill_number/makedict/base.json | 2 +- .../01fill_number/result/00-base.xml | 4 +- .../01fill_optional/makedict/base.json | 2 +- .../01fill_optional/result/00-base.xml | 4 +- .../01separator_base/makedict/base.json | 1 + .../01separator_base/result/00-base.xml | 4 +- .../makedict/base.json | 1 + .../result/00-base.xml | 4 +- .../10autosave_hidden/makedict/base.json | 1 + .../10autosave_hidden/result/00-base.xml | 4 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 4 +- .../10check_base/result/00-base.xml | 4 +- .../10check_option/result/00-base.xml | 4 +- .../10check_optional/result/00-base.xml | 4 +- .../10check_valid_differ/result/00-base.xml | 4 +- .../result/00-base.xml | 4 +- .../result/00-base.xml | 4 +- .../result/00-base.xml | 4 +- .../10leadership_append/result/00-base.xml | 4 +- .../10leadership_auto/00-base.xml | 18 +- .../10leadership_auto/makedict/base.json | 2 +- .../10leadership_auto/result/00-base.xml | 4 +- .../10leadership_autoleader/00-base.xml | 12 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 4 +- .../00-base.xml | 6 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 10 +- .../result/00-base.xml | 4 +- .../result/00-base.xml | 4 +- .../result/00-base.xml | 4 +- .../10leadership_mandatory/result/00-base.xml | 4 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 4 +- .../10leadership_multi/result/00-base.xml | 4 +- .../10load_disabled_if_in/result/00-base.xml | 10 +- .../result/00-base.xml | 10 +- .../10load_disabled_if_inaccent/00-base.xml | 4 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 4 +- .../10load_disabledifin_fallback/00-base.xml | 4 +- .../result/00-base.xml | 4 +- .../00-base.xml | 4 +- .../result/00-base.xml | 4 +- .../10load_emptyvalue/00-base.xml | 25 + .../10load_emptyvalue/makedict/base.json | 1 + .../10load_emptyvalue/result/00-base.xml | 15 + .../10load_frozenifin/result/00-base.xml | 4 +- .../10load_frozenifin_auto/00-base.xml | 4 +- .../10load_frozenifin_auto/result/00-base.xml | 4 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 4 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 4 +- .../10load_leadership/result/00-base.xml | 4 +- .../result/00-base.xml | 4 +- .../result/00-base.xml | 4 +- .../result/00-base.xml | 4 +- .../result/00-base.xml | 4 +- .../result/00-base.xml | 4 +- .../result/00-base.xml | 4 +- .../10load_mandatoryifin/result/00-base.xml | 4 +- .../10load_multivalue/makedict/base.json | 1 + .../10load_multivalue/result/00-base.xml | 4 +- .../result/00-base.xml | 4 +- .../10valid_enum_accent/result/00-base.xml | 4 +- .../10valid_enum_base/result/00-base.xml | 4 +- .../result/00-base.xml | 4 +- .../result/00-base.xml | 4 +- .../10valid_enum_eosfunc/result/00-base.xml | 4 +- .../10valid_enum_leader/result/00-base.xml | 4 +- .../10valid_enum_mandatory/result/00-base.xml | 4 +- .../10valid_enum_multi/result/00-base.xml | 4 +- .../10valid_enum_number/result/00-base.xml | 4 +- .../result/00-base.xml | 4 +- .../10valid_enum_python/result/00-base.xml | 4 +- .../10valid_enum_value/result/00-base.xml | 4 +- .../11disabled_if_in_filelist/00-base.xml | 4 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 41 +- .../00-base.xml | 4 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 41 +- .../00-base.xml | 4 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 77 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 41 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 41 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 41 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 41 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 41 +- .../20family_append/makedict/base.json | 1 + .../20family_append/result/00-base.xml | 4 +- .../20family_appendaccent/00-base.xml | 2 +- .../20family_appendaccent/makedict/base.json | 1 + .../20family_appendaccent/result/00-base.xml | 4 +- .../20family_dynamic/result/00-base.xml | 4 +- .../20family_dynamic_calc/result/00-base.xml | 4 +- .../20family_empty/result/00-base.xml | 4 +- .../20family_hidden/makedict/base.json | 1 + .../20family_hidden/result/00-base.xml | 4 +- .../20family_mode/result/00-base.xml | 4 +- .../result/00-base.xml | 4 +- .../20notemplating/makedict/base.json | 2 +- .../20notemplating/result/00-base.xml | 41 +- .../20override/result/00-base.xml | 21 +- .../21family_change/makedict/base.json | 1 + .../21family_change/result/00-base.xml | 4 +- .../21family_changeaccent/makedict/base.json | 1 + .../21family_changeaccent/result/00-base.xml | 4 +- .../21family_empty/result/00-base.xml | 4 +- .../result/00-base.xml | 4 +- .../30mandatory_withoutvaluecalc/00-base.xml | 6 +- .../makedict/base.json | 1 + .../result/00-base.xml | 4 +- .../30mandatory_withvalue/result/00-base.xml | 4 +- .../result/00-base.xml | 4 +- .../40condition_base/00-base.xml | 4 +- .../40condition_base/result/00-base.xml | 4 +- .../40condition_fallback/00-base.xml | 4 +- .../40condition_fallback/result/00-base.xml | 4 +- .../40condition_optional/00-base.xml | 2 +- .../40condition_optional/result/00-base.xml | 4 +- .../40ifin_leadership/result/00-base.xml | 4 +- .../40ifin_leadershipauto/00-base.xml | 6 +- .../40ifin_leadershipauto/result/00-base.xml | 4 +- .../flattener_dicos/40ifin_multi/00-base.xml | 2 +- .../40ifin_multi/makedict/base.json | 1 + .../40ifin_multi/result/00-base.xml | 4 +- .../40ifin_validenum/makedict/base.json | 2 +- .../40ifin_validenum/result/00-base.xml | 4 +- .../50exists_exists/makedict/base.json | 1 + .../50exists_exists/result/00-base.xml | 4 +- .../50redefine_description/makedict/base.json | 1 + .../50redefine_description/result/00-base.xml | 4 +- .../51exists_nonexists/makedict/base.json | 2 +- .../51exists_nonexists/result/00-base.xml | 4 +- .../51redefine_auto/00-base.xml | 4 +- .../51redefine_auto/01-base.xml | 4 +- .../51redefine_auto/makedict/base.json | 1 + .../51redefine_auto/result/00-base.xml | 4 +- .../51redefine_autofill/00-base.xml | 6 +- .../51redefine_autofill/01-base.xml | 2 +- .../51redefine_autofill/result/00-base.xml | 4 +- .../51redefine_family/makedict/base.json | 1 + .../51redefine_family/result/00-base.xml | 5 +- .../51redefine_fill/makedict/base.json | 1 + .../51redefine_fill/result/00-base.xml | 4 +- .../51redefine_fillauto/00-base.xml | 2 +- .../51redefine_fillauto/01-base.xml | 6 +- .../51redefine_fillauto/makedict/base.json | 1 + .../51redefine_fillauto/result/00-base.xml | 4 +- .../51redefine_help/makedict/base.json | 1 + .../51redefine_help/result/00-base.xml | 4 +- .../51redefine_hidden/makedict/base.json | 1 + .../51redefine_hidden/result/00-base.xml | 4 +- .../makedict/base.json | 1 + .../result/00-base.xml | 4 +- .../51redefine_remove_condition/00-base.xml | 2 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 4 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 4 +- .../00-base.xml | 2 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 4 +- .../51redefine_validenum/makedict/base.json | 1 + .../51redefine_validenum/result/00-base.xml | 4 +- .../51redefine_value/makedict/base.json | 2 +- .../51redefine_value/result/00-base.xml | 4 +- .../52exists_redefine/makedict/base.json | 1 + .../52exists_redefine/result/00-base.xml | 4 +- .../extra_dirs/extra/00-base.xml | 22 +- .../60action_external/makedict/base.json | 2 +- .../60action_external/result/00-base.xml | 78 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 4 +- .../60extra_group/makedict/base.json | 2 +- .../60extra_group/result/00-base.xml | 41 +- .../60extra_help/makedict/base.json | 2 +- .../60extra_help/result/00-base.xml | 41 +- .../60extra_load/makedict/base.json | 2 +- .../60extra_load/result/00-base.xml | 4 +- .../60extra_mandatory/makedict/base.json | 2 +- .../60extra_mandatory/result/00-base.xml | 4 +- .../60extra_redefine/makedict/base.json | 2 +- .../60extra_redefine/result/00-base.xml | 4 +- .../extra_dirs/extra/00-base.xml | 14 - .../60familyaction/makedict/base.json | 2 +- .../60familyaction/result/00-base.xml | 75 +- .../extra_dirs/extra/00-base.xml | 14 - .../60familyaction_accent/makedict/base.json | 2 +- .../60familyaction_accent/result/00-base.xml | 75 +- .../60familyaction_disable/00-base.xml | 25 - .../extra_dirs/extra/00-base.xml | 31 - .../60familyaction_disable/makedict/base.json | 1 - .../60familyaction_disable/result/00-base.xml | 108 --- .../60familyaction_empty/00-base.xml | 22 - .../extra_dirs/extra/00-base.xml | 21 - .../60familyaction_empty/makedict/base.json | 1 - .../60familyaction_empty/result/00-base.xml | 94 -- .../extra_dirs/extra/00-base.xml | 14 - .../makedict/base.json | 2 +- .../result/00-base.xml | 75 +- .../60familyaction_save/00-base.xml | 22 - .../extra_dirs/extra/00-base.xml | 27 - .../60familyaction_save/makedict/base.json | 1 - .../60familyaction_save/result/00-base.xml | 100 --- .../60familyaction_twoactions/00-base.xml | 22 - .../extra_dirs/extra/00-base.xml | 26 - .../extra_dirs/extra1/00-base.xml | 26 - .../makedict/base.json | 1 - .../result/00-base.xml | 161 ---- .../60familyactionexternal/00-base.xml | 22 - .../extra_dirs/extra/00-base.xml | 22 - .../60familyactionexternal/makedict/base.json | 1 - .../60familyactionexternal/result/00-base.xml | 95 --- .../70container_files/makedict/base.json | 2 +- .../70container_files/result/00-base.xml | 41 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 39 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 41 +- .../70container_filesmulti/makedict/base.json | 2 +- .../70container_filesmulti/result/00-base.xml | 77 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 41 +- .../70container_filesrm/00-base.xml | 28 - .../70container_filesrm/makedict/base.json | 1 - .../70container_filesrm/result/00-base.xml | 64 -- .../70container_new/makedict/base.json | 1 + .../70container_new/result/00-base.xml | 8 +- .../70container_newnocont/makedict/base.json | 1 + .../70container_newnocont/result/00-base.xml | 8 +- .../70container_newwithip/makedict/base.json | 2 +- .../70container_newwithip/result/00-base.xml | 8 +- .../70container_package/00-base.xml | 28 - .../70container_package/makedict/base.json | 1 - .../70container_package/result/00-base.xml | 36 - .../70container_pathaccess/makedict/base.json | 2 +- .../70container_pathaccess/result/00-base.xml | 17 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 17 +- .../70container_save/makedict/base.json | 1 + .../70container_save/result/00-base.xml | 4 +- .../70container_serviceaccess/00-base.xml | 1 - .../makedict/base.json | 2 +- .../result/00-base.xml | 31 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 21 +- .../70container_services/makedict/base.json | 2 +- .../70container_services/result/00-base.xml | 8 +- tests/test_flattener.py | 2 +- tests/test_makedict.py | 3 +- tests/test_template.py | 20 +- 297 files changed, 1560 insertions(+), 3198 deletions(-) create mode 100644 src/rougail/path.py create mode 100644 tests/flattener_dicos/00load_comment/makedict/base.json create mode 100644 tests/flattener_dicos/00load_save/makedict/base.json create mode 100644 tests/flattener_dicos/00load_subfolder/makedict/base.json create mode 100644 tests/flattener_dicos/01base_multi/makedict/base.json create mode 100644 tests/flattener_dicos/01base_submulti/makedict/base.json create mode 100644 tests/flattener_dicos/01separator_base/makedict/base.json create mode 100644 tests/flattener_dicos/01separator_neverhidden/makedict/base.json create mode 100644 tests/flattener_dicos/10autosave_hidden/makedict/base.json create mode 100644 tests/flattener_dicos/10load_emptyvalue/00-base.xml create mode 100644 tests/flattener_dicos/10load_emptyvalue/makedict/base.json create mode 100644 tests/flattener_dicos/10load_emptyvalue/result/00-base.xml create mode 100644 tests/flattener_dicos/10load_multivalue/makedict/base.json create mode 100644 tests/flattener_dicos/20family_append/makedict/base.json create mode 100644 tests/flattener_dicos/20family_appendaccent/makedict/base.json create mode 100644 tests/flattener_dicos/20family_hidden/makedict/base.json create mode 100644 tests/flattener_dicos/21family_change/makedict/base.json create mode 100644 tests/flattener_dicos/21family_changeaccent/makedict/base.json create mode 100644 tests/flattener_dicos/30mandatory_withoutvaluecalc/makedict/base.json create mode 100644 tests/flattener_dicos/40ifin_multi/makedict/base.json create mode 100644 tests/flattener_dicos/50exists_exists/makedict/base.json create mode 100644 tests/flattener_dicos/50redefine_description/makedict/base.json create mode 100644 tests/flattener_dicos/51redefine_auto/makedict/base.json create mode 100644 tests/flattener_dicos/51redefine_family/makedict/base.json create mode 100644 tests/flattener_dicos/51redefine_fill/makedict/base.json create mode 100644 tests/flattener_dicos/51redefine_fillauto/makedict/base.json create mode 100644 tests/flattener_dicos/51redefine_help/makedict/base.json create mode 100644 tests/flattener_dicos/51redefine_hidden/makedict/base.json create mode 100644 tests/flattener_dicos/51redefine_remove_check/makedict/base.json create mode 100644 tests/flattener_dicos/51redefine_validenum/makedict/base.json create mode 100644 tests/flattener_dicos/52exists_redefine/makedict/base.json delete mode 100644 tests/flattener_dicos/60familyaction_disable/00-base.xml delete mode 100644 tests/flattener_dicos/60familyaction_disable/extra_dirs/extra/00-base.xml delete mode 100644 tests/flattener_dicos/60familyaction_disable/makedict/base.json delete mode 100644 tests/flattener_dicos/60familyaction_disable/result/00-base.xml delete mode 100644 tests/flattener_dicos/60familyaction_empty/00-base.xml delete mode 100644 tests/flattener_dicos/60familyaction_empty/extra_dirs/extra/00-base.xml delete mode 100644 tests/flattener_dicos/60familyaction_empty/makedict/base.json delete mode 100644 tests/flattener_dicos/60familyaction_empty/result/00-base.xml delete mode 100644 tests/flattener_dicos/60familyaction_save/00-base.xml delete mode 100644 tests/flattener_dicos/60familyaction_save/extra_dirs/extra/00-base.xml delete mode 100644 tests/flattener_dicos/60familyaction_save/makedict/base.json delete mode 100644 tests/flattener_dicos/60familyaction_save/result/00-base.xml delete mode 100644 tests/flattener_dicos/60familyaction_twoactions/00-base.xml delete mode 100644 tests/flattener_dicos/60familyaction_twoactions/extra_dirs/extra/00-base.xml delete mode 100644 tests/flattener_dicos/60familyaction_twoactions/extra_dirs/extra1/00-base.xml delete mode 100644 tests/flattener_dicos/60familyaction_twoactions/makedict/base.json delete mode 100644 tests/flattener_dicos/60familyaction_twoactions/result/00-base.xml delete mode 100644 tests/flattener_dicos/60familyactionexternal/00-base.xml delete mode 100644 tests/flattener_dicos/60familyactionexternal/extra_dirs/extra/00-base.xml delete mode 100644 tests/flattener_dicos/60familyactionexternal/makedict/base.json delete mode 100644 tests/flattener_dicos/60familyactionexternal/result/00-base.xml delete mode 100644 tests/flattener_dicos/70container_filesrm/00-base.xml delete mode 100644 tests/flattener_dicos/70container_filesrm/makedict/base.json delete mode 100644 tests/flattener_dicos/70container_filesrm/result/00-base.xml create mode 100644 tests/flattener_dicos/70container_new/makedict/base.json create mode 100644 tests/flattener_dicos/70container_newnocont/makedict/base.json delete mode 100644 tests/flattener_dicos/70container_package/00-base.xml delete mode 100644 tests/flattener_dicos/70container_package/makedict/base.json delete mode 100644 tests/flattener_dicos/70container_package/result/00-base.xml create mode 100644 tests/flattener_dicos/70container_save/makedict/base.json diff --git a/src/rougail/annotator.py b/src/rougail/annotator.py index d4219777..907bdefe 100644 --- a/src/rougail/annotator.py +++ b/src/rougail/annotator.py @@ -50,6 +50,7 @@ def mode_factory(): modes = mode_factory() + # a CreoleObjSpace's attribute has some annotations # that shall not be present in the exported (flatened) XML ERASED_ATTRIBUTES = ('redefine', 'exists', 'fallback', 'optional', 'remove_check', 'namespace', @@ -74,7 +75,7 @@ KEY_TYPE = {'variable': 'symlink', TYPE_PARAM_CHECK = ('string', 'python', 'eole', 'variable') TYPE_PARAM_CONDITION = ('string', 'python', 'number', 'eole', 'variable') -TYPE_PARAM_FILL = ('string', 'eole', 'number', 'context', 'variable') +TYPE_PARAM_FILL = ('string', 'number', 'variable') CONVERSION = {'number': int} ERASED_FAMILY_ACTION_ATTRIBUTES = ('index', 'action') @@ -84,52 +85,73 @@ FREEZE_AUTOFREEZE_VARIABLE = 'module_instancie' class ServiceAnnotator: """Manage service's object + for example:: + + + + 123 + + + """ def __init__(self, objectspace): self.space = objectspace.space self.paths = objectspace.paths self.objectspace = objectspace - """for example:: - - 123 - ntpd - - """ self.grouplist_conditions = {} self.convert_services() def convert_services(self): - if hasattr(self.space, 'services'): - if hasattr(self.space.services, 'service'): - subelts = dict() - for idx, service in enumerate(self.space.services.service.values()): - family = self.objectspace.family() - family.name = 'service{}'.format(idx) - family.doc = service.name - family.family = OrderedDict() - self.convert_service_to_family(family.name, family.family, service) - setattr(self.space.services, family.name, family) - del self.space.services.service - else: - del self.space.services - - def convert_service_to_family(self, service_name, service_family, service): - for elttype, values in vars(service).items(): - if elttype in ['name', 'index', 'method']: - continue + if not hasattr(self.space, 'services'): + return + if not hasattr(self.space.services, 'service'): + del self.space.services + return + for idx, service in enumerate(self.space.services.service.values()): + service_name = f'service{idx}' family = self.objectspace.family() - family.name = elttype + 's' + family.name = service_name + family.doc = service.name + family.mode = None + family.family = self.convert_service_to_family(f'services.{service_name}', + service, + ) + setattr(self.space.services, family.name, family) + del self.space.services.service + + def convert_service_to_family(self, + subpath, + service, + ): + services = {} + for elttype, values in vars(service).items(): + if elttype == 'name' or elttype in ERASED_ATTRIBUTES: + continue + eltname = elttype + 's' + family = self.objectspace.family() + family.name = eltname + family.mode = None if isinstance(values, dict): values = list(values.values()) - family.family = self.convert_subelement_service(elttype, - values, - 'services.{}.{}'.format(service_name, family.name)) - family.mode = None - service_family[family.name] = family + family.family = self.make_group_from_elts(elttype, + values, + f'{subpath}.{eltname}', + ) + services[family.name] = family + return services - def convert_subelement_service(self, name, elts, path): + def make_group_from_elts(self, + name, + elts, + path, + ): + """Splits each objects into a group (and `OptionDescription`, in tiramisu terms) + and build elements and its attributes (the `Options` in tiramisu terms) + """ families = [] - new_elts = self._reorder_elts(name, elts, True) + new_elts = self._reorder_elts(name, + elts, + ) for index, elt_info in enumerate(new_elts): elt = elt_info['elt'] elt_name = elt_info['elt_name'] @@ -151,10 +173,6 @@ class ServiceAnnotator: if key.startswith('_') or key.endswith('_type') or key in ERASED_ATTRIBUTES: continue value = getattr(elt, key) - if isinstance(value, list): - continue - if key == 'service': - value = value.name if key == listname: self.objectspace.list_conditions.setdefault(listname, {}).setdefault( @@ -165,23 +183,27 @@ class ServiceAnnotator: true_key = elt_name else: true_key = key - if true_key in self.objectspace.booleans_attributs: + if key in self.objectspace.booleans_attributs: type_ = 'boolean' else: type_ = 'string' dtd_key_type = true_key + '_type' - if hasattr(elt, dtd_key_type): type_ = KEY_TYPE[getattr(elt, dtd_key_type)] multi = isinstance(value, list) - variables.append(self._generate_element(elt_name, - key, + variables.append(self._generate_element(key, value, type_, subpath, - multi)) + multi, + )) # FIXME ne devrait pas etre True par défaut - variables.append(self._generate_element(name, 'activate', True, 'boolean', subpath)) + # devrait etre un calcule + variables.append(self._generate_element('activate', + True, + 'boolean', + subpath, + )) family = self.objectspace.family() family.name = '{}{}'.format(name, index) family.variable = variables @@ -193,48 +215,39 @@ class ServiceAnnotator: families.append(family) return families - def _generate_element(self, eltname, name, value, type_, subpath, multi=False): - var_data = {'name': name, 'doc': '', 'value': value, - 'auto_freeze': False, 'mode': None, 'multi': multi} - values = None - if type_ == 'string': - values = self.objectspace.forced_choice_option.get(eltname, {}).get(name) - if values is not None: - type_ = 'choice' - var_data['type'] = type_ - + def _generate_element(self, + key, + value, + type_, + subpath, + multi=False, + ): variable = self.objectspace.variable() - variable.mandatory = True - for key, value in var_data.items(): - if key == 'value': - if value is None: - continue - if type_ == 'symlink': - key = 'opt' + variable.name = key + if type_ != 'symlink': + variable.doc = key + variable.multi = multi + variable.mode = None + variable.hidden = True + variable.type = type_ + if value is not None: + if type_ == 'symlink': + variable.opt = value + else: + if not multi: + val = self.objectspace.value() + val.name = value + value = [val] else: - # Value is a list of objects - if not multi: + # value is a list of objects + value_list = [] + for val_iter in value: val = self.objectspace.value() - val.name = value - value = [val] - else: - value_list = [] - for valiter in value: - val = self.objectspace.value() - val.name = valiter.name - value_list.append(val) - value = value_list - if key == 'doc' and type_ == 'symlink': - continue - setattr(variable, key, value) - if values is not None: - choices = [] - for value in values: - choice = self.objectspace.choice() - choice.name = value - choices.append(choice) - variable.choice = choices - path = '{}.{}'.format(subpath, name) + val.name = val_iter.name + value_list.append(val) + value = value_list + variable.value = value + path = f'{subpath}.{key}' self.paths.add_variable('services', path, 'service', @@ -243,10 +256,32 @@ class ServiceAnnotator: ) return variable - def _update_override(self, file_, index, service_path): - self._update_file(file_, index, service_path) + def _reorder_elts(self, + name, + elts, + ): + """Reorders by index the elts + """ + new_elts = {} + # reorder elts by index + for elt in elts: + new_elts.setdefault(elt.index, []).append(elt) + idxes = list(new_elts.keys()) + idxes.sort() + result_elts = [] + for idx in idxes: + for elt in new_elts[idx]: + result_elts.append({'elt_name': name, 'elt': elt}) + return result_elts - def _update_file(self, file_, index, service_path): + def _update_override(self, *args): + self._update_file(*args) + + def _update_file(self, + file_, + index, + service_path, + ): if not hasattr(file_, 'file_type') or file_.file_type == "UnicodeOption": if not hasattr(file_, 'source'): file_.source = basename(file_.name) @@ -254,139 +289,6 @@ class ServiceAnnotator: raise CreoleDictConsistencyError(_('attribute source mandatory for file with variable name ' 'for {}').format(file_.name)) - def _reorder_elts(self, name, elts, duplicate_list): - """Reorders by index the elts - """ - dict_elts = OrderedDict() - # reorder elts by index - new_elts = {} - not_indexed = [] - for elt in elts: - idx = elt.index - new_elts.setdefault(idx, []).append(elt) - idxes = list(new_elts.keys()) - idxes.sort() - elts = not_indexed - for idx in idxes: - elts.extend(new_elts[idx]) - for idx, elt in enumerate(elts): - elt_added = False - for key in dir(elt): - if key.startswith('_') or key.endswith('_type') or key in ERASED_ATTRIBUTES: - continue - value = getattr(elt, key) - if not elt_added: - eltname = elt.name - dict_elts.setdefault(eltname, []).append({'elt_name': name, 'elt': elt}) - - result_elts = [] - for elt in dict_elts.values(): - result_elts.extend(elt) - return result_elts - - def make_group_from_elts(self, name, elts, path, duplicate_list): - """Splits each objects into a group (and `OptionDescription`, in tiramisu terms) - and build elements and its attributes (the `Options` in tiramisu terms) - """ - families = [] - new_elts = self._reorder_elts(name, elts, duplicate_list) - for index, elt_info in enumerate(new_elts): - elt = elt_info['elt'] - elt_name = elt_info['elt_name'] - - # try to launch _update_xxxx() function - update_elt = '_update_' + elt_name - if hasattr(self, update_elt): - getattr(self, update_elt)(elt, index, path) - variables = [] - subpath = '{}.{}{}'.format(path, name, index) - listname = '{}list'.format(name) - activate_path = '.'.join([subpath, 'activate']) - if elt in self.grouplist_conditions: - # FIXME transformer le activate qui disparait en boolean - self.objectspace.list_conditions.setdefault(listname, - {}).setdefault(self.grouplist_conditions[elt], - []).append(activate_path) - for key in dir(elt): - if key.startswith('_') or key.endswith('_type') or key in ERASED_ATTRIBUTES: - continue - value = getattr(elt, key) - if isinstance(value, list) and duplicate_list: - # FIXME plusieurs fichier si calculé ! - continue - if key == listname: - self.objectspace.list_conditions.setdefault(listname, - {}).setdefault( - value, - []).append(activate_path) - continue - if key in self.objectspace.booleans_attributs: - type_ = 'boolean' - else: - type_ = 'string' - dtd_key_type = key + '_type' - if hasattr(elt, dtd_key_type): - type_ = KEY_TYPE[getattr(elt, dtd_key_type)] - multi = isinstance(value, list) - variables.append(self._generate_element(elt_name, - key, - value, - type_, - subpath, - multi)) - # FIXME ne devrait pas etre True par défaut - variables.append(self._generate_element(name, 'activate', True, 'boolean', subpath)) - family = self.objectspace.family() - family.name = '{}{}'.format(name, index) - family.variable = variables - family.mode = None - self.paths.add_family('services', - subpath, - family, - ) - families.append(family) - return families - - -class ActionAnnotator(ServiceAnnotator): - def __init__(self, objectspace): - self.space = objectspace.space - self.paths = objectspace.paths - self.objectspace = objectspace - self.grouplist_conditions = {} - self.convert_family_action() - - def convert_family_action(self): - if hasattr(self.space, 'family_action'): - actions = self.objectspace.family() - actions.name = 'actions' - actions.mode = None - actions.family = [] - self.space.actions = actions - namespaces = [] - for name, actions in self.space.family_action.items(): - subpath = 'actions.{}'.format(normalize_family(name)) - for action in actions.action: - namespace = action.namespace - if namespace in namespaces: - raise CreoleDictConsistencyError(_('only one action allow for {}' - '').format(namespace)) - namespaces.append(namespace) - action.name = action.namespace - new_actions = self.make_group_from_elts('action', actions.action, subpath, False) - family = self.objectspace.family() - family.name = actions.name - family.family = new_actions - family.mode = None - variables = [] - for key, value in vars(actions).items(): - if key not in ERASED_FAMILY_ACTION_ATTRIBUTES: - variables.append(self._generate_element('action', key, value, 'string', - subpath)) - family.variable = variables - self.space.actions.family.append(family) - del self.space.family_action - class SpaceAnnotator(object): """Transformations applied on a CreoleObjSpace instance @@ -415,7 +317,7 @@ class SpaceAnnotator(object): self.filter_condition() self.convert_valid_enums() self.convert_check() - self.convert_autofill() + self.convert_fill() self.remove_empty_families() self.change_variable_mode() self.change_family_mode() @@ -471,6 +373,12 @@ class SpaceAnnotator(object): leader_space.variable = [] leader_space.name = leader_name leader_space.hidden = variable.hidden + if variable.hidden: + leader_is_hidden = True + variable.frozen = True + variable.force_default_on_freeze = True + else: + leader_is_hidden = False variable.hidden = None if hasattr(group, 'description'): leader_space.doc = group.description @@ -490,19 +398,23 @@ class SpaceAnnotator(object): leader_name, ) leader_space.path = leader_fullname - + return leader_is_hidden def manage_follower(self, - namespace: str, - leader_family_name: str, - variable: 'Variable', - leader_name: str, - follower_names: List[str], - leader_space: 'Leadership', - ) -> None: + namespace: str, + leader_family_name: str, + variable: 'Variable', + leader_name: str, + follower_names: List[str], + leader_space: 'Leadership', + leader_is_hidden: bool, + ) -> None: if variable.name != follower_names[0]: raise CreoleDictConsistencyError(_('cannot found this follower {}').format(follower_names[0])) follower_names.remove(variable.name) + if leader_is_hidden: + variable.frozen = True + variable.force_default_on_freeze = True # followers are multi if not variable.multi: raise CreoleDictConsistencyError(_('the variable {} in a group must be multi or submulti').format(variable.name)) @@ -533,12 +445,13 @@ class SpaceAnnotator(object): if has_a_leader: # it's a follower self.manage_follower(namespace, - leader_family_name, - variable, - leader_name, - follower_names, - leader_space, - ) + leader_family_name, + variable, + leader_name, + follower_names, + leader_space, + leader_is_hidden, + ) ori_leader_family.variable.pop(variable.name) if follower_names == []: # no more follower @@ -546,14 +459,14 @@ class SpaceAnnotator(object): elif variable.name == leader_name: # it's a leader leader_space = self.objectspace.Leadership() - self.manage_leader(leader_space, - leader_family_name, - leader_name, - namespace, - variable, - group, - leader_fullname, - ) + leader_is_hidden = self.manage_leader(leader_space, + leader_family_name, + leader_name, + namespace, + variable, + group, + leader_fullname, + ) has_a_leader = True else: raise CreoleDictConsistencyError(_('cannot found followers {}').format(follower_names)) @@ -611,7 +524,7 @@ class SpaceAnnotator(object): variable.mode = modes_level[0] # if the variable is mandatory and doesn't have any value # then the variable's mode is set to 'basic' - has_value = hasattr(variable, 'value') + has_value = hasattr(variable, 'value') and variable.value != None if (path not in self.has_calc and variable.mandatory is True and (not has_value or is_follower) and variable.type != 'choice'): variable.mode = modes_level[0] @@ -793,81 +706,64 @@ class SpaceAnnotator(object): path = '{}.{}'.format(family.path, variable.name) self._annotate_variable(variable, family_mode, path) - def get_variable(self, name): # pylint: disable=C0111 - return self.paths.get_variable_obj(name) - - def convert_autofill(self): # pylint: disable=C0111 - if hasattr(self.space, 'constraints'): - self.convert_duplicate_autofill(self.space.constraints) - if 'auto' in vars(self.space.constraints): - self.convert_auto(self.space.constraints.auto, self.space) - if 'fill' in vars(self.space.constraints): - self.convert_fill(self.space.constraints.fill, self.space) - - def convert_duplicate_autofill(self, constraints): - """ Remove duplicate auto or fill for a variable - This variable must be redefined - """ - fills = {} + def convert_fill(self): # pylint: disable=C0111,R0912 + if not hasattr(self.space, 'constraints') or not hasattr(self.space.constraints, 'fill'): + return # sort fill/auto by index - if 'fill' in vars(constraints): - for idx, fill in enumerate(constraints.fill): - fills[fill.index] = {'idx': idx, 'fill': fill, 'type': 'fill'} - if 'auto' in vars(constraints): - for idx, fill in enumerate(constraints.auto): - fills[fill.index] = {'idx': idx, 'fill': fill, 'type': 'auto'} + fills = {fill.index: fill for idx, fill in enumerate(self.space.constraints.fill)} indexes = list(fills.keys()) indexes.sort() - targets = {} - remove_autos = [] - remove_fills = [] + targets = [] + eosfunc = dir(self.eosfunc) for idx in indexes: - fill = fills[idx]['fill'] - redefine = bool(fill.redefine) - if fill.target in targets: - if redefine: - if targets[fill.target][1] == 'auto': - remove_autos.append(targets[fill.target][0]) - else: - remove_fills.append(targets[fill.target][0]) - else: - raise CreoleDictConsistencyError(_("An auto or fill already exists " - "for the target: {}").format( - fill.target)) - targets[fill.target] = (fills[idx]['idx'], fills[idx]['type']) - remove_autos.sort(reverse=True) - for idx in remove_autos: - constraints.auto.pop(idx) - remove_fills.sort(reverse=True) - for idx in remove_fills: - constraints.fill.pop(idx) + fill = fills[idx] + # test if it's redefined calculation + if fill.target in targets and not fill.redefine: + raise CreoleDictConsistencyError(_(f"A fill already exists for the target: {fill.target}")) + targets.append(fill.target) + # + if not fill.name in eosfunc: + raise CreoleDictConsistencyError(_('cannot find fill function {}').format(fill.name)) - def convert_auto(self, auto_space, space): # pylint: disable=C0111 - for auto in auto_space: - if HIGH_COMPATIBILITY and auto.target in self.has_frozen_if_in_condition: - # if a variable has a 'frozen_if_in' condition - # then we change the 'auto' variable as a 'fill' variable - continue - # an auto is a fill with "hidden" and "frozen" properties - variable = self.get_variable(auto.target) - if variable.auto_freeze: - raise CreoleDictConsistencyError(_('variable with auto value ' - 'cannot be auto_freeze').format(auto.target)) - if variable.auto_save: - raise CreoleDictConsistencyError(_('variable with auto value ' - 'cannot be auto_save').format(auto.target)) - leader = self.paths.get_leader(auto.target) - if leader is None or variable.name != leader: - variable.hidden = True - else: - leadership = self.paths.get_family_obj(self.paths.get_variable_family_path(auto.target)) - leadership.hidden = True - variable.frozen = True - variable.force_default_on_freeze = True - if 'fill' not in vars(space.constraints): - space.constraints.fill = [] - space.constraints.fill.extend(auto_space) - del space.constraints.auto + namespace = fill.namespace + # let's replace the target by the path + fill.target = self.paths.get_variable_path(fill.target, + namespace) + + value = self.objectspace.value() + value.type = 'calculation' + value.name = fill.name + if hasattr(fill, 'param'): + param_to_delete = [] + for fill_idx, param in enumerate(fill.param): + if param.type not in TYPE_PARAM_FILL: + raise CreoleDictConsistencyError(_(f'cannot use {param.type} type as a param in a fill/auto')) + if param.type != 'string' and not hasattr(param, 'text'): + raise CreoleDictConsistencyError(_(f"All '{param.type}' variables shall have a value in order to calculate {fill.target}")) + if param.type == 'variable': + try: + param.text, suffix = self.paths.get_variable_path(param.text, + namespace, + with_suffix=True) + if suffix: + param.suffix = suffix + except CreoleDictConsistencyError as err: + if param.optional is False: + raise err + param_to_delete.append(fill_idx) + continue + if param.hidden is True: + param.transitive = False + param.hidden = None + param_to_delete.sort(reverse=True) + for param_idx in param_to_delete: + fill.param.pop(param_idx) + value.param = fill.param + variable = self.paths.get_variable_obj(fill.target) + variable.value = [value] + self.force_not_mandatory.append(fill.target) + self.has_calc.append(fill.target) + del self.space.constraints.fill def filter_separators(self): # pylint: disable=C0111,R0201 # FIXME devrait etre dans la variable @@ -991,7 +887,7 @@ class SpaceAnnotator(object): for param_idx, param in enumerate(check.param): if hasattr(param, 'name') and param.name == 'checkval': try: - proposed_value_type = self.objectspace._convert_boolean(param.text) == False + proposed_value_type = self.objectspace.convert_boolean(param.text) == False remove_params.append(param_idx) except TypeError as err: raise CreoleDictConsistencyError(_('cannot load checkval value for variable {}: {}').format(check.target, err)) @@ -1080,97 +976,6 @@ class SpaceAnnotator(object): variable.check.append(check_) del self.space.constraints.check - - def convert_fill(self, fill_space, space): # pylint: disable=C0111,R0912 - fills = {} - # sort fill/auto by index - for idx, fill in enumerate(fill_space): - fills[fill.index] = {'idx': idx, 'fill': fill} - del fill.index - indexes = list(fills.keys()) - indexes.sort() - del_idx = [] - for idx in indexes: - fill = fills[idx]['fill'] - variable = self.get_variable(fill.target) - if hasattr(variable, 'value'): - del variable.value - namespace = fill.namespace - # let's replace the target by the path - fill.target = self.paths.get_variable_path(fill.target, namespace) - if not fill.name in dir(self.eosfunc): - raise CreoleDictConsistencyError(_('cannot find fill function {}').format(fill.name)) - #is_probe = not fill.name in self.eosfunc.func_on_zephir_context - if hasattr(fill, 'param'): - for param in fill.param: - if param.type not in TYPE_PARAM_FILL: - raise CreoleDictConsistencyError(_('cannot use {} type as a param ' - 'in a fill/auto').format(param.type)) - if param.type == 'eole': - param.type = 'variable' - param_option_indexes = [] - for fill_idx, param in enumerate(fill.param): - if not hasattr(param, 'text') and \ - (param.type == 'variable' or param.type == 'number' or \ - param.type == 'python'): - raise CreoleDictConsistencyError(_("All '{}' variables shall be set in " - "order to calculate {}").format( - param.type, - fill.target)) - # if param.type == 'container': - # param.type = 'eole' - # param.text = 'container_ip_{}'.format(param.text) - if param.type == 'variable': - #if is_probe: - # raise CreoleDictConsistencyError(_('Function {0} used to calculate {1} ' - # 'is executed on remote server, ' - # 'so cannot depends to an ' - # 'other variable' - # ).format(fill.name, fill.target)) - # if HIGH_COMPATIBILITY and param.text.startswith('container_ip'): - # if param.optional is True: - # param_option_indexes.append(fill_idx) - try: - param.text, suffix = self.paths.get_variable_path(param.text, - namespace, - with_suffix=True) - if suffix: - param.suffix = suffix - except CreoleDictConsistencyError as err: - if param.optional is True: - param_option_indexes.append(fill_idx) - else: - raise err - param_option_indexes = list(set(param_option_indexes)) - param_option_indexes.sort(reverse=True) - for param_idx in param_option_indexes: - fill.param.pop(param_idx) - self.has_calc.append(fill.target) - - #if is_probe: - # variable.force_default_on_freeze = False - # self.objectspace.probe_variables.append(fill) - # del_idx.append(fills[idx]['idx']) - del_idx.sort(reverse=True) - for idx in del_idx: - space.constraints.fill.pop(idx) - for fill in space.constraints.fill: - variable = self.paths.get_variable_obj(fill.target) - value = self.objectspace.value() - value.type = 'calculation' - value.name = fill.name - if hasattr(fill, 'param'): - for param in fill.param: - if param.hidden is True: - param.transitive = False - param.hidden = None - value.param = fill.param - if not hasattr(variable, 'value'): - variable.value = [] - variable.value.append(value) - self.force_not_mandatory.append(fill.target) - del space.constraints.fill - def filter_targets(self): # pylint: disable=C0111 for condition_idx, condition in enumerate(self.space.constraints.condition): namespace = condition.namespace @@ -1228,15 +1033,14 @@ class SpaceAnnotator(object): if target.type in ['variable', 'family']: name = target.name.split('.')[-1] if target.type == 'variable': - variable = self.get_variable(name) + variable = self.paths.get_variable_obj(name) else: variable = self.paths.get_family_obj(name) if condition.name in ['disabled_if_in']: variable.disabled = True if condition.name in ['mandatory_if_in']: variable.mandatory = True - if condition.name in ['disabled_if_in', 'disabled_if_not_in', - 'frozen_if_in', 'frozen_if_not_in']: + if condition.name in ['frozen_if_in', 'frozen_if_not_in']: variable.hidden = False if HIGH_COMPATIBILITY: fallback_variables.append(name) @@ -1249,15 +1053,14 @@ class SpaceAnnotator(object): if listvars: for listvar in listvars: try: - variable = self.get_variable(listvar) + variable = self.paths.get_variable_obj(listvar) except CreoleDictConsistencyError: variable = self.paths.get_family_obj(listvar) if condition.name in ['disabled_if_in']: variable.disabled = True if condition.name in ['mandatory_if_in']: variable.mandatory = True - if condition.name in ['disabled_if_in', 'disabled_if_not_in', - 'frozen_if_in', 'frozen_if_not_in']: + if condition.name in ['frozen_if_in', 'frozen_if_not_in']: variable.hidden = False fallback_lists.append(listvar) remove_conditions.append(idx) @@ -1283,7 +1086,7 @@ class SpaceAnnotator(object): if listvar in fallback_lists: continue try: - variable = self.get_variable(listvar) + variable = self.paths.get_variable_obj(listvar) type_ = 'variable' except CreoleDictConsistencyError: variable = self.paths.get_family_obj(listvar) @@ -1347,7 +1150,7 @@ class SpaceAnnotator(object): else: name = target.name if target.type == 'variable': - variable = self.get_variable(name) + variable = self.paths.get_variable_obj(name) else: variable = self.paths.get_family_obj(name) if condition.name == 'disabled_if_not_in': @@ -1362,8 +1165,6 @@ class SpaceAnnotator(object): variable.mandatory = True force_remove_targets.setdefault(condition.name, []).append(target.name) - elif HIGH_COMPATIBILITY and condition.name == 'disabled_if_in': - variable.hidden = False remove_conditions.append(condition_idx) remove_conditions = list(set(remove_conditions)) remove_conditions.sort(reverse=True) @@ -1382,14 +1183,13 @@ class SpaceAnnotator(object): else: name = target.name if target.type == 'variable': - variable = self.get_variable(name) + variable = self.paths.get_variable_obj(name) else: variable = self.paths.get_family_obj(name) if name in fallback_variables: remove_targets.append(target_idx) continue - if condition.name in ['disabled_if_in', 'disabled_if_not_in', - 'frozen_if_in', 'frozen_if_not_in']: + if condition.name in ['frozen_if_in', 'frozen_if_not_in']: variable.hidden = False if condition.name in ['mandatory_if_in', 'mandatory_if_not_in']: variable.mandatory = False @@ -1463,7 +1263,7 @@ class SpaceAnnotator(object): else: name = target.name if target.type == 'variable': - variable = self.get_variable(name) + variable = self.paths.get_variable_obj(name) else: variable = self.paths.get_family_obj(name) if not hasattr(variable, 'property'): diff --git a/src/rougail/data/rougail.dtd b/src/rougail/data/rougail.dtd index 555c7397..778a84ec 100644 --- a/src/rougail/data/rougail.dtd +++ b/src/rougail/data/rougail.dtd @@ -37,17 +37,12 @@ - + - - - - - @@ -81,10 +76,6 @@ - - - - @@ -93,9 +84,6 @@ - - - @@ -106,8 +94,6 @@ - - @@ -158,7 +144,7 @@ - + @@ -168,10 +154,6 @@ - - - - diff --git a/src/rougail/objspace.py b/src/rougail/objspace.py index 4654e3b7..93f7c152 100644 --- a/src/rougail/objspace.py +++ b/src/rougail/objspace.py @@ -25,17 +25,16 @@ has to be moved in family2. The visit procedure changes the varable1's object sp """ from collections import OrderedDict from lxml.etree import Element, SubElement # pylint: disable=E0611 -from json import dump - from .i18n import _ from .xmlreflector import XMLReflector, HIGH_COMPATIBILITY -from .annotator import ERASED_ATTRIBUTES, ActionAnnotator, ServiceAnnotator, SpaceAnnotator +from .annotator import ERASED_ATTRIBUTES, ServiceAnnotator, SpaceAnnotator from .utils import normalize_family from .error import CreoleOperationError, SpaceObjShallNotBeUpdated, CreoleDictConsistencyError +from .path import Path # CreoleObjSpace's elements like 'family' or 'follower', that shall be forced to the Redefinable type -FORCE_REDEFINABLES = ('family', 'follower', 'service', 'disknod', 'variables', 'family_action') +FORCE_REDEFINABLES = ('family', 'follower', 'service', 'disknod', 'variables') # CreoleObjSpace's elements that shall be forced to the UnRedefinable type FORCE_UNREDEFINABLES = ('value', 'input', 'profile', 'ewtapp', 'tag', 'saltaction') # CreoleObjSpace's elements that shall be set to the UnRedefinable type @@ -48,16 +47,17 @@ CONVERT_PROPERTIES = {'auto_save': ['force_store_value'], 'auto_freeze': ['force RENAME_ATTIBUTES = {'description': 'doc'} INCOMPATIBLE_ATTRIBUTES = [['multi', 'submulti']] +FORCED_TEXT_ELTS_AS_NAME = ('choice', 'property') #TYPE_TARGET_CONDITION = ('variable', 'family') # _____________________________________________________________________________ # special types definitions for the Object Space's internal representation -class RootCreoleObject(object): +class RootCreoleObject: "" -class CreoleObjSpace(object): +class CreoleObjSpace: """DOM XML reflexion free internal representation of a Creole Dictionary """ choice = type('Choice', (RootCreoleObject,), OrderedDict()) @@ -78,80 +78,258 @@ class CreoleObjSpace(object): def __init__(self, dtdfilename): # pylint: disable=R0912 self.index = 0 - class ObjSpace(object): # pylint: disable=R0903 + class ObjSpace: # pylint: disable=R0903 """ Base object space """ self.space = ObjSpace() + self.paths = Path() self.xmlreflector = XMLReflector() self.xmlreflector.parse_dtd(dtdfilename) self.redefine_variables = None - self.probe_variables = [] # ['variable', 'separator', 'family'] self.forced_text_elts = set() - self.forced_text_elts_as_name = set(['choice', 'property']) - self.forced_choice_option = {} - self.paths = Path() + self.forced_text_elts_as_name = set(FORCED_TEXT_ELTS_AS_NAME) self.list_conditions = {} - self.booleans_attributs = [] - for elt in self.xmlreflector.dtd.iterelements(): - attrs = {} - clstype = self.UnRedefinable - atomic = True - forced_text_elt = False - if elt.type == 'mixed': - forced_text_elt = True - if elt.name == 'service': - self.parse_dtd_right_left_elt(elt.content) - for attr in elt.iterattributes(): - atomic = False - if attr.default_value: - if attr.default_value == 'True': - default_value = True - elif attr.default_value == 'False': - default_value = False - else: - default_value = attr.default_value - attrs[attr.name] = default_value - if not attr.name.endswith('_type'): - values = list(attr.itervalues()) - if values != []: - self.forced_choice_option.setdefault(elt.name, {})[attr.name] = values + self.make_object_space_class() - if attr.name == 'redefine': + def make_object_space_class(self): + """Create Rougail ObjectSpace class types, it enables us to create objects like: + File(), Variable(), Ip(), Family(), Constraints()... and so on. + + Creole ObjectSpace is an object's reflexion of the XML elements""" + + for dtd_elt in self.xmlreflector.dtd.iterelements(): + attrs = {} + if dtd_elt.name in FORCE_REDEFINABLES: + clstype = self.Redefinable + else: + clstype = self.UnRedefinable + atomic = dtd_elt.name not in FORCE_UNREDEFINABLES and dtd_elt.name not in FORCE_REDEFINABLES + forced_text_elt = dtd_elt.type == 'mixed' + for dtd_attr in dtd_elt.iterattributes(): + atomic = False + if set(dtd_attr.itervalues()) == set(['True', 'False']): + # it's a boolean + self.booleans_attributs.append(dtd_attr.name) + if dtd_attr.default_value: + # set default value for this attribute + default_value = dtd_attr.default_value + if dtd_attr.name in self.booleans_attributs: + default_value = self.convert_boolean(dtd_attr.default_value) + attrs[dtd_attr.name] = default_value + if dtd_attr.name == 'redefine': + # has a redefine attribute, so it's a Redefinable object clstype = self.Redefinable - if attr.name == 'name' and forced_text_elt is True: - self.forced_text_elts.add(elt.name) + if dtd_attr.name == 'name' and forced_text_elt: + # child.text should be transform has a "name" attribute + self.forced_text_elts.add(dtd_elt.name) forced_text_elt = False - if set(attr.itervalues()) == set(['True', 'False']): - self.booleans_attributs.append(attr.name) - if forced_text_elt is True: - self.forced_text_elts_as_name.add(elt.name) - - if elt.name in FORCE_REDEFINABLES: - clstype = self.Redefinable - elif elt.name in FORCE_UNREDEFINABLES: - clstype = self.UnRedefinable - elif atomic: + self.forced_text_elts_as_name.add(dtd_elt.name) + if atomic: + # has any attribute so it's an Atomic object clstype = self.Atom - # Creole ObjectSpace class types, it enables us to create objects like: - # Service_restriction(), Ip(), Interface(), Host(), Fstab(), Package(), Disknod(), - # File(), Variables(), Family(), Variable(), Separators(), Separator(), Value(), - # Constraints()... and so on. Creole ObjectSpace is an object's reflexion of - # the XML elements - setattr(self, elt.name, type(elt.name.capitalize(), (clstype,), attrs)) + # create ObjectSpace object + setattr(self, dtd_elt.name, type(dtd_elt.name.capitalize(), (clstype,), attrs)) - def parse_dtd_right_left_elt(self, elt): - if elt.right.type == 'or': - self.parse_dtd_right_left_elt(elt.right) + def create_or_populate_from_xml(self, + namespace, + xmlfolders): + """Parses a bunch of XML files + populates the CreoleObjSpace + """ + for xmlfile, document in self.xmlreflector.load_xml_from_folders(xmlfolders): + self.redefine_variables = [] + self.xml_parse_document(document, + self.space, + namespace, + ) - def _convert_boolean(self, value): # pylint: disable=R0201 + def xml_parse_document(self, + document, + space, + namespace, + ): + """Parses a Creole XML file + populates the CreoleObjSpace + """ + family_names = [] + for child in document: + # this index enables us to reorder objects + self.index += 1 + # doesn't proceed the XML commentaries + if not isinstance(child.tag, str): + continue + if child.tag == 'family': + if child.attrib['name'] in family_names: + raise CreoleDictConsistencyError(_('Family {} is set several times').format(child.attrib['name'])) + family_names.append(child.attrib['name']) + if child.tag == 'variables': + child.attrib['name'] = namespace + if HIGH_COMPATIBILITY and child.tag == 'value' and child.text == None: + # FIXME should not be here + continue + # creole objects creation + try: + creoleobj = self.generate_creoleobj(child, + space, + namespace, + ) + except SpaceObjShallNotBeUpdated: + continue + self.set_text_to_obj(child, + creoleobj, + ) + self.set_xml_attributes_to_obj(child, + creoleobj, + ) + self.creoleobj_tree_visitor(child, + creoleobj, + namespace, + ) + self.fill_creoleobj_path_attribute(space, + child, + namespace, + document, + creoleobj, + ) + self.add_to_tree_structure(creoleobj, + space, + child, + ) + if list(child) != []: + self.xml_parse_document(child, + creoleobj, + namespace, + ) + + def generate_creoleobj(self, + child, + space, + namespace, + ): + """ + instanciates or creates Creole Object Subspace objects + """ + creoleobj = getattr(self, child.tag)() + if isinstance(creoleobj, self.Redefinable): + creoleobj = self.create_or_update_redefinable_object(child.attrib, + space, + child, + namespace, + ) + elif isinstance(creoleobj, self.Atom) and child.tag in vars(space): + # instanciates an object from the CreoleObjSpace's builtins types + # example : child.tag = constraints -> a self.Constraints() object is created + # this Atom instance has to be a singleton here + # we do not re-create it, we reuse it + creoleobj = getattr(space, child.tag) + self.create_tree_structure(space, + child, + creoleobj, + ) + return creoleobj + + def create_or_update_redefinable_object(self, + subspace, + space, + child, + namespace, + ): + """Creates or retrieves the space object that corresponds + to the `child` XML object + + Two attributes of the `child` XML object are important: + + - with the `redefine` boolean flag attribute we know whether + the corresponding space object shall be created or updated + + - `True` means that the corresponding space object shall be updated + - `False` means that the corresponding space object shall be created + + - with the `exists` boolean flag attribute we know whether + the corresponding space object shall be created + (or nothing -- that is the space object isn't modified) + + - `True` means that the corresponding space object shall be created + - `False` means that the corresponding space object is not updated + + In the special case `redefine` is True and `exists` is False, + we create the corresponding space object if it doesn't exist + and we update it if it exists. + + :return: the corresponding space object of the `child` XML object + """ + if child.tag in self.forced_text_elts_as_name: + name = child.text + else: + name = subspace['name'] + if self.is_already_exists(name, + space, + child, + namespace, + ): + default_redefine = child.tag in FORCE_REDEFINABLES + redefine = self.convert_boolean(subspace.get('redefine', default_redefine)) + exists = self.convert_boolean(subspace.get('exists', True)) + if redefine is True: + return self.translate_in_space(name, + space, + child, + namespace, + ) + elif exists is False: + raise SpaceObjShallNotBeUpdated() + raise CreoleDictConsistencyError(_(f'Already present in another XML file, {name} cannot be re-created')) + redefine = self.convert_boolean(subspace.get('redefine', False)) + exists = self.convert_boolean(subspace.get('exists', False)) + if redefine is False or exists is True: + return getattr(self, child.tag)() + raise CreoleDictConsistencyError(_(f'Redefined object: {name} does not exist yet')) + + def create_tree_structure(self, + space, + child, + creoleobj, + ): # pylint: disable=R0201 + """ + Builds the tree structure of the object space here + we set services attributes in order to be populated later on + for example:: + + space = Family() + space.variable = OrderedDict() + another example: + space = Variable() + space.value = list() + """ + if child.tag not in vars(space): + if isinstance(creoleobj, self.Redefinable): + setattr(space, child.tag, OrderedDict()) + elif isinstance(creoleobj, self.UnRedefinable): + setattr(space, child.tag, []) + elif not isinstance(creoleobj, self.Atom): # pragma: no cover + raise CreoleOperationError(_("Creole object {} " + "has a wrong type").format(type(creoleobj))) + + def is_already_exists(self, name, space, child, namespace): + if isinstance(space, self.family): # pylint: disable=E1101 + if namespace != 'creole': + name = space.path + '.' + name + return self.paths.path_is_defined(name) + if child.tag == 'family': + norm_name = normalize_family(name) + else: + norm_name = name + return norm_name in getattr(space, child.tag, {}) + + def convert_boolean(self, value): # pylint: disable=R0201 """Boolean coercion. The Creole XML may contain srings like `True` or `False` """ if isinstance(value, bool): @@ -163,20 +341,14 @@ class CreoleObjSpace(object): else: raise TypeError(_('{} is not True or False').format(value)) # pragma: no cover - def _is_already_exists(self, name, space, child, namespace): - if isinstance(space, self.family): # pylint: disable=E1101 - if namespace != 'creole': - name = space.path + '.' + name - return self.paths.path_is_defined(name) - if child.tag in ['family', 'family_action']: - norm_name = normalize_family(name) - else: - norm_name = name - return norm_name in getattr(space, child.tag, {}) - - def _translate_in_space(self, name, family, variable, namespace): + def translate_in_space(self, + name, + family, + variable, + namespace, + ): if not isinstance(family, self.family): # pylint: disable=E1101 - if variable.tag in ['family', 'family_action']: + if variable.tag == 'family': norm_name = normalize_family(name) else: norm_name = name @@ -213,6 +385,7 @@ class CreoleObjSpace(object): remove_checks.sort(reverse=True) for idx in remove_checks: self.space.constraints.check.pop(idx) # pylint: disable=E1101 + def remove_condition(self, name): # pylint: disable=C0111 for idx, condition in enumerate(self.space.constraints.condition): # pylint: disable=E1101 remove_targets = [] @@ -225,101 +398,14 @@ class CreoleObjSpace(object): for idx in remove_targets: del condition.target[idx] - def create_or_update_space_object(self, subspace, space, child, namespace): - """Creates or retrieves the space object that corresponds - to the `child` XML object - - Two attributes of the `child` XML object are important: - - - with the `redefine` boolean flag attribute we know whether - the corresponding space object shall be created or updated - - - `True` means that the corresponding space object shall be updated - - `False` means that the corresponding space object shall be created - - - with the `exists` boolean flag attribute we know whether - the corresponding space object shall be created - (or nothing -- that is the space object isn't modified) - - - `True` means that the corresponding space object shall be created - - `False` means that the corresponding space object is not updated - - In the special case `redefine` is True and `exists` is False, - we create the corresponding space object if it doesn't exist - and we update it if it exists. - - :return: the corresponding space object of the `child` XML object - """ - if child.tag in self.forced_text_elts_as_name: - name = child.text - else: - name = subspace['name'] - if self._is_already_exists(name, space, child, namespace): - if child.tag in FORCE_REDEFINABLES: - redefine = self._convert_boolean(subspace.get('redefine', True)) - else: - redefine = self._convert_boolean(subspace.get('redefine', False)) - exists = self._convert_boolean(subspace.get('exists', True)) - if redefine is True: - return self._translate_in_space(name, space, child, namespace) - elif exists is False: - raise SpaceObjShallNotBeUpdated() - else: - raise CreoleDictConsistencyError(_('Already present in another XML file, {} ' - 'cannot be re-created').format(name)) - else: - redefine = self._convert_boolean(subspace.get('redefine', False)) - exists = self._convert_boolean(subspace.get('exists', False)) - if redefine is False or exists is True: - return getattr(self, child.tag)() - else: - raise CreoleDictConsistencyError(_('Redefined object: ' - '{} does not exist yet').format(name)) - - def generate_creoleobj(self, child, space, namespace): - """ - instanciates or creates Creole Object Subspace objects - """ - if issubclass(getattr(self, child.tag), self.Redefinable): - creoleobj = self.create_or_update_space_object(child.attrib, space, child, namespace) - else: - # instanciates an object from the CreoleObjSpace's builtins types - # example : child.tag = constraints -> a self.Constraints() object is created - creoleobj = getattr(self, child.tag)() - # this Atom instance has to be a singleton here - # we do not re-create it, we reuse it - if isinstance(creoleobj, self.Atom) and child.tag in vars(space): - creoleobj = getattr(space, child.tag) - self.create_tree_structure(space, child, creoleobj) - return creoleobj - - def create_tree_structure(self, space, child, creoleobj): # pylint: disable=R0201 - """ - Builds the tree structure of the object space here - we set services attributes in order to be populated later on - for example:: - - space = Family() - space.variable = OrderedDict() - another example: - space = Variable() - space.value = list() - """ - if child.tag not in vars(space): - if isinstance(creoleobj, self.Redefinable): - setattr(space, child.tag, OrderedDict()) - elif isinstance(creoleobj, self.UnRedefinable): - setattr(space, child.tag, []) - elif isinstance(creoleobj, self.Atom): - pass - else: # pragma: no cover - raise CreoleOperationError(_("Creole object {} " - "has a wrong type").format(type(creoleobj))) - - def _add_to_tree_structure(self, creoleobj, space, child): # pylint: disable=R0201 + def add_to_tree_structure(self, + creoleobj, + space, + child, + ): # pylint: disable=R0201 if isinstance(creoleobj, self.Redefinable): name = creoleobj.name - if child.tag == 'family' or child.tag == 'family_action': + if child.tag == 'family': name = normalize_family(name) getattr(space, child.tag)[name] = creoleobj elif isinstance(creoleobj, self.UnRedefinable): @@ -327,7 +413,10 @@ class CreoleObjSpace(object): else: setattr(space, child.tag, creoleobj) - def _set_text_to_obj(self, child, creoleobj): + def set_text_to_obj(self, + child, + creoleobj, + ): if child.text is None: text = None else: @@ -338,28 +427,24 @@ class CreoleObjSpace(object): else: creoleobj.text = text - def _set_xml_attributes_to_obj(self, child, creoleobj): - redefine = self._convert_boolean(child.attrib.get('redefine', False)) + def set_xml_attributes_to_obj(self, + child, + creoleobj, + ): + redefine = self.convert_boolean(child.attrib.get('redefine', False)) has_value = hasattr(creoleobj, 'value') if HIGH_COMPATIBILITY and has_value: has_value = len(child) != 1 or child[0].text != None - if (redefine is True and child.tag == 'variable' and has_value - and len(child) != 0): + if redefine is True and child.tag == 'variable' and has_value and len(child) != 0: del creoleobj.value for attr, val in child.attrib.items(): if redefine and attr in UNREDEFINABLE: # UNREDEFINABLE concerns only 'variable' node so we can fix name # to child.attrib['name'] name = child.attrib['name'] - raise CreoleDictConsistencyError(_("cannot redefine attribute {} for variable {}").format(attr, name)) - if isinstance(getattr(creoleobj, attr, None), bool): - if val == 'False': - val = False - elif val == 'True': - val = True - else: # pragma: no cover - raise CreoleOperationError(_('value for {} must be True or False, ' - 'not {}').format(attr, val)) + raise CreoleDictConsistencyError(_(f'cannot redefine attribute {attr} for variable {name}')) + if attr in self.booleans_attributs: + val = self.convert_boolean(val) if not (attr == 'name' and getattr(creoleobj, 'name', None) != None): setattr(creoleobj, attr, val) keys = list(vars(creoleobj).keys()) @@ -371,113 +456,63 @@ class CreoleObjSpace(object): raise CreoleDictConsistencyError(_('those attributes are incompatible {}').format(incompatible)) found = True - - def _creoleobj_tree_visitor(self, child, creoleobj, namespace): + def creoleobj_tree_visitor(self, + child, + creoleobj, + namespace, + ): """Creole object tree manipulations """ - if child.tag == 'variable' and child.attrib.get('remove_check', False): - self.remove_check(creoleobj.name) - if child.tag == 'variable' and child.attrib.get('remove_condition', False): - self.remove_condition(creoleobj.name) - if child.tag in ['auto', 'fill', 'check']: - variable_name = child.attrib['target'] + if child.tag == 'variable': + if child.attrib.get('remove_check', False): + self.remove_check(creoleobj.name) + if child.attrib.get('remove_condition', False): + self.remove_condition(creoleobj.name) + if child.tag in ['fill', 'check']: + # if variable is a redefine in current dictionary # XXX not working with variable not in creole and in leader/followers - if variable_name in self.redefine_variables: - creoleobj.redefine = True - else: - creoleobj.redefine = False + creoleobj.redefine = child.attrib['target'] in self.redefine_variables if not hasattr(creoleobj, 'index'): creoleobj.index = self.index - if child.tag in ['auto', 'fill', 'condition', 'check', 'action']: + if child.tag in ['fill', 'condition', 'check', 'action']: creoleobj.namespace = namespace - def xml_parse_document(self, document, space, namespace, is_in_family=False): - """Parses a Creole XML file - populates the CreoleObjSpace - """ - family_names = [] - for child in document: - # this index enables us to reorder the 'fill' and 'auto' objects - self.index += 1 - # doesn't proceed the XML commentaries - if not isinstance(child.tag, str): - continue - if child.tag == 'family': - is_in_family = True - if child.attrib['name'] in family_names: - raise CreoleDictConsistencyError(_('Family {} is set several times').format(child.attrib['name'])) - family_names.append(child.attrib['name']) - if child.tag == 'variables': - child.attrib['name'] = namespace - if HIGH_COMPATIBILITY and child.tag == 'value' and child.text == None: - continue - # creole objects creation - try: - creoleobj = self.generate_creoleobj(child, space, namespace) - except SpaceObjShallNotBeUpdated: - continue - self._set_text_to_obj(child, creoleobj) - self._set_xml_attributes_to_obj(child, creoleobj) - self._creoleobj_tree_visitor(child, creoleobj, namespace) - self._fill_creoleobj_path_attribute(space, child, namespace, document, creoleobj) - self._add_to_tree_structure(creoleobj, space, child) - if list(child) != []: - self.xml_parse_document(child, creoleobj, namespace, is_in_family) - - def _fill_creoleobj_path_attribute(self, - space, - child, - namespace, - document, - creoleobj, - ): # pylint: disable=R0913 + def fill_creoleobj_path_attribute(self, + space, + child, + namespace, + document, + creoleobj, + ): # pylint: disable=R0913 """Fill self.paths attributes """ - if not isinstance(space, self.help): # pylint: disable=E1101 - if child.tag == 'variable': - family_name = normalize_family(document.attrib['name']) - self.paths.add_variable(namespace, - child.attrib['name'], - family_name, - document.attrib.get('dynamic') != None, - creoleobj) - if child.attrib.get('redefine', 'False') == 'True': - if namespace == 'creole': - self.redefine_variables.append(child.attrib['name']) - else: - self.redefine_variables.append(namespace + '.' + family_name + '.' + - child.attrib['name']) + if isinstance(space, self.help): # pylint: disable=E1101 + return + if child.tag == 'variable': + family_name = normalize_family(document.attrib['name']) + self.paths.add_variable(namespace, + child.attrib['name'], + family_name, + document.attrib.get('dynamic') != None, + creoleobj) + if child.attrib.get('redefine', 'False') == 'True': + if namespace == 'creole': + self.redefine_variables.append(child.attrib['name']) + else: + self.redefine_variables.append(namespace + '.' + family_name + '.' + + child.attrib['name']) - if child.tag == 'family': - family_name = normalize_family(child.attrib['name']) - if namespace != 'creole': - family_name = namespace + '.' + family_name - self.paths.add_family(namespace, - family_name, - creoleobj, - ) - creoleobj.path = self.paths.get_family_path(family_name, namespace) - - def create_or_populate_from_xml(self, namespace, xmlfolders, from_zephir=None): - """Parses a bunch of XML files - populates the CreoleObjSpace - """ - documents = self.xmlreflector.load_xml_from_folders(xmlfolders, from_zephir) - for xmlfile, document in documents: - try: - self.redefine_variables = [] - self.xml_parse_document(document, self.space, namespace) - except Exception as err: - #print(_('error in XML file {}').format(xmlfile)) - raise err - - def populate_from_zephir(self, namespace, xmlfile): - self.redefine_variables = [] - document = self.xmlreflector.parse_xmlfile(xmlfile, from_zephir=True, zephir2=True) - self.xml_parse_document(document, self.space, namespace) + elif child.tag == 'family': + family_name = normalize_family(child.attrib['name']) + if namespace != 'creole': + family_name = namespace + '.' + family_name + self.paths.add_family(namespace, + family_name, + creoleobj, + ) + creoleobj.path = self.paths.get_family_path(family_name, namespace) def space_visitor(self, eosfunc_file): # pylint: disable=C0111 - ActionAnnotator(self) ServiceAnnotator(self) SpaceAnnotator(self, eosfunc_file) @@ -486,42 +521,13 @@ class CreoleObjSpace(object): :param filename: the full XML filename """ - xml = Element('creole') + xml = Element('rougail') self._xml_export(xml, self.space) if not force_no_save: self.xmlreflector.save_xmlfile(filename, xml) return xml - def save_probes(self, filename, force_no_save=False): - """Save an XML output on disk - - :param filename: the full XML filename - """ - ret = {} - for variable in self.probe_variables: - args = [] - kwargs = {} - if hasattr(variable, 'param'): - for param in variable.param: - list_param = list(vars(param).keys()) - if 'index' in list_param: - list_param.remove('index') - if list_param == ['text']: - args.append(param.text) - elif list_param == ['text', 'name']: - kwargs[param.name] = param.text - else: - print(vars(param)) - raise Exception('hu?') - ret[variable.target] = {'function': variable.name, - 'args': args, - 'kwargs': kwargs} - if not force_no_save: - with open(filename, 'w') as fhj: - dump(ret, fhj) - return ret - - def _get_attributes(self, space): # pylint: disable=R0201 + def get_attributes(self, space): # pylint: disable=R0201 for attr in dir(space): if not attr.startswith('_'): yield attr @@ -549,13 +555,13 @@ class CreoleObjSpace(object): child_node.attrib['name'] = name else: child_node = SubElement(node, name) - for subname in self._get_attributes(space): + for subname in self.get_attributes(space): subspace = getattr(space, subname) self._sub_xml_export(subname, child_node, name, subspace, space) elif isinstance(space, self.Redefinable): child_node = SubElement(node, 'family') child_node.attrib['name'] = name - for subname in self._get_attributes(space): + for subname in self.get_attributes(space): subspace = getattr(space, subname) self._sub_xml_export(subname, child_node, name, subspace, space) else: @@ -587,192 +593,6 @@ class CreoleObjSpace(object): node.attrib[name] = str(space) def _xml_export(self, node, space, node_name='creole'): - for name in self._get_attributes(space): + for name in self.get_attributes(space): subspace = getattr(space, name) self._sub_xml_export(name, node, node_name, subspace, space) - - -class Path: - """Helper class to handle the `path` attribute of a CreoleObjSpace - instance. - - sample: path="creole.general.condition" - """ - def __init__(self): - self.variables = {} - self.families = {} - - # Family - def add_family(self, - namespace: str, - name: str, - creoleobj: str, - ) -> str: # pylint: disable=C0111 - self.families[name] = dict(name=name, - namespace=namespace, - creoleobj=creoleobj, - ) - - def get_family_path(self, - name: str, - current_namespace: str, - ) -> str: # pylint: disable=C0111 - if current_namespace is None: # pragma: no cover - raise CreoleOperationError('current_namespace must not be None') - dico = self.families[normalize_family(name, - check_name=False, - allow_dot=True, - )] - if dico['namespace'] != 'creole' and current_namespace != dico['namespace']: - raise CreoleDictConsistencyError(_('A family located in the {} namespace ' - 'shall not be used in the {} namespace').format( - dico['namespace'], current_namespace)) - path = dico['name'] - if dico['namespace'] is not None and '.' not in dico['name']: - path = '.'.join([dico['namespace'], path]) - return path - - def get_family_namespace(self, - name: str, - ) -> str: # pylint: disable=C0111 - dico = self.families[name] - if dico['namespace'] is None: - return dico['name'] - return dico['namespace'] - - def get_family_obj(self, - name: str, - ) -> 'Family': # pylint: disable=C0111 - if name not in self.families: - raise CreoleDictConsistencyError(_('unknown family {}').format(name)) - dico = self.families[name] - return dico['creoleobj'] - - # Leadership - def set_leader(self, - namespace: str, - leader_family_name: str, - name: str, - leader_name: str, - ) -> None: # pylint: disable=C0111 - if namespace != 'creole': - # need rebuild path and move object in new path - old_path = namespace + '.' + leader_family_name + '.' + name - dico = self._get_variable(old_path) - del self.variables[old_path] - new_path = namespace + '.' + leader_family_name + '.' + leader_name + '.' + name - self.add_variable(namespace, - new_path, - dico['family'], - False, - dico['creoleobj'], - ) - name = new_path - dico = self._get_variable(name) - if dico['leader'] != None: - raise CreoleDictConsistencyError(_('Already defined leader {} for variable' - ' {}'.format(dico['leader'], name))) - dico['leader'] = leader_name - - def get_leader(self, name): # pylint: disable=C0111 - return self._get_variable(name)['leader'] - - # Variable - def add_variable(self, - namespace: str, - name: str, - family: str, - is_dynamic: bool, - creoleobj, - ) -> str: # pylint: disable=C0111 - if namespace == 'creole' or '.' in name: - varname = name - else: - varname = '.'.join([namespace, family, name]) - self.variables[varname] = dict(name=name, - family=family, - namespace=namespace, - leader=None, - is_dynamic=is_dynamic, - creoleobj=creoleobj) - - def get_variable_name(self, - name, - ): # pylint: disable=C0111 - return self._get_variable(name)['name'] - - def get_variable_obj(self, - name:str, - ) -> 'Variable': # pylint: disable=C0111 - return self._get_variable(name)['creoleobj'] - - def get_variable_family_name(self, - name: str, - ) -> str: # pylint: disable=C0111 - return self._get_variable(name)['family'] - - def get_variable_family_path(self, - name: str, - ) -> str: # pylint: disable=C0111 - dico = self._get_variable(name) - list_path = [dico['namespace'], dico['family']] - if dico['leader'] is not None: - list_path.append(dico['leader']) - return '.'.join(list_path) - - def get_variable_namespace(self, - name: str, - ) -> str: # pylint: disable=C0111 - return self._get_variable(name)['namespace'] - - def get_variable_path(self, - name: str, - current_namespace: str, - allow_source: str=False, - with_suffix: bool=False, - ) -> str: # pylint: disable=C0111 - if current_namespace is None: # pragma: no cover - raise CreoleOperationError('current_namespace must not be None') - if with_suffix: - dico, suffix = self._get_variable(name, - with_suffix=True, - ) - else: - dico = self._get_variable(name) - if not allow_source: - if dico['namespace'] not in ['creole', 'services'] and current_namespace != dico['namespace']: - raise CreoleDictConsistencyError(_('A variable located in the {} namespace ' - 'shall not be used in the {} namespace').format( - dico['namespace'], current_namespace)) - if '.' in dico['name']: - value = dico['name'] - else: - list_path = [dico['namespace'], dico['family']] - if dico['leader'] is not None: - list_path.append(dico['leader']) - list_path.append(dico['name']) - value = '.'.join(list_path) - if with_suffix: - return value, suffix - return value - - def path_is_defined(self, - name: str, - ) -> str: # pylint: disable=C0111 - return name in self.variables - - def _get_variable(self, - name: str, - with_suffix: bool=False, - ) -> str: - if name not in self.variables: - if name.startswith('creole.'): - name = name.split('.')[-1] - if name not in self.variables: - for var_name, variable in self.variables.items(): - if variable['is_dynamic'] and name.startswith(var_name): - return variable, name[len(var_name):] - raise CreoleDictConsistencyError(_('unknown option {}').format(name)) - if with_suffix: - return self.variables[name], None - return self.variables[name] diff --git a/src/rougail/path.py b/src/rougail/path.py new file mode 100644 index 00000000..9d7995ee --- /dev/null +++ b/src/rougail/path.py @@ -0,0 +1,182 @@ +from .i18n import _ +from .utils import normalize_family +from .error import CreoleOperationError, CreoleDictConsistencyError + + +class Path: + """Helper class to handle the `path` attribute of a CreoleObjSpace + instance. + + sample: path="creole.general.condition" + """ + def __init__(self): + self.variables = {} + self.families = {} + + # Family + def add_family(self, + namespace: str, + name: str, + creoleobj: str, + ) -> str: # pylint: disable=C0111 + self.families[name] = dict(name=name, + namespace=namespace, + creoleobj=creoleobj, + ) + + def get_family_path(self, + name: str, + current_namespace: str, + ) -> str: # pylint: disable=C0111 + if current_namespace is None: # pragma: no cover + raise CreoleOperationError('current_namespace must not be None') + dico = self.families[normalize_family(name, + check_name=False, + allow_dot=True, + )] + if dico['namespace'] != 'creole' and current_namespace != dico['namespace']: + raise CreoleDictConsistencyError(_('A family located in the {} namespace ' + 'shall not be used in the {} namespace').format( + dico['namespace'], current_namespace)) + path = dico['name'] + if dico['namespace'] is not None and '.' not in dico['name']: + path = '.'.join([dico['namespace'], path]) + return path + + def get_family_obj(self, + name: str, + ) -> 'Family': # pylint: disable=C0111 + if name not in self.families: + raise CreoleDictConsistencyError(_('unknown family {}').format(name)) + dico = self.families[name] + return dico['creoleobj'] + + # Leadership + def set_leader(self, + namespace: str, + leader_family_name: str, + name: str, + leader_name: str, + ) -> None: # pylint: disable=C0111 + if namespace != 'creole': + # need rebuild path and move object in new path + old_path = namespace + '.' + leader_family_name + '.' + name + dico = self._get_variable(old_path) + del self.variables[old_path] + new_path = namespace + '.' + leader_family_name + '.' + leader_name + '.' + name + self.add_variable(namespace, + new_path, + dico['family'], + False, + dico['creoleobj'], + ) + name = new_path + dico = self._get_variable(name) + if dico['leader'] != None: + raise CreoleDictConsistencyError(_('Already defined leader {} for variable' + ' {}'.format(dico['leader'], name))) + dico['leader'] = leader_name + + def get_leader(self, name): # pylint: disable=C0111 + return self._get_variable(name)['leader'] + + # Variable + def add_variable(self, + namespace: str, + name: str, + family: str, + is_dynamic: bool, + creoleobj, + ) -> str: # pylint: disable=C0111 + if namespace == 'creole' or '.' in name: + varname = name + else: + varname = '.'.join([namespace, family, name]) + self.variables[varname] = dict(name=name, + family=family, + namespace=namespace, + leader=None, + is_dynamic=is_dynamic, + creoleobj=creoleobj) + + def get_variable_name(self, + name, + ): # pylint: disable=C0111 + return self._get_variable(name)['name'] + + def get_variable_obj(self, + name:str, + ) -> 'Variable': # pylint: disable=C0111 + return self._get_variable(name)['creoleobj'] + + def get_variable_family_name(self, + name: str, + ) -> str: # pylint: disable=C0111 + return self._get_variable(name)['family'] + + def get_variable_family_path(self, + name: str, + ) -> str: # pylint: disable=C0111 + dico = self._get_variable(name) + list_path = [dico['namespace'], dico['family']] + if dico['leader'] is not None: + list_path.append(dico['leader']) + return '.'.join(list_path) + + def get_variable_namespace(self, + name: str, + ) -> str: # pylint: disable=C0111 + return self._get_variable(name)['namespace'] + + def get_variable_path(self, + name: str, + current_namespace: str, + allow_source: str=False, + with_suffix: bool=False, + ) -> str: # pylint: disable=C0111 + if current_namespace is None: # pragma: no cover + raise CreoleOperationError('current_namespace must not be None') + if with_suffix: + dico, suffix = self._get_variable(name, + with_suffix=True, + ) + else: + dico = self._get_variable(name) + if not allow_source: + if dico['namespace'] not in ['creole', 'services'] and current_namespace != dico['namespace']: + raise CreoleDictConsistencyError(_('A variable located in the {} namespace ' + 'shall not be used in the {} namespace').format( + dico['namespace'], current_namespace)) + if '.' in dico['name']: + value = dico['name'] + else: + list_path = [dico['namespace'], dico['family']] + if dico['leader'] is not None: + list_path.append(dico['leader']) + list_path.append(dico['name']) + value = '.'.join(list_path) + if with_suffix: + return value, suffix + return value + + def path_is_defined(self, + name: str, + ) -> str: # pylint: disable=C0111 + return name in self.variables + + def _get_variable(self, + name: str, + with_suffix: bool=False, + ) -> str: + if name not in self.variables: + if name.startswith('creole.'): + name = name.split('.')[-1] + if name not in self.variables: + for var_name, variable in self.variables.items(): + if variable['is_dynamic'] and name.startswith(var_name): + return variable, name[len(var_name):] + raise CreoleDictConsistencyError(_('unknown option {}').format(name)) + if with_suffix: + return self.variables[name], None + return self.variables[name] + diff --git a/src/rougail/xmlreflector.py b/src/rougail/xmlreflector.py index 59436b2e..6b0f0bbf 100644 --- a/src/rougail/xmlreflector.py +++ b/src/rougail/xmlreflector.py @@ -35,58 +35,53 @@ class XMLReflector(object): :returns: the root element tree object """ - # FIXME zephir2 # document = parse(BytesIO(xmlfile), XMLParser(remove_blank_text=True)) document = parse(xmlfile) if not self.dtd.validate(document): raise CreoleDictConsistencyError(_("not a valid xml file: {}").format(xmlfile)) return document.getroot() - def load_xml_from_folders(self, xmlfolders, from_zephir): + def load_xml_from_folders(self, xmlfolders): """Loads all the XML files located in the xmlfolders' list :param xmlfolders: list of full folder's name """ documents = [] - if from_zephir: - for idx, xmlfile in enumerate(xmlfolders): - documents.append(('generate_{}'.format(idx), self.parse_xmlfile(xmlfile, from_zephir=from_zephir))) - else: - if not isinstance(xmlfolders, list): - xmlfolders = [xmlfolders] - for xmlfolder in xmlfolders: - if isinstance(xmlfolder, list) or isinstance(xmlfolder, tuple): - # directory group : collect files from each - # directory and sort them before loading - group_files = [] - for idx, subdir in enumerate(xmlfolder): - if isdir(subdir): - for filename in listdir(subdir): - group_files.append((filename, idx, subdir)) - else: - group_files.append(basename(subdir), idx, dirname(subdir)) - def sort_group(file1, file2): - if file1[0] == file2[0]: - # sort by initial xmlfolder order if same name - return file1[1].__cmp__(file2[1]) - # sort by filename - elif file1[0] > file2[0]: - return 1 - else: - return -1 - group_files.sort(sort_group) - filenames = [join(f[2], f[0]) for f in group_files] - elif isdir(xmlfolder): - filenames = [] - for filename in listdir(xmlfolder): - filenames.append(join(xmlfolder, filename)) - filenames.sort() - else: - filenames = [xmlfolder] - for xmlfile in filenames: - if xmlfile.endswith('.xml'): - #xmlfile_path = join(xmlfolder, xmlfile) - documents.append((xmlfile, self.parse_xmlfile(xmlfile))) + if not isinstance(xmlfolders, list): + xmlfolders = [xmlfolders] + for xmlfolder in xmlfolders: + if isinstance(xmlfolder, list) or isinstance(xmlfolder, tuple): + # directory group : collect files from each + # directory and sort them before loading + group_files = [] + for idx, subdir in enumerate(xmlfolder): + if isdir(subdir): + for filename in listdir(subdir): + group_files.append((filename, idx, subdir)) + else: + group_files.append(basename(subdir), idx, dirname(subdir)) + def sort_group(file1, file2): + if file1[0] == file2[0]: + # sort by initial xmlfolder order if same name + return file1[1].__cmp__(file2[1]) + # sort by filename + elif file1[0] > file2[0]: + return 1 + else: + return -1 + group_files.sort(sort_group) + filenames = [join(f[2], f[0]) for f in group_files] + elif isdir(xmlfolder): + filenames = [] + for filename in listdir(xmlfolder): + filenames.append(join(xmlfolder, filename)) + filenames.sort() + else: + filenames = [xmlfolder] + for xmlfile in filenames: + if xmlfile.endswith('.xml'): + #xmlfile_path = join(xmlfolder, xmlfile) + documents.append((xmlfile, self.parse_xmlfile(xmlfile))) return documents def save_xmlfile(self, xmlfilename, xml): # pylint: disable=R0201 diff --git a/tests/eosfunc/test.py b/tests/eosfunc/test.py index 638625f1..210a332e 100644 --- a/tests/eosfunc/test.py +++ b/tests/eosfunc/test.py @@ -59,3 +59,7 @@ def cdrom_minormajor(*args, **kwargs): def device_type(*args, **kwargs): pass + + +def calc_list(*args, **kwargs): + return [] diff --git a/tests/flattener_dicos/00empty/result/00-base.xml b/tests/flattener_dicos/00empty/result/00-base.xml index 320698ef..944cc083 100644 --- a/tests/flattener_dicos/00empty/result/00-base.xml +++ b/tests/flattener_dicos/00empty/result/00-base.xml @@ -1,8 +1,6 @@ - + - - basic - + - + diff --git a/tests/flattener_dicos/00load_autofreeze/result/00-base.xml b/tests/flattener_dicos/00load_autofreeze/result/00-base.xml index 5480153d..7cb08d61 100644 --- a/tests/flattener_dicos/00load_autofreeze/result/00-base.xml +++ b/tests/flattener_dicos/00load_autofreeze/result/00-base.xml @@ -1,5 +1,5 @@ - + basic @@ -23,4 +23,4 @@ - + diff --git a/tests/flattener_dicos/00load_autofreezeexpert/result/00-base.xml b/tests/flattener_dicos/00load_autofreezeexpert/result/00-base.xml index c7505ff3..0c50974c 100644 --- a/tests/flattener_dicos/00load_autofreezeexpert/result/00-base.xml +++ b/tests/flattener_dicos/00load_autofreezeexpert/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -23,4 +23,4 @@ - + diff --git a/tests/flattener_dicos/00load_autosave/result/00-base.xml b/tests/flattener_dicos/00load_autosave/result/00-base.xml index f9a036dc..e85260bf 100644 --- a/tests/flattener_dicos/00load_autosave/result/00-base.xml +++ b/tests/flattener_dicos/00load_autosave/result/00-base.xml @@ -1,5 +1,5 @@ - + basic @@ -14,4 +14,4 @@ - + diff --git a/tests/flattener_dicos/00load_autosaveexpert/result/00-base.xml b/tests/flattener_dicos/00load_autosaveexpert/result/00-base.xml index e20230d3..62b4e978 100644 --- a/tests/flattener_dicos/00load_autosaveexpert/result/00-base.xml +++ b/tests/flattener_dicos/00load_autosaveexpert/result/00-base.xml @@ -1,5 +1,5 @@ - + expert @@ -14,4 +14,4 @@ - + diff --git a/tests/flattener_dicos/00load_comment/makedict/base.json b/tests/flattener_dicos/00load_comment/makedict/base.json new file mode 100644 index 00000000..f06f2ed8 --- /dev/null +++ b/tests/flattener_dicos/00load_comment/makedict/base.json @@ -0,0 +1 @@ +{"creole.general.mode_conteneur_actif": "non"} diff --git a/tests/flattener_dicos/00load_comment/result/00-base.xml b/tests/flattener_dicos/00load_comment/result/00-base.xml index 7231f218..1a57bb8d 100644 --- a/tests/flattener_dicos/00load_comment/result/00-base.xml +++ b/tests/flattener_dicos/00load_comment/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -16,4 +16,4 @@ - + diff --git a/tests/flattener_dicos/00load_notype/makedict/base.json b/tests/flattener_dicos/00load_notype/makedict/base.json index 87b2ec3b..b13db160 100644 --- a/tests/flattener_dicos/00load_notype/makedict/base.json +++ b/tests/flattener_dicos/00load_notype/makedict/base.json @@ -1 +1 @@ -{"creole.general.without_type": "non"} +{"creole.general.mode_conteneur_actif": "non", "creole.general.without_type": "non"} diff --git a/tests/flattener_dicos/00load_notype/result/00-base.xml b/tests/flattener_dicos/00load_notype/result/00-base.xml index 68bd88a8..54fe43d1 100644 --- a/tests/flattener_dicos/00load_notype/result/00-base.xml +++ b/tests/flattener_dicos/00load_notype/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -21,4 +21,4 @@ - + diff --git a/tests/flattener_dicos/00load_save/makedict/base.json b/tests/flattener_dicos/00load_save/makedict/base.json new file mode 100644 index 00000000..f06f2ed8 --- /dev/null +++ b/tests/flattener_dicos/00load_save/makedict/base.json @@ -0,0 +1 @@ +{"creole.general.mode_conteneur_actif": "non"} diff --git a/tests/flattener_dicos/00load_save/result/00-base.xml b/tests/flattener_dicos/00load_save/result/00-base.xml index 7231f218..1a57bb8d 100644 --- a/tests/flattener_dicos/00load_save/result/00-base.xml +++ b/tests/flattener_dicos/00load_save/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -16,4 +16,4 @@ - + diff --git a/tests/flattener_dicos/00load_subfolder/makedict/base.json b/tests/flattener_dicos/00load_subfolder/makedict/base.json new file mode 100644 index 00000000..dcccb00c --- /dev/null +++ b/tests/flattener_dicos/00load_subfolder/makedict/base.json @@ -0,0 +1 @@ +{"creole.general.mode_conteneur_actif": "non", "creole.general.mode_conteneur_actif1": "non"} diff --git a/tests/flattener_dicos/00load_subfolder/result/00-base.xml b/tests/flattener_dicos/00load_subfolder/result/00-base.xml index fb91ca91..f7e00d90 100644 --- a/tests/flattener_dicos/00load_subfolder/result/00-base.xml +++ b/tests/flattener_dicos/00load_subfolder/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -26,4 +26,4 @@ - + diff --git a/tests/flattener_dicos/01auto_base/00-base.xml b/tests/flattener_dicos/01auto_base/00-base.xml index 58619ec9..edf7fd20 100644 --- a/tests/flattener_dicos/01auto_base/00-base.xml +++ b/tests/flattener_dicos/01auto_base/00-base.xml @@ -16,9 +16,9 @@ - + mode_conteneur_actif1 - + diff --git a/tests/flattener_dicos/01auto_base/makedict/base.json b/tests/flattener_dicos/01auto_base/makedict/base.json index 8f8f47c6..530abf24 100644 --- a/tests/flattener_dicos/01auto_base/makedict/base.json +++ b/tests/flattener_dicos/01auto_base/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif1": "non"} +{"creole.general.mode_conteneur_actif": null, "creole.general.mode_conteneur_actif1": "non"} diff --git a/tests/flattener_dicos/01auto_base/result/00-base.xml b/tests/flattener_dicos/01auto_base/result/00-base.xml index e76c5ccd..5ff153fb 100644 --- a/tests/flattener_dicos/01auto_base/result/00-base.xml +++ b/tests/flattener_dicos/01auto_base/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -25,4 +25,4 @@ - + diff --git a/tests/flattener_dicos/01auto_withoutparam/00-base.xml b/tests/flattener_dicos/01auto_withoutparam/00-base.xml index 4808a541..5c07d2c3 100644 --- a/tests/flattener_dicos/01auto_withoutparam/00-base.xml +++ b/tests/flattener_dicos/01auto_withoutparam/00-base.xml @@ -16,8 +16,8 @@ - - + + diff --git a/tests/flattener_dicos/01auto_withoutparam/makedict/base.json b/tests/flattener_dicos/01auto_withoutparam/makedict/base.json index 8f8f47c6..530abf24 100644 --- a/tests/flattener_dicos/01auto_withoutparam/makedict/base.json +++ b/tests/flattener_dicos/01auto_withoutparam/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif1": "non"} +{"creole.general.mode_conteneur_actif": null, "creole.general.mode_conteneur_actif1": "non"} diff --git a/tests/flattener_dicos/01auto_withoutparam/result/00-base.xml b/tests/flattener_dicos/01auto_withoutparam/result/00-base.xml index 7fa50bee..441dc24b 100644 --- a/tests/flattener_dicos/01auto_withoutparam/result/00-base.xml +++ b/tests/flattener_dicos/01auto_withoutparam/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -23,4 +23,4 @@ - + diff --git a/tests/flattener_dicos/01base_multi/makedict/base.json b/tests/flattener_dicos/01base_multi/makedict/base.json new file mode 100644 index 00000000..f4597dea --- /dev/null +++ b/tests/flattener_dicos/01base_multi/makedict/base.json @@ -0,0 +1 @@ +{"creole.general.mode_conteneur_actif": ["non"]} diff --git a/tests/flattener_dicos/01base_multi/result/00-base.xml b/tests/flattener_dicos/01base_multi/result/00-base.xml index d8cc6916..aa8240e0 100644 --- a/tests/flattener_dicos/01base_multi/result/00-base.xml +++ b/tests/flattener_dicos/01base_multi/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -16,4 +16,4 @@ - + diff --git a/tests/flattener_dicos/01base_submulti/makedict/base.json b/tests/flattener_dicos/01base_submulti/makedict/base.json new file mode 100644 index 00000000..179a0b61 --- /dev/null +++ b/tests/flattener_dicos/01base_submulti/makedict/base.json @@ -0,0 +1 @@ +{"creole.general.mode_conteneur_actif": [["non"]]} diff --git a/tests/flattener_dicos/01base_submulti/result/00-base.xml b/tests/flattener_dicos/01base_submulti/result/00-base.xml index 87e8da22..e0085fb3 100644 --- a/tests/flattener_dicos/01base_submulti/result/00-base.xml +++ b/tests/flattener_dicos/01base_submulti/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -16,4 +16,4 @@ - + diff --git a/tests/flattener_dicos/01fill_autofreeze/result/00-base.xml b/tests/flattener_dicos/01fill_autofreeze/result/00-base.xml index 7b53c763..7af4a94e 100644 --- a/tests/flattener_dicos/01fill_autofreeze/result/00-base.xml +++ b/tests/flattener_dicos/01fill_autofreeze/result/00-base.xml @@ -1,5 +1,5 @@ - + basic @@ -32,4 +32,4 @@ - + diff --git a/tests/flattener_dicos/01fill_autosave/result/00-base.xml b/tests/flattener_dicos/01fill_autosave/result/00-base.xml index a55ea99b..79cae590 100644 --- a/tests/flattener_dicos/01fill_autosave/result/00-base.xml +++ b/tests/flattener_dicos/01fill_autosave/result/00-base.xml @@ -1,5 +1,5 @@ - + basic @@ -23,4 +23,4 @@ - + diff --git a/tests/flattener_dicos/01fill_base/makedict/base.json b/tests/flattener_dicos/01fill_base/makedict/base.json index 8f8f47c6..530abf24 100644 --- a/tests/flattener_dicos/01fill_base/makedict/base.json +++ b/tests/flattener_dicos/01fill_base/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif1": "non"} +{"creole.general.mode_conteneur_actif": null, "creole.general.mode_conteneur_actif1": "non"} diff --git a/tests/flattener_dicos/01fill_base/result/00-base.xml b/tests/flattener_dicos/01fill_base/result/00-base.xml index e76c5ccd..5ff153fb 100644 --- a/tests/flattener_dicos/01fill_base/result/00-base.xml +++ b/tests/flattener_dicos/01fill_base/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -25,4 +25,4 @@ - + diff --git a/tests/flattener_dicos/01fill_baseaccent/makedict/base.json b/tests/flattener_dicos/01fill_baseaccent/makedict/base.json index 8f8f47c6..530abf24 100644 --- a/tests/flattener_dicos/01fill_baseaccent/makedict/base.json +++ b/tests/flattener_dicos/01fill_baseaccent/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif1": "non"} +{"creole.general.mode_conteneur_actif": null, "creole.general.mode_conteneur_actif1": "non"} diff --git a/tests/flattener_dicos/01fill_baseaccent/result/00-base.xml b/tests/flattener_dicos/01fill_baseaccent/result/00-base.xml index b9bb3da1..ef70b6a8 100644 --- a/tests/flattener_dicos/01fill_baseaccent/result/00-base.xml +++ b/tests/flattener_dicos/01fill_baseaccent/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -25,4 +25,4 @@ - + diff --git a/tests/flattener_dicos/01fill_mandatory/result/00-base.xml b/tests/flattener_dicos/01fill_mandatory/result/00-base.xml index 5d713d37..57be5d28 100644 --- a/tests/flattener_dicos/01fill_mandatory/result/00-base.xml +++ b/tests/flattener_dicos/01fill_mandatory/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -20,4 +20,4 @@ - + diff --git a/tests/flattener_dicos/01fill_number/makedict/base.json b/tests/flattener_dicos/01fill_number/makedict/base.json index 8f8f47c6..530abf24 100644 --- a/tests/flattener_dicos/01fill_number/makedict/base.json +++ b/tests/flattener_dicos/01fill_number/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif1": "non"} +{"creole.general.mode_conteneur_actif": null, "creole.general.mode_conteneur_actif1": "non"} diff --git a/tests/flattener_dicos/01fill_number/result/00-base.xml b/tests/flattener_dicos/01fill_number/result/00-base.xml index c3cc42a5..2a3c6c80 100644 --- a/tests/flattener_dicos/01fill_number/result/00-base.xml +++ b/tests/flattener_dicos/01fill_number/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -22,4 +22,4 @@ - + diff --git a/tests/flattener_dicos/01fill_optional/makedict/base.json b/tests/flattener_dicos/01fill_optional/makedict/base.json index 8f8f47c6..530abf24 100644 --- a/tests/flattener_dicos/01fill_optional/makedict/base.json +++ b/tests/flattener_dicos/01fill_optional/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif1": "non"} +{"creole.general.mode_conteneur_actif": null, "creole.general.mode_conteneur_actif1": "non"} diff --git a/tests/flattener_dicos/01fill_optional/result/00-base.xml b/tests/flattener_dicos/01fill_optional/result/00-base.xml index e76c5ccd..5ff153fb 100644 --- a/tests/flattener_dicos/01fill_optional/result/00-base.xml +++ b/tests/flattener_dicos/01fill_optional/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -25,4 +25,4 @@ - + diff --git a/tests/flattener_dicos/01separator_base/makedict/base.json b/tests/flattener_dicos/01separator_base/makedict/base.json new file mode 100644 index 00000000..f06f2ed8 --- /dev/null +++ b/tests/flattener_dicos/01separator_base/makedict/base.json @@ -0,0 +1 @@ +{"creole.general.mode_conteneur_actif": "non"} diff --git a/tests/flattener_dicos/01separator_base/result/00-base.xml b/tests/flattener_dicos/01separator_base/result/00-base.xml index d5863e5e..026c68d4 100644 --- a/tests/flattener_dicos/01separator_base/result/00-base.xml +++ b/tests/flattener_dicos/01separator_base/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -18,4 +18,4 @@ Établissement - + diff --git a/tests/flattener_dicos/01separator_neverhidden/makedict/base.json b/tests/flattener_dicos/01separator_neverhidden/makedict/base.json new file mode 100644 index 00000000..f06f2ed8 --- /dev/null +++ b/tests/flattener_dicos/01separator_neverhidden/makedict/base.json @@ -0,0 +1 @@ +{"creole.general.mode_conteneur_actif": "non"} diff --git a/tests/flattener_dicos/01separator_neverhidden/result/00-base.xml b/tests/flattener_dicos/01separator_neverhidden/result/00-base.xml index eb290e2e..46dede28 100644 --- a/tests/flattener_dicos/01separator_neverhidden/result/00-base.xml +++ b/tests/flattener_dicos/01separator_neverhidden/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -18,4 +18,4 @@ Établissement - + diff --git a/tests/flattener_dicos/10autosave_hidden/makedict/base.json b/tests/flattener_dicos/10autosave_hidden/makedict/base.json new file mode 100644 index 00000000..359ba452 --- /dev/null +++ b/tests/flattener_dicos/10autosave_hidden/makedict/base.json @@ -0,0 +1 @@ +{"creole.general.mode_conteneur_actif": "non", "creole.general.autosavevar": null} diff --git a/tests/flattener_dicos/10autosave_hidden/result/00-base.xml b/tests/flattener_dicos/10autosave_hidden/result/00-base.xml index 1e686273..2a31fb2e 100644 --- a/tests/flattener_dicos/10autosave_hidden/result/00-base.xml +++ b/tests/flattener_dicos/10autosave_hidden/result/00-base.xml @@ -1,5 +1,5 @@ - + basic @@ -25,4 +25,4 @@ - + diff --git a/tests/flattener_dicos/10autosave_hidden_frozenifin/makedict/base.json b/tests/flattener_dicos/10autosave_hidden_frozenifin/makedict/base.json index fb8fd49f..359ba452 100644 --- a/tests/flattener_dicos/10autosave_hidden_frozenifin/makedict/base.json +++ b/tests/flattener_dicos/10autosave_hidden_frozenifin/makedict/base.json @@ -1 +1 @@ -{"creole.general.autosavevar": null} +{"creole.general.mode_conteneur_actif": "non", "creole.general.autosavevar": null} diff --git a/tests/flattener_dicos/10autosave_hidden_frozenifin/result/00-base.xml b/tests/flattener_dicos/10autosave_hidden_frozenifin/result/00-base.xml index 7a9264be..e00e9035 100644 --- a/tests/flattener_dicos/10autosave_hidden_frozenifin/result/00-base.xml +++ b/tests/flattener_dicos/10autosave_hidden_frozenifin/result/00-base.xml @@ -1,5 +1,5 @@ - + basic @@ -26,4 +26,4 @@ - + diff --git a/tests/flattener_dicos/10check_base/result/00-base.xml b/tests/flattener_dicos/10check_base/result/00-base.xml index e2e286c9..908f8585 100644 --- a/tests/flattener_dicos/10check_base/result/00-base.xml +++ b/tests/flattener_dicos/10check_base/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -18,4 +18,4 @@ - + diff --git a/tests/flattener_dicos/10check_option/result/00-base.xml b/tests/flattener_dicos/10check_option/result/00-base.xml index ab96be9f..967c5ecf 100644 --- a/tests/flattener_dicos/10check_option/result/00-base.xml +++ b/tests/flattener_dicos/10check_option/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -23,4 +23,4 @@ - + diff --git a/tests/flattener_dicos/10check_optional/result/00-base.xml b/tests/flattener_dicos/10check_optional/result/00-base.xml index 88b10e62..9cc336e6 100644 --- a/tests/flattener_dicos/10check_optional/result/00-base.xml +++ b/tests/flattener_dicos/10check_optional/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -21,4 +21,4 @@ - + diff --git a/tests/flattener_dicos/10check_valid_differ/result/00-base.xml b/tests/flattener_dicos/10check_valid_differ/result/00-base.xml index 0d40273b..9b36f786 100644 --- a/tests/flattener_dicos/10check_valid_differ/result/00-base.xml +++ b/tests/flattener_dicos/10check_valid_differ/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -23,4 +23,4 @@ - + diff --git a/tests/flattener_dicos/10check_valid_differ_add/result/00-base.xml b/tests/flattener_dicos/10check_valid_differ_add/result/00-base.xml index fc596149..49875577 100644 --- a/tests/flattener_dicos/10check_valid_differ_add/result/00-base.xml +++ b/tests/flattener_dicos/10check_valid_differ_add/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -44,4 +44,4 @@ - + diff --git a/tests/flattener_dicos/10check_valid_differ_removecheck/result/00-base.xml b/tests/flattener_dicos/10check_valid_differ_removecheck/result/00-base.xml index d3646abd..a6cee741 100644 --- a/tests/flattener_dicos/10check_valid_differ_removecheck/result/00-base.xml +++ b/tests/flattener_dicos/10check_valid_differ_removecheck/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -38,4 +38,4 @@ - + diff --git a/tests/flattener_dicos/10check_valid_ipnetmask/result/00-base.xml b/tests/flattener_dicos/10check_valid_ipnetmask/result/00-base.xml index 73b07ef5..5bbc5953 100644 --- a/tests/flattener_dicos/10check_valid_ipnetmask/result/00-base.xml +++ b/tests/flattener_dicos/10check_valid_ipnetmask/result/00-base.xml @@ -1,5 +1,5 @@ - + basic @@ -24,4 +24,4 @@ - + diff --git a/tests/flattener_dicos/10leadership_append/result/00-base.xml b/tests/flattener_dicos/10leadership_append/result/00-base.xml index 4b8d1024..b3d76d32 100644 --- a/tests/flattener_dicos/10leadership_append/result/00-base.xml +++ b/tests/flattener_dicos/10leadership_append/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -34,4 +34,4 @@ - + diff --git a/tests/flattener_dicos/10leadership_auto/00-base.xml b/tests/flattener_dicos/10leadership_auto/00-base.xml index 7d9f1ca2..fd7d172c 100644 --- a/tests/flattener_dicos/10leadership_auto/00-base.xml +++ b/tests/flattener_dicos/10leadership_auto/00-base.xml @@ -9,22 +9,22 @@ non - - - + - + diff --git a/tests/flattener_dicos/10leadership_autoleader/00-base.xml b/tests/flattener_dicos/10leadership_autoleader/00-base.xml index d24509d3..5bf26bcd 100644 --- a/tests/flattener_dicos/10leadership_autoleader/00-base.xml +++ b/tests/flattener_dicos/10leadership_autoleader/00-base.xml @@ -9,18 +9,18 @@ non - - + - + diff --git a/tests/flattener_dicos/10leadership_autoleader_expert/00-base.xml b/tests/flattener_dicos/10leadership_autoleader_expert/00-base.xml index 76e712e8..b644d2c7 100644 --- a/tests/flattener_dicos/10leadership_autoleader_expert/00-base.xml +++ b/tests/flattener_dicos/10leadership_autoleader_expert/00-base.xml @@ -10,16 +10,16 @@ - + - + valfill - + follower1 follower2 diff --git a/tests/flattener_dicos/10leadership_autoleader_expert/makedict/base.json b/tests/flattener_dicos/10leadership_autoleader_expert/makedict/base.json index f06f2ed8..631fdc62 100644 --- a/tests/flattener_dicos/10leadership_autoleader_expert/makedict/base.json +++ b/tests/flattener_dicos/10leadership_autoleader_expert/makedict/base.json @@ -1 +1 @@ -{"creole.general.mode_conteneur_actif": "non"} +{"creole.general.mode_conteneur_actif": "non", "creole.leadermode.leader.leader": [], "creole.leadermode.leader.follower1": [], "creole.leadermode.leader.follower2": []} diff --git a/tests/flattener_dicos/10leadership_autoleader_expert/result/00-base.xml b/tests/flattener_dicos/10leadership_autoleader_expert/result/00-base.xml index 37131b3e..7c74227c 100644 --- a/tests/flattener_dicos/10leadership_autoleader_expert/result/00-base.xml +++ b/tests/flattener_dicos/10leadership_autoleader_expert/result/00-base.xml @@ -1,5 +1,5 @@ - + expert @@ -19,17 +19,21 @@ force_default_on_freeze frozen - + valfill + force_default_on_freeze + frozen expert + force_default_on_freeze + frozen expert - + diff --git a/tests/flattener_dicos/10leadership_autosaveexpert/result/00-base.xml b/tests/flattener_dicos/10leadership_autosaveexpert/result/00-base.xml index 00318561..1a921c2a 100644 --- a/tests/flattener_dicos/10leadership_autosaveexpert/result/00-base.xml +++ b/tests/flattener_dicos/10leadership_autosaveexpert/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -28,4 +28,4 @@ - + diff --git a/tests/flattener_dicos/10leadership_familyaccent/result/00-base.xml b/tests/flattener_dicos/10leadership_familyaccent/result/00-base.xml index 47482572..c1bf10b1 100644 --- a/tests/flattener_dicos/10leadership_familyaccent/result/00-base.xml +++ b/tests/flattener_dicos/10leadership_familyaccent/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -28,4 +28,4 @@ - + diff --git a/tests/flattener_dicos/10leadership_leadermandatory/result/00-base.xml b/tests/flattener_dicos/10leadership_leadermandatory/result/00-base.xml index ba4245dc..9c49bf25 100644 --- a/tests/flattener_dicos/10leadership_leadermandatory/result/00-base.xml +++ b/tests/flattener_dicos/10leadership_leadermandatory/result/00-base.xml @@ -1,5 +1,5 @@ - + basic @@ -30,4 +30,4 @@ - + diff --git a/tests/flattener_dicos/10leadership_mandatory/result/00-base.xml b/tests/flattener_dicos/10leadership_mandatory/result/00-base.xml index 66455866..71215bec 100644 --- a/tests/flattener_dicos/10leadership_mandatory/result/00-base.xml +++ b/tests/flattener_dicos/10leadership_mandatory/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -29,4 +29,4 @@ - + diff --git a/tests/flattener_dicos/10leadership_mandatoryfollower/makedict/base.json b/tests/flattener_dicos/10leadership_mandatoryfollower/makedict/base.json index 81e39999..4ff9e4c6 100644 --- a/tests/flattener_dicos/10leadership_mandatoryfollower/makedict/base.json +++ b/tests/flattener_dicos/10leadership_mandatoryfollower/makedict/base.json @@ -1 +1 @@ -{"creole.general.nut_monitor_netmask.nut_monitor_netmask": [], "creole.general.nut_monitor_netmask.nut_monitor_host": []} +{"creole.general.mode_conteneur_actif": "oui", "creole.general.nut_monitor_netmask.nut_monitor_netmask": [], "creole.general.nut_monitor_netmask.nut_monitor_host": []} diff --git a/tests/flattener_dicos/10leadership_mandatoryfollower/result/00-base.xml b/tests/flattener_dicos/10leadership_mandatoryfollower/result/00-base.xml index 959fddf5..871c120e 100644 --- a/tests/flattener_dicos/10leadership_mandatoryfollower/result/00-base.xml +++ b/tests/flattener_dicos/10leadership_mandatoryfollower/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -24,4 +24,4 @@ - + diff --git a/tests/flattener_dicos/10leadership_multi/result/00-base.xml b/tests/flattener_dicos/10leadership_multi/result/00-base.xml index a2525bef..aaec8c90 100644 --- a/tests/flattener_dicos/10leadership_multi/result/00-base.xml +++ b/tests/flattener_dicos/10leadership_multi/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -41,4 +41,4 @@ - + diff --git a/tests/flattener_dicos/10load_disabled_if_in/result/00-base.xml b/tests/flattener_dicos/10load_disabled_if_in/result/00-base.xml index f92fed81..50c7e8e3 100644 --- a/tests/flattener_dicos/10load_disabled_if_in/result/00-base.xml +++ b/tests/flattener_dicos/10load_disabled_if_in/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -13,6 +13,9 @@ oui non + force_default_on_freeze + frozen + hidden mandatory normal disabled @@ -21,6 +24,9 @@ oui non + force_default_on_freeze + frozen + hidden mandatory normal disabled @@ -29,4 +35,4 @@ - + diff --git a/tests/flattener_dicos/10load_disabled_if_in_none/result/00-base.xml b/tests/flattener_dicos/10load_disabled_if_in_none/result/00-base.xml index 0e104d25..8b34ce92 100644 --- a/tests/flattener_dicos/10load_disabled_if_in_none/result/00-base.xml +++ b/tests/flattener_dicos/10load_disabled_if_in_none/result/00-base.xml @@ -1,5 +1,5 @@ - + normal @@ -11,6 +11,9 @@ oui non + force_default_on_freeze + frozen + hidden mandatory normal disabled @@ -19,6 +22,9 @@ oui non + force_default_on_freeze + frozen + hidden mandatory normal disabled @@ -27,4 +33,4 @@ - + diff --git a/tests/flattener_dicos/10load_disabled_if_inaccent/00-base.xml b/tests/flattener_dicos/10load_disabled_if_inaccent/00-base.xml index 2d51e599..d185fc60 100644 --- a/tests/flattener_dicos/10load_disabled_if_inaccent/00-base.xml +++ b/tests/flattener_dicos/10load_disabled_if_inaccent/00-base.xml @@ -8,10 +8,10 @@ non - diff --git a/tests/flattener_dicos/51redefine_remove_check/tiramisu/__init__.py b/tests/flattener_dicos/51redefine_remove_check/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/51redefine_remove_check/tiramisu/base.py b/tests/flattener_dicos/51redefine_remove_check/tiramisu/base.py new file mode 100644 index 00000000..1a758e48 --- /dev/null +++ b/tests/flattener_dicos/51redefine_remove_check/tiramisu/base.py @@ -0,0 +1,8 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = StrOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='non') +option_2 = OptionDescription(doc='general', name='general', properties=frozenset(['normal']), children=[option_3]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1]) diff --git a/tests/flattener_dicos/51redefine_remove_condition/__init__.py b/tests/flattener_dicos/51redefine_remove_condition/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/51redefine_remove_condition/tiramisu/__init__.py b/tests/flattener_dicos/51redefine_remove_condition/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/51redefine_remove_condition/tiramisu/base.py b/tests/flattener_dicos/51redefine_remove_condition/tiramisu/base.py new file mode 100644 index 00000000..2cdea98d --- /dev/null +++ b/tests/flattener_dicos/51redefine_remove_condition/tiramisu/base.py @@ -0,0 +1,11 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non')) +option_4 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='condition', default='non', values=('oui', 'non')) +option_5 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif1', default='non', values=('oui', 'non')) +option_6 = ChoiceOption(properties=frozenset(['mandatory', 'normal', Calculation(calc_value, Params(ParamValue('disabled'), kwargs={'condition': ParamOption(option_4, todict=True), 'expected': ParamValue('oui')}))]), doc='No change', multi=False, name='mode_conteneur_actif2', default='non', values=('oui', 'non')) +option_2 = OptionDescription(doc='general', name='general', properties=frozenset(['normal']), children=[option_3, option_4, option_5, option_6]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1]) diff --git a/tests/flattener_dicos/51redefine_removecondition_alltarget/__init__.py b/tests/flattener_dicos/51redefine_removecondition_alltarget/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/51redefine_removecondition_alltarget/tiramisu/__init__.py b/tests/flattener_dicos/51redefine_removecondition_alltarget/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/51redefine_removecondition_alltarget/tiramisu/base.py b/tests/flattener_dicos/51redefine_removecondition_alltarget/tiramisu/base.py new file mode 100644 index 00000000..76b864c7 --- /dev/null +++ b/tests/flattener_dicos/51redefine_removecondition_alltarget/tiramisu/base.py @@ -0,0 +1,11 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non')) +option_4 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='condition', default='non', values=('oui', 'non')) +option_5 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif1', default='non', values=('oui', 'non')) +option_6 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif2', default='non', values=('oui', 'non')) +option_2 = OptionDescription(doc='general', name='general', properties=frozenset(['normal']), children=[option_3, option_4, option_5, option_6]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1]) diff --git a/tests/flattener_dicos/51redefine_removecondition_nonautofreeze/__init__.py b/tests/flattener_dicos/51redefine_removecondition_nonautofreeze/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/51redefine_removecondition_nonautofreeze/tiramisu/__init__.py b/tests/flattener_dicos/51redefine_removecondition_nonautofreeze/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/51redefine_removecondition_nonautofreeze/tiramisu/base.py b/tests/flattener_dicos/51redefine_removecondition_nonautofreeze/tiramisu/base.py new file mode 100644 index 00000000..b319b2c5 --- /dev/null +++ b/tests/flattener_dicos/51redefine_removecondition_nonautofreeze/tiramisu/base.py @@ -0,0 +1,12 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_7 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='module_instancie', default='non', values=('oui', 'non')) +option_3 = ChoiceOption(properties=frozenset(['force_store_value', 'auto_freeze', 'mandatory', 'basic', Calculation(calc_value, Params(ParamValue('auto_frozen'), kwargs={'condition': ParamOption(option_7, todict=True), 'expected': ParamValue('oui'), 'reverse_condition': ParamValue(True)}))]), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non')) +option_4 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='condition', default='non', values=('oui', 'non')) +option_5 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif1', default='non', values=('oui', 'non')) +option_6 = ChoiceOption(properties=frozenset(['mandatory', 'normal', Calculation(calc_value, Params(ParamValue('disabled'), kwargs={'condition': ParamOption(option_4, todict=True), 'expected': ParamValue('oui')}))]), doc='No change', multi=False, name='mode_conteneur_actif2', default='non', values=('oui', 'non')) +option_2 = OptionDescription(doc='general', name='general', properties=frozenset(['basic']), children=[option_3, option_4, option_5, option_6, option_7]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1]) diff --git a/tests/flattener_dicos/51redefine_type/__init__.py b/tests/flattener_dicos/51redefine_type/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/51redefine_validenum/__init__.py b/tests/flattener_dicos/51redefine_validenum/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/51redefine_validenum/tiramisu/__init__.py b/tests/flattener_dicos/51redefine_validenum/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/51redefine_validenum/tiramisu/base.py b/tests/flattener_dicos/51redefine_validenum/tiramisu/base.py new file mode 100644 index 00000000..4865cd1f --- /dev/null +++ b/tests/flattener_dicos/51redefine_validenum/tiramisu/base.py @@ -0,0 +1,8 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='Redefine description', multi=False, name='mode_conteneur_actif', default='a', values=('a', 'b')) +option_2 = OptionDescription(doc='general', name='general', properties=frozenset(['normal']), children=[option_3]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1]) diff --git a/tests/flattener_dicos/51redefine_value/__init__.py b/tests/flattener_dicos/51redefine_value/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/51redefine_value/tiramisu/__init__.py b/tests/flattener_dicos/51redefine_value/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/51redefine_value/tiramisu/base.py b/tests/flattener_dicos/51redefine_value/tiramisu/base.py new file mode 100644 index 00000000..2d49c670 --- /dev/null +++ b/tests/flattener_dicos/51redefine_value/tiramisu/base.py @@ -0,0 +1,9 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='Redefine value', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non')) +option_4 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='Redefine value', multi=False, name='mode_conteneur_actif1', default='oui', values=('oui', 'non')) +option_2 = OptionDescription(doc='general', name='general', properties=frozenset(['normal']), children=[option_3, option_4]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1]) diff --git a/tests/flattener_dicos/52exists_redefine/__init__.py b/tests/flattener_dicos/52exists_redefine/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/52exists_redefine/tiramisu/__init__.py b/tests/flattener_dicos/52exists_redefine/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/52exists_redefine/tiramisu/base.py b/tests/flattener_dicos/52exists_redefine/tiramisu/base.py new file mode 100644 index 00000000..841c2d99 --- /dev/null +++ b/tests/flattener_dicos/52exists_redefine/tiramisu/base.py @@ -0,0 +1,8 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='New description', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non')) +option_2 = OptionDescription(doc='general', name='general', properties=frozenset(['normal']), children=[option_3]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1]) diff --git a/tests/flattener_dicos/60action_external/__init__.py b/tests/flattener_dicos/60action_external/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60action_external/result/00-base.xml b/tests/flattener_dicos/60action_external/result/00-base.xml index f4b7b9c7..191f3291 100644 --- a/tests/flattener_dicos/60action_external/result/00-base.xml +++ b/tests/flattener_dicos/60action_external/result/00-base.xml @@ -21,7 +21,7 @@ mandatory normal - 0 + 0 force_default_on_freeze @@ -30,7 +30,7 @@ mandatory normal - http://localhost/ + http://localhost/ diff --git a/tests/flattener_dicos/60action_external/tiramisu/__init__.py b/tests/flattener_dicos/60action_external/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60action_external/tiramisu/base.py b/tests/flattener_dicos/60action_external/tiramisu/base.py new file mode 100644 index 00000000..5b2eae6e --- /dev/null +++ b/tests/flattener_dicos/60action_external/tiramisu/base.py @@ -0,0 +1,12 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non')) +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_6 = IntOption(properties=frozenset(['mandatory', 'normal']), doc='délai en minutes avant lancement', multi=False, name='delay', default=0) +option_7 = URLOption(allow_ip=True, allow_without_dot=True, properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='domain', multi=False, name='calc_url', default=Calculation(func.calc_val, Params((ParamValue("http://localhost/")), kwargs={}))) +option_5 = OptionDescription(doc='test', name='test', properties=frozenset(['normal']), children=[option_6, option_7]) +option_4 = OptionDescription(doc='extra', name='extra', children=[option_5]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_4]) diff --git a/tests/flattener_dicos/60extra_externalspace/__init__.py b/tests/flattener_dicos/60extra_externalspace/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60extra_externalspaceauto/__init__.py b/tests/flattener_dicos/60extra_externalspaceauto/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60extra_externalspacecondition/__init__.py b/tests/flattener_dicos/60extra_externalspacecondition/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60extra_externalspacecondition/result/00-base.xml b/tests/flattener_dicos/60extra_externalspacecondition/result/00-base.xml index 5ff2d623..4d298973 100644 --- a/tests/flattener_dicos/60extra_externalspacecondition/result/00-base.xml +++ b/tests/flattener_dicos/60extra_externalspacecondition/result/00-base.xml @@ -41,7 +41,7 @@ mandatory normal - Exportation de la base de ejabberd + Exportation de la base de ejabberd none @@ -68,7 +68,7 @@ mandatory normal - test + test diff --git a/tests/flattener_dicos/60extra_externalspacecondition/tiramisu/__init__.py b/tests/flattener_dicos/60extra_externalspacecondition/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60extra_externalspacecondition/tiramisu/base.py b/tests/flattener_dicos/60extra_externalspacecondition/tiramisu/base.py new file mode 100644 index 00000000..7631921d --- /dev/null +++ b/tests/flattener_dicos/60extra_externalspacecondition/tiramisu/base.py @@ -0,0 +1,18 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_5 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='module_instancie', default='non', values=('oui', 'non')) +option_3 = ChoiceOption(properties=frozenset(['force_store_value', 'auto_freeze', 'mandatory', 'basic', Calculation(calc_value, Params(ParamValue('auto_frozen'), kwargs={'condition': ParamOption(option_5, todict=True), 'expected': ParamValue('oui'), 'reverse_condition': ParamValue(True)}))]), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non')) +option_4 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='activer_ejabberd', default='non', values=('oui', 'non')) +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['basic']), children=[option_3, option_4, option_5]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_8 = StrOption(properties=frozenset(['mandatory', 'normal']), doc='description', multi=False, name='description', default='Exportation de la base de ejabberd') +option_9 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='day', multi=False, name='day', default='none', values=('none', 'daily', 'weekly', 'monthly')) +option_10 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='mode', multi=False, name='mode', default='pre', values=('pre', 'post')) +option_7 = OptionDescription(doc='ejabberd', name='ejabberd', properties=frozenset(['normal']), children=[option_8, option_9, option_10]) +option_6 = OptionDescription(doc='extra', name='extra', children=[option_7]) +option_13 = StrOption(properties=frozenset(['mandatory', 'normal']), doc='description', multi=False, name='description', default='test') +option_12 = OptionDescription(doc='external', name='external', properties=frozenset(['normal', Calculation(calc_value, Params(ParamValue('disabled'), kwargs={'condition': ParamOption(option_8, todict=True), 'expected': ParamValue('non')}))]), children=[option_13]) +option_11 = OptionDescription(doc='extra1', name='extra1', children=[option_12]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_6, option_11]) diff --git a/tests/flattener_dicos/60extra_externalspacecondition2/__init__.py b/tests/flattener_dicos/60extra_externalspacecondition2/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60extra_externalspacecondition3/__init__.py b/tests/flattener_dicos/60extra_externalspacecondition3/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60extra_group/__init__.py b/tests/flattener_dicos/60extra_group/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60extra_group/result/00-base.xml b/tests/flattener_dicos/60extra_group/result/00-base.xml index 2d645b1d..063d244e 100644 --- a/tests/flattener_dicos/60extra_group/result/00-base.xml +++ b/tests/flattener_dicos/60extra_group/result/00-base.xml @@ -6,25 +6,25 @@ - root + root - 0644 + 0644 - /etc/mailname + /etc/mailname - root + root - mailname + mailname - True + True - True + True @@ -62,12 +62,12 @@ normal mandatory - test + test mandatory normal - pre + pre diff --git a/tests/flattener_dicos/60extra_group/tiramisu/__init__.py b/tests/flattener_dicos/60extra_group/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60extra_group/tiramisu/base.py b/tests/flattener_dicos/60extra_group/tiramisu/base.py new file mode 100644 index 00000000..096d2a0a --- /dev/null +++ b/tests/flattener_dicos/60extra_group/tiramisu/base.py @@ -0,0 +1,25 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non')) +option_4 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='activer_ejabberd', default='non', values=('oui', 'non')) +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3, option_4]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_9 = StrOption(properties=frozenset([]), doc='group', multi=False, name='group', default='root') +option_10 = StrOption(properties=frozenset([]), doc='mode', multi=False, name='mode', default='0644') +option_11 = StrOption(properties=frozenset([]), doc='name', multi=False, name='name', default='/etc/mailname') +option_12 = StrOption(properties=frozenset([]), doc='owner', multi=False, name='owner', default='root') +option_13 = StrOption(properties=frozenset([]), doc='source', multi=False, name='source', default='mailname') +option_14 = BoolOption(default=True, properties=frozenset([]), doc='templating', multi=False, name='templating') +option_15 = BoolOption(default=True, properties=frozenset([]), doc='activate', multi=False, name='activate') +option_8 = OptionDescription(doc='mailname', name='mailname', children=[option_9, option_10, option_11, option_12, option_13, option_14, option_15]) +option_7 = OptionDescription(name='files', doc='files', children=[option_8]) +option_6 = OptionDescription(doc='test', name='test', children=[option_7]) +option_5 = OptionDescription(name='services', doc='services', properties=frozenset(['hidden']), children=[option_6]) +option_19 = StrOption(properties=frozenset(['mandatory']), doc='description', multi=True, name='description', default=['test']) +option_20 = StrOption(properties=frozenset(['mandatory', 'normal']), doc='mode', multi=True, name='mode', default_multi='pre') +option_18 = Leadership(doc='description', name='description', properties=frozenset(['normal']), children=[option_19, option_20]) +option_17 = OptionDescription(doc='ejabberd', name='ejabberd', properties=frozenset(['normal']), children=[option_18]) +option_16 = OptionDescription(doc='extra', name='extra', children=[option_17]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_5, option_16]) diff --git a/tests/flattener_dicos/60extra_help/60extra/00-base.xml b/tests/flattener_dicos/60extra_help/60extra/00-base.xml deleted file mode 100644 index 91f8117c..00000000 --- a/tests/flattener_dicos/60extra_help/60extra/00-base.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - False - - - /etc/mailname - - - False - - - mailname - - - True - - - - basic - - - - - normal - - oui - non - force_default_on_freeze - frozen - hidden - mandatory - normal - non - - - oui - non - force_default_on_freeze - frozen - hidden - mandatory - normal - non - - - - - - - normal - - mandatory - normal - Exportation de la base de ejabberd - - - none - daily - weekly - monthly - mandatory - normal - - non - creole.general.activer_ejabberd - none - daily - - - - pre - post - mandatory - normal - pre - - - - diff --git a/tests/flattener_dicos/60extra_help/60extra/result/test/etc/mailname b/tests/flattener_dicos/60extra_help/60extra/result/test/etc/mailname deleted file mode 100644 index 174cc656..00000000 --- a/tests/flattener_dicos/60extra_help/60extra/result/test/etc/mailname +++ /dev/null @@ -1 +0,0 @@ -Exportation de la base de ejabberd diff --git a/tests/flattener_dicos/60extra_help/60extra/tmpl/mailname b/tests/flattener_dicos/60extra_help/60extra/tmpl/mailname deleted file mode 100644 index cd745cac..00000000 --- a/tests/flattener_dicos/60extra_help/60extra/tmpl/mailname +++ /dev/null @@ -1 +0,0 @@ -%%extra.ejabberd.description diff --git a/tests/flattener_dicos/60extra_help/__init__.py b/tests/flattener_dicos/60extra_help/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60extra_help/extra_dirs/extra/00-base.xml b/tests/flattener_dicos/60extra_help/extra_dirs/extra/00-base.xml index ab3d1cdd..15a5a566 100644 --- a/tests/flattener_dicos/60extra_help/extra_dirs/extra/00-base.xml +++ b/tests/flattener_dicos/60extra_help/extra_dirs/extra/00-base.xml @@ -15,7 +15,7 @@ non - activer_ejabberd + activer_ejabberd none daily diff --git a/tests/flattener_dicos/60extra_help/result/00-base.xml b/tests/flattener_dicos/60extra_help/result/00-base.xml index 2731f873..edb63e32 100644 --- a/tests/flattener_dicos/60extra_help/result/00-base.xml +++ b/tests/flattener_dicos/60extra_help/result/00-base.xml @@ -6,25 +6,25 @@ - root + root - 0644 + 0644 - /etc/mailname + /etc/mailname - root + root - mailname + mailname - True + True - True + True @@ -61,7 +61,7 @@ mandatory normal - Exportation de la base de ejabberd + Exportation de la base de ejabberd none @@ -71,10 +71,10 @@ mandatory normal - non - rougail.general.activer_ejabberd - none - daily + non + rougail.general.activer_ejabberd + none + daily diff --git a/tests/flattener_dicos/60extra_help/tiramisu/__init__.py b/tests/flattener_dicos/60extra_help/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60extra_help/tiramisu/base.py b/tests/flattener_dicos/60extra_help/tiramisu/base.py new file mode 100644 index 00000000..bc18cef5 --- /dev/null +++ b/tests/flattener_dicos/60extra_help/tiramisu/base.py @@ -0,0 +1,26 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non')) +option_4 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='activer_ejabberd', default='non', values=('oui', 'non')) +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3, option_4]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_9 = StrOption(properties=frozenset([]), doc='group', multi=False, name='group', default='root') +option_10 = StrOption(properties=frozenset([]), doc='mode', multi=False, name='mode', default='0644') +option_11 = StrOption(properties=frozenset([]), doc='name', multi=False, name='name', default='/etc/mailname') +option_12 = StrOption(properties=frozenset([]), doc='owner', multi=False, name='owner', default='root') +option_13 = StrOption(properties=frozenset([]), doc='source', multi=False, name='source', default='mailname') +option_14 = BoolOption(default=True, properties=frozenset([]), doc='templating', multi=False, name='templating') +option_15 = BoolOption(default=True, properties=frozenset([]), doc='activate', multi=False, name='activate') +option_8 = OptionDescription(doc='mailname', name='mailname', children=[option_9, option_10, option_11, option_12, option_13, option_14, option_15]) +option_7 = OptionDescription(name='files', doc='files', children=[option_8]) +option_6 = OptionDescription(doc='test', name='test', children=[option_7]) +option_5 = OptionDescription(name='services', doc='services', properties=frozenset(['hidden']), children=[option_6]) +option_18 = StrOption(properties=frozenset(['mandatory', 'normal']), doc='description', multi=False, name='description', default='Exportation de la base de ejabberd') +option_19 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='day', multi=False, name='day', default=Calculation(func.calc_multi_condition, Params((ParamValue("non")), kwargs={'condition_1': ParamOption(option_4, notraisepropertyerror=True, todict=False), 'match': ParamValue("none"), 'mismatch': ParamValue("daily")})), values=('none', 'daily', 'weekly', 'monthly')) +option_19.impl_set_information("help", "Test help") +option_20 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='mode', multi=False, name='mode', default='pre', values=('pre', 'post')) +option_17 = OptionDescription(doc='ejabberd', name='ejabberd', properties=frozenset(['normal']), children=[option_18, option_19, option_20]) +option_16 = OptionDescription(doc='extra', name='extra', children=[option_17]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_5, option_16]) diff --git a/tests/flattener_dicos/60extra_load/__init__.py b/tests/flattener_dicos/60extra_load/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60extra_load/extra_dirs/extra/00-base.xml b/tests/flattener_dicos/60extra_load/extra_dirs/extra/00-base.xml index 185ac9b8..651c2125 100644 --- a/tests/flattener_dicos/60extra_load/extra_dirs/extra/00-base.xml +++ b/tests/flattener_dicos/60extra_load/extra_dirs/extra/00-base.xml @@ -15,7 +15,7 @@ non - activer_ejabberd + activer_ejabberd none daily diff --git a/tests/flattener_dicos/60extra_load/result/00-base.xml b/tests/flattener_dicos/60extra_load/result/00-base.xml index 756c4421..bcd752ac 100644 --- a/tests/flattener_dicos/60extra_load/result/00-base.xml +++ b/tests/flattener_dicos/60extra_load/result/00-base.xml @@ -31,7 +31,7 @@ mandatory normal - Exportation de la base de ejabberd + Exportation de la base de ejabberd none @@ -41,10 +41,10 @@ mandatory normal - non - rougail.general.activer_ejabberd - none - daily + non + rougail.general.activer_ejabberd + none + daily diff --git a/tests/flattener_dicos/60extra_load/tiramisu/__init__.py b/tests/flattener_dicos/60extra_load/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60extra_load/tiramisu/base.py b/tests/flattener_dicos/60extra_load/tiramisu/base.py new file mode 100644 index 00000000..c8db5a96 --- /dev/null +++ b/tests/flattener_dicos/60extra_load/tiramisu/base.py @@ -0,0 +1,14 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non')) +option_4 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='activer_ejabberd', default='non', values=('oui', 'non')) +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3, option_4]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_7 = StrOption(properties=frozenset(['mandatory', 'normal']), doc='description', multi=False, name='description', default='Exportation de la base de ejabberd') +option_8 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='day', multi=False, name='day', default=Calculation(func.calc_multi_condition, Params((ParamValue("non")), kwargs={'condition_1': ParamOption(option_4, notraisepropertyerror=True, todict=False), 'match': ParamValue("none"), 'mismatch': ParamValue("daily")})), values=('none', 'daily', 'weekly', 'monthly')) +option_9 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='mode', multi=False, name='mode', default='pre', values=('pre', 'post')) +option_6 = OptionDescription(doc='ejabberd', name='ejabberd', properties=frozenset(['normal']), children=[option_7, option_8, option_9]) +option_5 = OptionDescription(doc='extra', name='extra', children=[option_6]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_5]) diff --git a/tests/flattener_dicos/60extra_mandatory/__init__.py b/tests/flattener_dicos/60extra_mandatory/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60extra_mandatory/extra_dirs/extra/00-base.xml b/tests/flattener_dicos/60extra_mandatory/extra_dirs/extra/00-base.xml index 9db3b32e..76cfb57b 100644 --- a/tests/flattener_dicos/60extra_mandatory/extra_dirs/extra/00-base.xml +++ b/tests/flattener_dicos/60extra_mandatory/extra_dirs/extra/00-base.xml @@ -14,7 +14,7 @@ non - activer_ejabberd + activer_ejabberd none daily diff --git a/tests/flattener_dicos/60extra_mandatory/result/00-base.xml b/tests/flattener_dicos/60extra_mandatory/result/00-base.xml index e886aa84..c40d8f38 100644 --- a/tests/flattener_dicos/60extra_mandatory/result/00-base.xml +++ b/tests/flattener_dicos/60extra_mandatory/result/00-base.xml @@ -31,7 +31,7 @@ mandatory normal - Exportation de la base de ejabberd + Exportation de la base de ejabberd none @@ -41,10 +41,10 @@ mandatory normal - non - rougail.general.activer_ejabberd - none - daily + non + rougail.general.activer_ejabberd + none + daily diff --git a/tests/flattener_dicos/60extra_mandatory/tiramisu/__init__.py b/tests/flattener_dicos/60extra_mandatory/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60extra_mandatory/tiramisu/base.py b/tests/flattener_dicos/60extra_mandatory/tiramisu/base.py new file mode 100644 index 00000000..38e30ff4 --- /dev/null +++ b/tests/flattener_dicos/60extra_mandatory/tiramisu/base.py @@ -0,0 +1,15 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non')) +option_4 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='activer_ejabberd', default='non', values=('oui', 'non')) +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3, option_4]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_7 = StrOption(properties=frozenset(['mandatory', 'normal']), doc='description', multi=False, name='description', default='Exportation de la base de ejabberd') +option_8 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='day', multi=False, name='day', default=Calculation(func.calc_multi_condition, Params((ParamValue("non")), kwargs={'condition_1': ParamOption(option_4, notraisepropertyerror=True, todict=False), 'match': ParamValue("none"), 'mismatch': ParamValue("daily")})), values=('none', 'daily', 'weekly', 'monthly')) +option_9 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='mode', multi=False, name='mode', default='pre', values=('pre', 'post')) +option_10 = StrOption(properties=frozenset(['mandatory', 'basic']), doc='var1', multi=False, name='var1') +option_6 = OptionDescription(doc='ejabberd', name='ejabberd', properties=frozenset(['basic']), children=[option_7, option_8, option_9, option_10]) +option_5 = OptionDescription(doc='extra', name='extra', children=[option_6]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_5]) diff --git a/tests/flattener_dicos/60extra_redefine/__init__.py b/tests/flattener_dicos/60extra_redefine/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60extra_redefine/extra_dirs/extra/00-base.xml b/tests/flattener_dicos/60extra_redefine/extra_dirs/extra/00-base.xml index 185ac9b8..651c2125 100644 --- a/tests/flattener_dicos/60extra_redefine/extra_dirs/extra/00-base.xml +++ b/tests/flattener_dicos/60extra_redefine/extra_dirs/extra/00-base.xml @@ -15,7 +15,7 @@ non - activer_ejabberd + activer_ejabberd none daily diff --git a/tests/flattener_dicos/60extra_redefine/result/00-base.xml b/tests/flattener_dicos/60extra_redefine/result/00-base.xml index 5e591783..937fc257 100644 --- a/tests/flattener_dicos/60extra_redefine/result/00-base.xml +++ b/tests/flattener_dicos/60extra_redefine/result/00-base.xml @@ -34,7 +34,7 @@ hidden mandatory normal - Exportation de la base de ejabberd + Exportation de la base de ejabberd none @@ -44,10 +44,10 @@ mandatory normal - non - rougail.general.activer_ejabberd - none - daily + non + rougail.general.activer_ejabberd + none + daily diff --git a/tests/flattener_dicos/60extra_redefine/tiramisu/__init__.py b/tests/flattener_dicos/60extra_redefine/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60extra_redefine/tiramisu/base.py b/tests/flattener_dicos/60extra_redefine/tiramisu/base.py new file mode 100644 index 00000000..b08a07d3 --- /dev/null +++ b/tests/flattener_dicos/60extra_redefine/tiramisu/base.py @@ -0,0 +1,14 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non')) +option_4 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='activer_ejabberd', default='non', values=('oui', 'non')) +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3, option_4]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_7 = StrOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='description', multi=False, name='description', default='Exportation de la base de ejabberd') +option_8 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='day', multi=False, name='day', default=Calculation(func.calc_multi_condition, Params((ParamValue("non")), kwargs={'condition_1': ParamOption(option_4, notraisepropertyerror=True, todict=False), 'match': ParamValue("none"), 'mismatch': ParamValue("daily")})), values=('none', 'daily', 'weekly', 'monthly')) +option_9 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='mode', multi=False, name='mode', default='pre', values=('pre', 'post')) +option_6 = OptionDescription(doc='ejabberd', name='ejabberd', properties=frozenset(['normal']), children=[option_7, option_8, option_9]) +option_5 = OptionDescription(doc='extra', name='extra', children=[option_6]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_5]) diff --git a/tests/flattener_dicos/60extra_separators/__init__.py b/tests/flattener_dicos/60extra_separators/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60extra_separators/extra_dirs/extra/00-base.xml b/tests/flattener_dicos/60extra_separators/extra_dirs/extra/00-base.xml index b6247865..f51f8a14 100644 --- a/tests/flattener_dicos/60extra_separators/extra_dirs/extra/00-base.xml +++ b/tests/flattener_dicos/60extra_separators/extra_dirs/extra/00-base.xml @@ -18,7 +18,7 @@ non - activer_ejabberd + activer_ejabberd none daily diff --git a/tests/flattener_dicos/60extra_separators/result/00-base.xml b/tests/flattener_dicos/60extra_separators/result/00-base.xml index 0147ea94..7a59f723 100644 --- a/tests/flattener_dicos/60extra_separators/result/00-base.xml +++ b/tests/flattener_dicos/60extra_separators/result/00-base.xml @@ -31,7 +31,7 @@ mandatory normal - Exportation de la base de ejabberd + Exportation de la base de ejabberd none @@ -41,10 +41,10 @@ mandatory normal - non - rougail.general.activer_ejabberd - none - daily + non + rougail.general.activer_ejabberd + none + daily diff --git a/tests/flattener_dicos/60extra_separators/tiramisu/__init__.py b/tests/flattener_dicos/60extra_separators/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60extra_separators/tiramisu/base.py b/tests/flattener_dicos/60extra_separators/tiramisu/base.py new file mode 100644 index 00000000..337cb092 --- /dev/null +++ b/tests/flattener_dicos/60extra_separators/tiramisu/base.py @@ -0,0 +1,15 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non')) +option_4 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='activer_ejabberd', default='non', values=('oui', 'non')) +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3, option_4]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_7 = StrOption(properties=frozenset(['mandatory', 'normal']), doc='description', multi=False, name='description', default='Exportation de la base de ejabberd') +option_8 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='day', multi=False, name='day', default=Calculation(func.calc_multi_condition, Params((ParamValue("non")), kwargs={'condition_1': ParamOption(option_4, notraisepropertyerror=True, todict=False), 'match': ParamValue("none"), 'mismatch': ParamValue("daily")})), values=('none', 'daily', 'weekly', 'monthly')) +option_8.impl_set_information("separator", "Séparateur") +option_9 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='mode', multi=False, name='mode', default='pre', values=('pre', 'post')) +option_6 = OptionDescription(doc='ejabberd', name='ejabberd', properties=frozenset(['normal']), children=[option_7, option_8, option_9]) +option_5 = OptionDescription(doc='extra', name='extra', children=[option_6]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_5]) diff --git a/tests/flattener_dicos/60familyaction/__init__.py b/tests/flattener_dicos/60familyaction/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60familyaction/result/00-base.xml b/tests/flattener_dicos/60familyaction/result/00-base.xml index 2136b58e..02f93e60 100644 --- a/tests/flattener_dicos/60familyaction/result/00-base.xml +++ b/tests/flattener_dicos/60familyaction/result/00-base.xml @@ -21,7 +21,7 @@ mandatory normal - 0 + 0 diff --git a/tests/flattener_dicos/60familyaction/tiramisu/__init__.py b/tests/flattener_dicos/60familyaction/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60familyaction/tiramisu/base.py b/tests/flattener_dicos/60familyaction/tiramisu/base.py new file mode 100644 index 00000000..9122bae2 --- /dev/null +++ b/tests/flattener_dicos/60familyaction/tiramisu/base.py @@ -0,0 +1,11 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non')) +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_6 = IntOption(properties=frozenset(['mandatory', 'normal']), doc='délai en minutes avant lancement', multi=False, name='delay', default=0) +option_5 = OptionDescription(doc='test', name='test', properties=frozenset(['normal']), children=[option_6]) +option_4 = OptionDescription(doc='extra', name='extra', children=[option_5]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_4]) diff --git a/tests/flattener_dicos/60familyaction_accent/__init__.py b/tests/flattener_dicos/60familyaction_accent/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60familyaction_accent/result/00-base.xml b/tests/flattener_dicos/60familyaction_accent/result/00-base.xml index 2136b58e..02f93e60 100644 --- a/tests/flattener_dicos/60familyaction_accent/result/00-base.xml +++ b/tests/flattener_dicos/60familyaction_accent/result/00-base.xml @@ -21,7 +21,7 @@ mandatory normal - 0 + 0 diff --git a/tests/flattener_dicos/60familyaction_accent/tiramisu/__init__.py b/tests/flattener_dicos/60familyaction_accent/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60familyaction_accent/tiramisu/base.py b/tests/flattener_dicos/60familyaction_accent/tiramisu/base.py new file mode 100644 index 00000000..9122bae2 --- /dev/null +++ b/tests/flattener_dicos/60familyaction_accent/tiramisu/base.py @@ -0,0 +1,11 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non')) +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_6 = IntOption(properties=frozenset(['mandatory', 'normal']), doc='délai en minutes avant lancement', multi=False, name='delay', default=0) +option_5 = OptionDescription(doc='test', name='test', properties=frozenset(['normal']), children=[option_6]) +option_4 = OptionDescription(doc='extra', name='extra', children=[option_5]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_4]) diff --git a/tests/flattener_dicos/60familyaction_mandatory/__init__.py b/tests/flattener_dicos/60familyaction_mandatory/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60familyaction_mandatory/result/00-base.xml b/tests/flattener_dicos/60familyaction_mandatory/result/00-base.xml index 9e63517e..f9c1bcb3 100644 --- a/tests/flattener_dicos/60familyaction_mandatory/result/00-base.xml +++ b/tests/flattener_dicos/60familyaction_mandatory/result/00-base.xml @@ -21,7 +21,7 @@ mandatory normal - 0 + 0 mandatory diff --git a/tests/flattener_dicos/60familyaction_mandatory/tiramisu/__init__.py b/tests/flattener_dicos/60familyaction_mandatory/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/60familyaction_mandatory/tiramisu/base.py b/tests/flattener_dicos/60familyaction_mandatory/tiramisu/base.py new file mode 100644 index 00000000..0de65c86 --- /dev/null +++ b/tests/flattener_dicos/60familyaction_mandatory/tiramisu/base.py @@ -0,0 +1,12 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non')) +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_6 = IntOption(properties=frozenset(['mandatory', 'normal']), doc='délai en minutes avant lancement', multi=False, name='delay', default=0) +option_7 = IntOption(properties=frozenset(['mandatory', 'basic']), doc='day avant lancement', multi=False, name='day') +option_5 = OptionDescription(doc='test', name='test', properties=frozenset(['basic']), children=[option_6, option_7]) +option_4 = OptionDescription(doc='extra', name='extra', children=[option_5]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_4]) diff --git a/tests/flattener_dicos/70container_files/__init__.py b/tests/flattener_dicos/70container_files/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_files/result/00-base.xml b/tests/flattener_dicos/70container_files/result/00-base.xml index 811f7b2a..3e6ccef9 100644 --- a/tests/flattener_dicos/70container_files/result/00-base.xml +++ b/tests/flattener_dicos/70container_files/result/00-base.xml @@ -6,48 +6,48 @@ - root + root - 0644 + 0644 - /etc/mailname + /etc/mailname - root + root - mailname + mailname - True + True - True + True - root + root - 0644 + 0644 - /rougail.conf + /rougail.conf - root + root - rougail.conf + rougail.conf - True + True - True + True diff --git a/tests/flattener_dicos/70container_files/tiramisu/__init__.py b/tests/flattener_dicos/70container_files/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_files/tiramisu/base.py b/tests/flattener_dicos/70container_files/tiramisu/base.py new file mode 100644 index 00000000..fa71a54a --- /dev/null +++ b/tests/flattener_dicos/70container_files/tiramisu/base.py @@ -0,0 +1,27 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='oui', values=('oui', 'non')) +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_8 = StrOption(properties=frozenset([]), doc='group', multi=False, name='group', default='root') +option_9 = StrOption(properties=frozenset([]), doc='mode', multi=False, name='mode', default='0644') +option_10 = StrOption(properties=frozenset([]), doc='name', multi=False, name='name', default='/etc/mailname') +option_11 = StrOption(properties=frozenset([]), doc='owner', multi=False, name='owner', default='root') +option_12 = StrOption(properties=frozenset([]), doc='source', multi=False, name='source', default='mailname') +option_13 = BoolOption(default=True, properties=frozenset([]), doc='templating', multi=False, name='templating') +option_14 = BoolOption(default=True, properties=frozenset([]), doc='activate', multi=False, name='activate') +option_7 = OptionDescription(doc='mailname', name='mailname', children=[option_8, option_9, option_10, option_11, option_12, option_13, option_14]) +option_16 = StrOption(properties=frozenset([]), doc='group', multi=False, name='group', default='root') +option_17 = StrOption(properties=frozenset([]), doc='mode', multi=False, name='mode', default='0644') +option_18 = StrOption(properties=frozenset([]), doc='name', multi=False, name='name', default='/rougail.conf') +option_19 = StrOption(properties=frozenset([]), doc='owner', multi=False, name='owner', default='root') +option_20 = StrOption(properties=frozenset([]), doc='source', multi=False, name='source', default='rougail.conf') +option_21 = BoolOption(default=True, properties=frozenset([]), doc='templating', multi=False, name='templating') +option_22 = BoolOption(default=True, properties=frozenset([]), doc='activate', multi=False, name='activate') +option_15 = OptionDescription(doc='rougail.conf', name='rougail_conf', children=[option_16, option_17, option_18, option_19, option_20, option_21, option_22]) +option_6 = OptionDescription(name='files', doc='files', children=[option_7, option_15]) +option_5 = OptionDescription(doc='test', name='test', children=[option_6]) +option_4 = OptionDescription(name='services', doc='services', properties=frozenset(['hidden']), children=[option_5]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_4]) diff --git a/tests/flattener_dicos/70container_files_symlink_multi/__init__.py b/tests/flattener_dicos/70container_files_symlink_multi/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_files_symlink_multi/result/00-base.xml b/tests/flattener_dicos/70container_files_symlink_multi/result/00-base.xml index f2eff7ec..986a8e48 100644 --- a/tests/flattener_dicos/70container_files_symlink_multi/result/00-base.xml +++ b/tests/flattener_dicos/70container_files_symlink_multi/result/00-base.xml @@ -6,23 +6,23 @@ - root + root - 0644 + 0644 - + - root + root - mailname + mailname - True + True - True + True @@ -44,8 +44,8 @@ mandatory normal - /etc/mailname - /etc/mailname2 + /etc/mailname + /etc/mailname2 diff --git a/tests/flattener_dicos/70container_files_symlink_multi/tiramisu/__init__.py b/tests/flattener_dicos/70container_files_symlink_multi/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_files_symlink_multi/tiramisu/base.py b/tests/flattener_dicos/70container_files_symlink_multi/tiramisu/base.py new file mode 100644 index 00000000..bfdf0910 --- /dev/null +++ b/tests/flattener_dicos/70container_files_symlink_multi/tiramisu/base.py @@ -0,0 +1,20 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='oui', values=('oui', 'non')) +option_4 = StrOption(properties=frozenset(['mandatory', 'normal']), doc='file_name', multi=True, name='file_name', default=['/etc/mailname', '/etc/mailname2'], default_multi='/etc/mailname2') +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3, option_4]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_9 = StrOption(properties=frozenset([]), doc='group', multi=False, name='group', default='root') +option_10 = StrOption(properties=frozenset([]), doc='mode', multi=False, name='mode', default='0644') +option_11 = SymLinkOption(name='name', opt=option_4) +option_12 = StrOption(properties=frozenset([]), doc='owner', multi=False, name='owner', default='root') +option_13 = StrOption(properties=frozenset([]), doc='source', multi=False, name='source', default='mailname') +option_14 = BoolOption(default=True, properties=frozenset([]), doc='templating', multi=False, name='templating') +option_15 = BoolOption(default=True, properties=frozenset([]), doc='activate', multi=False, name='activate') +option_8 = OptionDescription(doc='mailname', name='mailname', children=[option_9, option_10, option_11, option_12, option_13, option_14, option_15]) +option_7 = OptionDescription(name='files', doc='files', children=[option_8]) +option_6 = OptionDescription(doc='test', name='test', children=[option_7]) +option_5 = OptionDescription(name='services', doc='services', properties=frozenset(['hidden']), children=[option_6]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_5]) diff --git a/tests/flattener_dicos/70container_files_symlink_multi_variable/__init__.py b/tests/flattener_dicos/70container_files_symlink_multi_variable/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_files_symlink_multi_variable/result/00-base.xml b/tests/flattener_dicos/70container_files_symlink_multi_variable/result/00-base.xml index b3f0634e..1ed33554 100644 --- a/tests/flattener_dicos/70container_files_symlink_multi_variable/result/00-base.xml +++ b/tests/flattener_dicos/70container_files_symlink_multi_variable/result/00-base.xml @@ -6,24 +6,24 @@ - root + root - 0644 + 0644 - + - root + root - mailname + mailname - True + True - + - True + True @@ -45,14 +45,14 @@ mandatory normal - /etc/mailname - /etc/mailname2 + /etc/mailname + /etc/mailname2 mandatory normal - mailname - mailname2 + mailname + mailname2 diff --git a/tests/flattener_dicos/70container_files_symlink_multi_variable/tiramisu/__init__.py b/tests/flattener_dicos/70container_files_symlink_multi_variable/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_files_symlink_multi_variable/tiramisu/base.py b/tests/flattener_dicos/70container_files_symlink_multi_variable/tiramisu/base.py new file mode 100644 index 00000000..44b7d300 --- /dev/null +++ b/tests/flattener_dicos/70container_files_symlink_multi_variable/tiramisu/base.py @@ -0,0 +1,22 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='oui', values=('oui', 'non')) +option_4 = StrOption(properties=frozenset(['mandatory', 'normal']), doc='file_name', multi=True, name='file_name', default=['/etc/mailname', '/etc/mailname2'], default_multi='/etc/mailname2') +option_5 = StrOption(properties=frozenset(['mandatory', 'normal']), doc='var', multi=True, name='var', default=['mailname', 'mailname2'], default_multi='mailname2') +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3, option_4, option_5]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_10 = StrOption(properties=frozenset([]), doc='group', multi=False, name='group', default='root') +option_11 = StrOption(properties=frozenset([]), doc='mode', multi=False, name='mode', default='0644') +option_12 = SymLinkOption(name='name', opt=option_4) +option_13 = StrOption(properties=frozenset([]), doc='owner', multi=False, name='owner', default='root') +option_14 = StrOption(properties=frozenset([]), doc='source', multi=False, name='source', default='mailname') +option_15 = BoolOption(default=True, properties=frozenset([]), doc='templating', multi=False, name='templating') +option_16 = SymLinkOption(name='variable', opt=option_5) +option_17 = BoolOption(default=True, properties=frozenset([]), doc='activate', multi=False, name='activate') +option_9 = OptionDescription(doc='mailname', name='mailname', children=[option_10, option_11, option_12, option_13, option_14, option_15, option_16, option_17]) +option_8 = OptionDescription(name='files', doc='files', children=[option_9]) +option_7 = OptionDescription(doc='test', name='test', children=[option_8]) +option_6 = OptionDescription(name='services', doc='services', properties=frozenset(['hidden']), children=[option_7]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_6]) diff --git a/tests/flattener_dicos/70container_filesmulti/__init__.py b/tests/flattener_dicos/70container_filesmulti/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_filesmulti/result/00-base.xml b/tests/flattener_dicos/70container_filesmulti/result/00-base.xml index 5469a501..2393fd26 100644 --- a/tests/flattener_dicos/70container_filesmulti/result/00-base.xml +++ b/tests/flattener_dicos/70container_filesmulti/result/00-base.xml @@ -6,48 +6,48 @@ - root + root - 0644 + 0644 - /etc/mailname + /etc/mailname - root + root - mailname + mailname - True + True - True + True - root + root - 0644 + 0644 - /etc/mailname2 + /etc/mailname2 - root + root - mailname2 + mailname2 - True + True - True + True diff --git a/tests/flattener_dicos/70container_filesmulti/tiramisu/__init__.py b/tests/flattener_dicos/70container_filesmulti/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_filesmulti/tiramisu/base.py b/tests/flattener_dicos/70container_filesmulti/tiramisu/base.py new file mode 100644 index 00000000..0ec5b6d1 --- /dev/null +++ b/tests/flattener_dicos/70container_filesmulti/tiramisu/base.py @@ -0,0 +1,27 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='oui', values=('oui', 'non')) +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_8 = StrOption(properties=frozenset([]), doc='group', multi=False, name='group', default='root') +option_9 = StrOption(properties=frozenset([]), doc='mode', multi=False, name='mode', default='0644') +option_10 = StrOption(properties=frozenset([]), doc='name', multi=False, name='name', default='/etc/mailname') +option_11 = StrOption(properties=frozenset([]), doc='owner', multi=False, name='owner', default='root') +option_12 = StrOption(properties=frozenset([]), doc='source', multi=False, name='source', default='mailname') +option_13 = BoolOption(default=True, properties=frozenset([]), doc='templating', multi=False, name='templating') +option_14 = BoolOption(default=True, properties=frozenset([]), doc='activate', multi=False, name='activate') +option_7 = OptionDescription(doc='mailname', name='mailname', children=[option_8, option_9, option_10, option_11, option_12, option_13, option_14]) +option_16 = StrOption(properties=frozenset([]), doc='group', multi=False, name='group', default='root') +option_17 = StrOption(properties=frozenset([]), doc='mode', multi=False, name='mode', default='0644') +option_18 = StrOption(properties=frozenset([]), doc='name', multi=False, name='name', default='/etc/mailname2') +option_19 = StrOption(properties=frozenset([]), doc='owner', multi=False, name='owner', default='root') +option_20 = StrOption(properties=frozenset([]), doc='source', multi=False, name='source', default='mailname2') +option_21 = BoolOption(default=True, properties=frozenset([]), doc='templating', multi=False, name='templating') +option_22 = BoolOption(default=True, properties=frozenset([]), doc='activate', multi=False, name='activate') +option_15 = OptionDescription(doc='mailname2', name='mailname2', children=[option_16, option_17, option_18, option_19, option_20, option_21, option_22]) +option_6 = OptionDescription(name='files', doc='files', children=[option_7, option_15]) +option_5 = OptionDescription(doc='test', name='test', children=[option_6]) +option_4 = OptionDescription(name='services', doc='services', properties=frozenset(['hidden']), children=[option_5]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_4]) diff --git a/tests/flattener_dicos/70container_filesredefine/__init__.py b/tests/flattener_dicos/70container_filesredefine/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_filesredefine/result/00-base.xml b/tests/flattener_dicos/70container_filesredefine/result/00-base.xml index b98857b1..7e6af2c2 100644 --- a/tests/flattener_dicos/70container_filesredefine/result/00-base.xml +++ b/tests/flattener_dicos/70container_filesredefine/result/00-base.xml @@ -6,25 +6,25 @@ - root + root - 0644 + 0644 - /etc/mailname + /etc/mailname - root + root - mailname.new + mailname.new - True + True - True + True diff --git a/tests/flattener_dicos/70container_filesredefine/tiramisu/__init__.py b/tests/flattener_dicos/70container_filesredefine/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_filesredefine/tiramisu/base.py b/tests/flattener_dicos/70container_filesredefine/tiramisu/base.py new file mode 100644 index 00000000..8029b4d3 --- /dev/null +++ b/tests/flattener_dicos/70container_filesredefine/tiramisu/base.py @@ -0,0 +1,19 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='oui', values=('oui', 'non')) +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_8 = StrOption(properties=frozenset([]), doc='group', multi=False, name='group', default='root') +option_9 = StrOption(properties=frozenset([]), doc='mode', multi=False, name='mode', default='0644') +option_10 = StrOption(properties=frozenset([]), doc='name', multi=False, name='name', default='/etc/mailname') +option_11 = StrOption(properties=frozenset([]), doc='owner', multi=False, name='owner', default='root') +option_12 = StrOption(properties=frozenset([]), doc='source', multi=False, name='source', default='mailname.new') +option_13 = BoolOption(default=True, properties=frozenset([]), doc='templating', multi=False, name='templating') +option_14 = BoolOption(default=True, properties=frozenset([]), doc='activate', multi=False, name='activate') +option_7 = OptionDescription(doc='mailname.new', name='mailname_new', children=[option_8, option_9, option_10, option_11, option_12, option_13, option_14]) +option_6 = OptionDescription(name='files', doc='files', children=[option_7]) +option_5 = OptionDescription(doc='test', name='test', children=[option_6]) +option_4 = OptionDescription(name='services', doc='services', properties=frozenset(['hidden']), children=[option_5]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_4]) diff --git a/tests/flattener_dicos/70container_new/__init__.py b/tests/flattener_dicos/70container_new/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_new/tiramisu/__init__.py b/tests/flattener_dicos/70container_new/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_new/tiramisu/base.py b/tests/flattener_dicos/70container_new/tiramisu/base.py new file mode 100644 index 00000000..26efa8c6 --- /dev/null +++ b/tests/flattener_dicos/70container_new/tiramisu/base.py @@ -0,0 +1,10 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='oui', values=('oui', 'non')) +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_5 = OptionDescription(doc='test', name='test', children=[]) +option_4 = OptionDescription(name='services', doc='services', properties=frozenset(['hidden']), children=[option_5]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_4]) diff --git a/tests/flattener_dicos/70container_newnocont/__init__.py b/tests/flattener_dicos/70container_newnocont/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_newnocont/tiramisu/__init__.py b/tests/flattener_dicos/70container_newnocont/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_newnocont/tiramisu/base.py b/tests/flattener_dicos/70container_newnocont/tiramisu/base.py new file mode 100644 index 00000000..94b83079 --- /dev/null +++ b/tests/flattener_dicos/70container_newnocont/tiramisu/base.py @@ -0,0 +1,10 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non')) +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_5 = OptionDescription(doc='test', name='test', children=[]) +option_4 = OptionDescription(name='services', doc='services', properties=frozenset(['hidden']), children=[option_5]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_4]) diff --git a/tests/flattener_dicos/70container_newwithip/__init__.py b/tests/flattener_dicos/70container_newwithip/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_newwithip/tiramisu/__init__.py b/tests/flattener_dicos/70container_newwithip/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_newwithip/tiramisu/base.py b/tests/flattener_dicos/70container_newwithip/tiramisu/base.py new file mode 100644 index 00000000..80512cc7 --- /dev/null +++ b/tests/flattener_dicos/70container_newwithip/tiramisu/base.py @@ -0,0 +1,11 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='oui', values=('oui', 'non')) +option_4 = IPOption(allow_reserved=True, properties=frozenset(['normal']), doc='No change', multi=False, name='adresse_ip_test') +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3, option_4]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_6 = OptionDescription(doc='test', name='test', children=[]) +option_5 = OptionDescription(name='services', doc='services', properties=frozenset(['hidden']), children=[option_6]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_5]) diff --git a/tests/flattener_dicos/70container_pathaccess/__init__.py b/tests/flattener_dicos/70container_pathaccess/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_pathaccess/result/00-base.xml b/tests/flattener_dicos/70container_pathaccess/result/00-base.xml index 8dcff25a..c28cae29 100644 --- a/tests/flattener_dicos/70container_pathaccess/result/00-base.xml +++ b/tests/flattener_dicos/70container_pathaccess/result/00-base.xml @@ -6,12 +6,12 @@ - auto + auto - - + + - True + True diff --git a/tests/flattener_dicos/70container_pathaccess/tiramisu/__init__.py b/tests/flattener_dicos/70container_pathaccess/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_pathaccess/tiramisu/base.py b/tests/flattener_dicos/70container_pathaccess/tiramisu/base.py new file mode 100644 index 00000000..8c65112d --- /dev/null +++ b/tests/flattener_dicos/70container_pathaccess/tiramisu/base.py @@ -0,0 +1,18 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='oui', values=('oui', 'non')) +option_4 = NetmaskOption(properties=frozenset(['mandatory', 'basic']), doc='Masque de l\'IP du réseau de l\'esclave', multi=False, name='nut_monitor_netmask') +option_5 = NetworkOption(properties=frozenset(['mandatory', 'basic']), doc='Adresse IP du réseau de l\'esclave', multi=False, name='nut_monitor_host') +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['basic']), children=[option_3, option_4, option_5]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_10 = StrOption(properties=frozenset([]), doc='interface', multi=False, name='interface', default='auto') +option_11 = SymLinkOption(name='name', opt=option_5) +option_12 = SymLinkOption(name='netmask', opt=option_4) +option_13 = BoolOption(default=True, properties=frozenset([]), doc='activate', multi=False, name='activate') +option_9 = OptionDescription(doc='nut_monitor_host', name='nut_monitor_host', children=[option_10, option_11, option_12, option_13]) +option_8 = OptionDescription(name='ips', doc='ips', children=[option_9]) +option_7 = OptionDescription(doc='nut', name='nut', children=[option_8]) +option_6 = OptionDescription(name='services', doc='services', properties=frozenset(['hidden']), children=[option_7]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_6]) diff --git a/tests/flattener_dicos/70container_pathaccess_leadership/__init__.py b/tests/flattener_dicos/70container_pathaccess_leadership/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_pathaccess_leadership/result/00-base.xml b/tests/flattener_dicos/70container_pathaccess_leadership/result/00-base.xml index 5f35dabc..8eb7d53b 100644 --- a/tests/flattener_dicos/70container_pathaccess_leadership/result/00-base.xml +++ b/tests/flattener_dicos/70container_pathaccess_leadership/result/00-base.xml @@ -6,12 +6,12 @@ - auto + auto - - + + - True + True diff --git a/tests/flattener_dicos/70container_pathaccess_leadership/tiramisu/__init__.py b/tests/flattener_dicos/70container_pathaccess_leadership/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_pathaccess_leadership/tiramisu/base.py b/tests/flattener_dicos/70container_pathaccess_leadership/tiramisu/base.py new file mode 100644 index 00000000..2a75d88a --- /dev/null +++ b/tests/flattener_dicos/70container_pathaccess_leadership/tiramisu/base.py @@ -0,0 +1,19 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='oui', values=('oui', 'non')) +option_5 = NetmaskOption(properties=frozenset(['mandatory']), doc='Masque de l\'IP du réseau de l\'esclave', multi=True, name='nut_monitor_netmask') +option_6 = NetworkOption(properties=frozenset(['mandatory', 'basic']), doc='Adresse IP du réseau de l\'esclave', multi=True, name='nut_monitor_host') +option_4 = Leadership(doc='Masque de l\'IP du réseau de l\'esclave', name='nut_monitor_netmask', properties=frozenset(['basic']), children=[option_5, option_6]) +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['basic']), children=[option_3, option_4]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_11 = StrOption(properties=frozenset([]), doc='interface', multi=False, name='interface', default='auto') +option_12 = SymLinkOption(name='name', opt=option_6) +option_13 = SymLinkOption(name='netmask', opt=option_5) +option_14 = BoolOption(default=True, properties=frozenset([]), doc='activate', multi=False, name='activate') +option_10 = OptionDescription(doc='nut_monitor_host', name='nut_monitor_host', children=[option_11, option_12, option_13, option_14]) +option_9 = OptionDescription(name='ips', doc='ips', children=[option_10]) +option_8 = OptionDescription(doc='ntp', name='ntp', children=[option_9]) +option_7 = OptionDescription(name='services', doc='services', properties=frozenset(['hidden']), children=[option_8]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_7]) diff --git a/tests/flattener_dicos/70container_save/__init__.py b/tests/flattener_dicos/70container_save/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_save/tiramisu/__init__.py b/tests/flattener_dicos/70container_save/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_save/tiramisu/base.py b/tests/flattener_dicos/70container_save/tiramisu/base.py new file mode 100644 index 00000000..89840741 --- /dev/null +++ b/tests/flattener_dicos/70container_save/tiramisu/base.py @@ -0,0 +1,8 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='oui', values=('oui', 'non')) +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1]) diff --git a/tests/flattener_dicos/70container_serviceaccess/__init__.py b/tests/flattener_dicos/70container_serviceaccess/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_serviceaccess/result/00-base.xml b/tests/flattener_dicos/70container_serviceaccess/result/00-base.xml index c603bc1d..0bcf2d19 100644 --- a/tests/flattener_dicos/70container_serviceaccess/result/00-base.xml +++ b/tests/flattener_dicos/70container_serviceaccess/result/00-base.xml @@ -6,13 +6,13 @@ - 123 + 123 - udp + udp - True + True diff --git a/tests/flattener_dicos/70container_serviceaccess/tiramisu/__init__.py b/tests/flattener_dicos/70container_serviceaccess/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_serviceaccess/tiramisu/base.py b/tests/flattener_dicos/70container_serviceaccess/tiramisu/base.py new file mode 100644 index 00000000..4dba8f53 --- /dev/null +++ b/tests/flattener_dicos/70container_serviceaccess/tiramisu/base.py @@ -0,0 +1,15 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='oui', values=('oui', 'non')) +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_8 = PortOption(allow_private=True, properties=frozenset([]), doc='name', multi=False, name='name', default='123') +option_9 = StrOption(properties=frozenset([]), doc='protocol', multi=False, name='protocol', default='udp') +option_10 = BoolOption(default=True, properties=frozenset([]), doc='activate', multi=False, name='activate') +option_7 = OptionDescription(doc='123', name='123', children=[option_8, option_9, option_10]) +option_6 = OptionDescription(name='ports', doc='ports', children=[option_7]) +option_5 = OptionDescription(doc='ntp', name='ntp', children=[option_6]) +option_4 = OptionDescription(name='services', doc='services', properties=frozenset(['hidden']), children=[option_5]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_4]) diff --git a/tests/flattener_dicos/70container_servicerestriction/__init__.py b/tests/flattener_dicos/70container_servicerestriction/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_servicerestriction/result/00-base.xml b/tests/flattener_dicos/70container_servicerestriction/result/00-base.xml index e6709841..28dd3254 100644 --- a/tests/flattener_dicos/70container_servicerestriction/result/00-base.xml +++ b/tests/flattener_dicos/70container_servicerestriction/result/00-base.xml @@ -6,16 +6,16 @@ - eth0 + eth0 - 192.168.1.1 + 192.168.1.1 - 255.255.255.255 + 255.255.255.255 - True + True diff --git a/tests/flattener_dicos/70container_servicerestriction/tiramisu/__init__.py b/tests/flattener_dicos/70container_servicerestriction/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_servicerestriction/tiramisu/base.py b/tests/flattener_dicos/70container_servicerestriction/tiramisu/base.py new file mode 100644 index 00000000..82aef0a4 --- /dev/null +++ b/tests/flattener_dicos/70container_servicerestriction/tiramisu/base.py @@ -0,0 +1,16 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='oui', values=('oui', 'non')) +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_8 = StrOption(properties=frozenset([]), doc='interface', multi=False, name='interface', default='eth0') +option_9 = NetworkOption(properties=frozenset([]), doc='name', multi=False, name='name', default='192.168.1.1') +option_10 = NetmaskOption(properties=frozenset([]), doc='netmask', multi=False, name='netmask', default='255.255.255.255') +option_11 = BoolOption(default=True, properties=frozenset([]), doc='activate', multi=False, name='activate') +option_7 = OptionDescription(doc='192.168.1.1', name='192_168_1_1', children=[option_8, option_9, option_10, option_11]) +option_6 = OptionDescription(name='ips', doc='ips', children=[option_7]) +option_5 = OptionDescription(doc='testsrv', name='testsrv', children=[option_6]) +option_4 = OptionDescription(name='services', doc='services', properties=frozenset(['hidden']), children=[option_5]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_4]) diff --git a/tests/flattener_dicos/70container_services/__init__.py b/tests/flattener_dicos/70container_services/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_services/tiramisu/__init__.py b/tests/flattener_dicos/70container_services/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/70container_services/tiramisu/base.py b/tests/flattener_dicos/70container_services/tiramisu/base.py new file mode 100644 index 00000000..ea0725dc --- /dev/null +++ b/tests/flattener_dicos/70container_services/tiramisu/base.py @@ -0,0 +1,10 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='oui', values=('oui', 'non')) +option_2 = OptionDescription(doc='général', name='general', properties=frozenset(['normal']), children=[option_3]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_5 = OptionDescription(doc='testsrv', name='testsrv', children=[]) +option_4 = OptionDescription(name='services', doc='services', properties=frozenset(['hidden']), children=[option_5]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_4]) diff --git a/tests/flattener_dicos/80action_onlyone/__init__.py b/tests/flattener_dicos/80action_onlyone/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80auto_autofreeze/__init__.py b/tests/flattener_dicos/80auto_autofreeze/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80auto_autosave/__init__.py b/tests/flattener_dicos/80auto_autosave/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80auto_error/__init__.py b/tests/flattener_dicos/80auto_error/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80auto_multi/__init__.py b/tests/flattener_dicos/80auto_multi/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80condition_itself/__init__.py b/tests/flattener_dicos/80condition_itself/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80condition_not_exists_error/__init__.py b/tests/flattener_dicos/80condition_not_exists_error/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80container_files_symlink_without_source/__init__.py b/tests/flattener_dicos/80container_files_symlink_without_source/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80container_filesredefine_error/__init__.py b/tests/flattener_dicos/80container_filesredefine_error/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80empty_typeeole_container/__init__.py b/tests/flattener_dicos/80empty_typeeole_container/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80empty_typeeole_eole/__init__.py b/tests/flattener_dicos/80empty_typeeole_eole/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80empty_typeeole_number/__init__.py b/tests/flattener_dicos/80empty_typeeole_number/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80empty_typeeole_python/__init__.py b/tests/flattener_dicos/80empty_typeeole_python/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80empty_validenum/__init__.py b/tests/flattener_dicos/80empty_validenum/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80family_several/__init__.py b/tests/flattener_dicos/80family_several/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80fill_container/__init__.py b/tests/flattener_dicos/80fill_container/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80hidden_if_in_filelist/__init__.py b/tests/flattener_dicos/80hidden_if_in_filelist/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80leadership_auto_save/__init__.py b/tests/flattener_dicos/80leadership_auto_save/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80leadership_autofreeze/__init__.py b/tests/flattener_dicos/80leadership_autofreeze/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80leadership_none_follower_between_follower/__init__.py b/tests/flattener_dicos/80leadership_none_follower_between_follower/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80leadership_not_ordered/__init__.py b/tests/flattener_dicos/80leadership_not_ordered/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80leadership_not_same_family/__init__.py b/tests/flattener_dicos/80leadership_not_same_family/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80leadership_notexists/__init__.py b/tests/flattener_dicos/80leadership_notexists/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80redefine_autoerror/__init__.py b/tests/flattener_dicos/80redefine_autoerror/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80redefine_error/__init__.py b/tests/flattener_dicos/80redefine_error/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80redefine_helperror/__init__.py b/tests/flattener_dicos/80redefine_helperror/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80redefine_notexists/__init__.py b/tests/flattener_dicos/80redefine_notexists/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80separator_multi/__init__.py b/tests/flattener_dicos/80separator_multi/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80separator_multi2/__init__.py b/tests/flattener_dicos/80separator_multi2/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80separator_nonexists/__init__.py b/tests/flattener_dicos/80separator_nonexists/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80unknown_validenum/__init__.py b/tests/flattener_dicos/80unknown_validenum/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80validenum_ouinon/__init__.py b/tests/flattener_dicos/80validenum_ouinon/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80validenum_python_not_list/__init__.py b/tests/flattener_dicos/80validenum_python_not_list/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80validenum_python_unknown/__init__.py b/tests/flattener_dicos/80validenum_python_unknown/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/80validenum_python_unknownvalue/__init__.py b/tests/flattener_dicos/80validenum_python_unknownvalue/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/88valid_enum_not_number/__init__.py b/tests/flattener_dicos/88valid_enum_not_number/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/88valid_enum_numberdefaultstring/__init__.py b/tests/flattener_dicos/88valid_enum_numberdefaultstring/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/__init__.py b/tests/flattener_dicos/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/test_flattener.py b/tests/test_1_flattener.py similarity index 90% rename from tests/test_flattener.py rename to tests/test_1_flattener.py index 8056111e..82d57693 100644 --- a/tests/test_flattener.py +++ b/tests/test_1_flattener.py @@ -6,9 +6,8 @@ from json import load from rougail import objspace, annotator from rougail.xml_compare import xml_compare -from rougail.error import CreoleDictConsistencyError -from rougail.config import dtdfilename -from rougail.annotator import VARIABLE_NAMESPACE +from rougail.error import DictConsistencyError +from rougail.config import dtdfilename, variable_namespace @@ -23,7 +22,7 @@ for test in listdir(dico_dirs): if isdir(join(dico_dirs, test)): if isdir(join(dico_dirs, test, 'result')): test_ok.add(test) - else: + elif test != '__pycache__': test_raise.add(test) excludes = set([]) @@ -67,12 +66,14 @@ def compare_xml(exported_xmlfile, expected_xmlfile): def launch_flattener(test_dir, test_ok=False): + debug = False +# debug = True eolobj = objspace.CreoleObjSpace(dtdfilename) dirs = [test_dir] subfolder = join(test_dir, 'subfolder') if isdir(subfolder): dirs.append(subfolder) - eolobj.create_or_populate_from_xml(VARIABLE_NAMESPACE, dirs) + eolobj.create_or_populate_from_xml(variable_namespace, dirs) subfolder = join(test_dir, 'extra_dirs', 'extra') if isdir(subfolder): eolobj.create_or_populate_from_xml('extra', [subfolder]) @@ -84,7 +85,8 @@ def launch_flattener(test_dir, test_ok=False): eolobj.save(destfile) result_file = join(test_dir, 'result/00-base.xml') if isfile(result_file): - #eolobj.save(result_file) + if debug: + eolobj.save(result_file) compare_xml(destfile, result_file) elif test_ok: raise Exception(f'no test found for {test_dir}') @@ -113,7 +115,7 @@ def test_dictionary(test_dir): def test_error_dictionary(test_dir_error): test_dir = join(dico_dirs, test_dir_error) - with raises(CreoleDictConsistencyError): + with raises(DictConsistencyError): launch_flattener(test_dir) diff --git a/tests/test_2_tiramisu.py b/tests/test_2_tiramisu.py new file mode 100644 index 00000000..e96dd58a --- /dev/null +++ b/tests/test_2_tiramisu.py @@ -0,0 +1,80 @@ +from lxml import etree +from os.path import isfile, join, isdir +from pytest import fixture, mark +from os import listdir, mkdir +from json import dump, load, dumps, loads + +from tiramisu import Config +from rougail import load as rougail_load +from rougail.xml_compare import xml_compare +from rougail.error import DictConsistencyError + + +dico_dirs = 'tests/flattener_dicos' + + +test_ok = set() + +for test in listdir(dico_dirs): + if isdir(join(dico_dirs, test)): + if isdir(join(dico_dirs, test, 'result')): + test_ok.add(test) + +excludes = set([]) +#excludes = set(['70container_services']) +test_ok -= excludes +#test_ok = ['10leadership_append'] + + +test_ok = list(test_ok) +test_ok.sort() + + +@fixture(scope="module", params=test_ok) +def test_dir(request): + return request.param + + +async def launch_flattener(test_dir): + debug = False +# debug = True + eosfunc = join(dico_dirs, '../eosfunc/test.py') + cache_file = test_dir + '/result/00-base.xml' + fileio = open(cache_file) + xmlroot = etree.parse(fileio).getroot() + tiramisu_objects = rougail_load(xmlroot, + eosfunc, + ) + tiramisu_objects += '\n' + #print(tiramisu_objects) + tiramisu_dir = join(test_dir, 'tiramisu') + tiramisu_file = join(tiramisu_dir, 'base.py') + #config = await Config(tiramisu_objects) + #await config.property.read_only() + #await config.property.pop('mandatory') + #config_dict = await config.value.dict() + if not isdir(tiramisu_dir): + mkdir(tiramisu_dir) + if not isfile(tiramisu_file) or debug: + with open(tiramisu_file, 'w') as fh: + fh.write(tiramisu_objects) + with open(tiramisu_file, 'r') as fh: + tiramisu_objects_ori = fh.read() + assert tiramisu_objects == tiramisu_objects_ori + #if config_dict: + # if not isdir(tiramisu_dir): + # mkdir(tiramisu_dir) + # #with open(tiramisu_file, 'w') as fh: + # # dump(config_dict, fh) + # # fh.write('\n') + #if not isfile(tiramisu_file): + # if config_dict: + # raise Exception('dict is not empty') + #else: + # assert load(fh) == loads(dumps(config_dict)) + + +@mark.asyncio +async def test_dictionary(test_dir): + test_dir = join(dico_dirs, test_dir) + await launch_flattener(test_dir) diff --git a/tests/test_makedict.py b/tests/test_3_makedict.py similarity index 73% rename from tests/test_makedict.py rename to tests/test_3_makedict.py index 5b4e370d..ec2af49d 100644 --- a/tests/test_makedict.py +++ b/tests/test_3_makedict.py @@ -7,7 +7,7 @@ from json import dump, load, dumps, loads from tiramisu import Config from rougail import load as rougail_load from rougail.xml_compare import xml_compare -from rougail.error import CreoleDictConsistencyError +from rougail.error import DictConsistencyError from rougail.config import dtdfilename @@ -37,16 +37,21 @@ def test_dir(request): async def launch_flattener(test_dir): - eosfunc = join(dico_dirs, '../eosfunc/test.py') - cache_file = test_dir + '/result/00-base.xml' - fileio = open(cache_file) - xmlroot = etree.parse(fileio).getroot() - tiramisu_objects = rougail_load(xmlroot, - dtdfilename, - eosfunc) + #eosfunc = join(dico_dirs, '../eosfunc/test.py') + #cache_file = test_dir + '/result/00-base.xml' + #fileio = open(cache_file) + #xmlroot = etree.parse(fileio).getroot() + #tiramisu_objects = rougail_load(xmlroot, + # dtdfilename, + # eosfunc) makedict_dir = join(test_dir, 'makedict') makedict_file = join(makedict_dir, 'base.json') - config = await Config(tiramisu_objects) + + modulepath = test_dir.replace('/', '.') + '.tiramisu.base' + mod = __import__(modulepath) + for token in modulepath.split(".")[1:]: + mod = getattr(mod, token) + config = await Config(mod.option_0) await config.property.read_only() await config.property.pop('mandatory') config_dict = await config.value.dict() diff --git a/tests/test_template.py b/tests/test_4_template.py similarity index 98% rename from tests/test_template.py rename to tests/test_4_template.py index ca03230a..86ed1015 100644 --- a/tests/test_template.py +++ b/tests/test_4_template.py @@ -51,7 +51,6 @@ async def test_dictionary(test_dir): with open(join(test_dir, '00-base.xml')) as fileio: xmlroot = parse(fileio).getroot() optiondescription = load(xmlroot, - dtdfilename, funcs_file) config = await Config(optiondescription) From d18248544c8345b3d40cfbf9f180fa636f122b26 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Fri, 24 Jul 2020 14:59:09 +0200 Subject: [PATCH 23/32] refactor --- src/rougail/annotator.py | 1420 ++++++++--------- src/rougail/data/rougail.dtd | 4 +- src/rougail/objspace.py | 9 +- src/rougail/path.py | 95 +- src/rougail/xmlreflector.py | 1 - .../__init__.py | 0 .../10autosave_hidden_frozenifin/00-base.xml | 2 +- .../result/00-base.xml | 2 +- .../tiramisu/base.py | 2 +- .../00-base.xml | 4 +- .../result/00-base.xml | 7 - .../tiramisu/base.py | 8 +- .../10leadership_leader_hidden/00-base.xml | 31 + .../__init__.py | 0 .../makedict/base.json | 1 + .../result/00-base.xml | 40 + .../tiramisu}/__init__.py | 0 .../tiramisu/base.py | 13 + .../00-base.xml | 32 + .../__init__.py | 0 .../makedict/base.json | 1 + .../result/00-base.xml | 36 + .../tiramisu}/__init__.py | 0 .../tiramisu/base.py | 13 + .../00-base.xml | 0 .../__init__.py | 0 .../makedict/base.json | 0 .../result/00-base.xml | 0 .../tiramisu}/__init__.py | 0 .../tiramisu/base.py | 0 .../00-base.xml | 38 + .../__init__.py | 0 .../makedict/base.json | 1 + .../result/00-base.xml | 31 + .../tiramisu}/__init__.py | 0 .../tiramisu/base.py | 10 + .../00-base.xml | 38 + .../__init__.py | 0 .../makedict/base.json | 1 + .../result/00-base.xml | 31 + .../tiramisu}/__init__.py | 0 .../tiramisu/base.py | 10 + .../result/00-base.xml | 1 - .../tiramisu/base.py | 2 +- .../00-base.xml | 38 + .../__init__.py | 0 .../makedict/base.json | 1 + .../result/00-base.xml | 31 + .../tiramisu/__init__.py | 0 .../tiramisu/base.py | 10 + .../10load_frozenifin/00-base.xml | 4 +- .../10load_frozenifin/result/00-base.xml | 4 +- .../10load_frozenifin/tiramisu/base.py | 4 +- .../10load_frozenifin_auto/00-base.xml | 4 +- .../10load_frozenifin_auto/result/00-base.xml | 4 +- .../10load_frozenifin_auto/tiramisu/base.py | 4 +- .../10load_frozenifin_multiparam/00-base.xml | 4 +- .../result/00-base.xml | 8 +- .../tiramisu/base.py | 4 +- .../10load_hidden_if_family/00-base.xml | 39 + .../10load_hidden_if_family/__init__.py | 0 .../makedict/base.json | 1 + .../result/00-base.xml | 51 + .../tiramisu/__init__.py | 0 .../10load_hidden_if_family/tiramisu/base.py | 12 + .../10load_mandatoryifin/00-base.xml | 4 +- .../10load_mandatoryifin/result/00-base.xml | 8 +- .../10load_mandatoryifin/tiramisu/base.py | 4 +- .../10valid_enum_checkval_true/00-base.xml | 24 - .../makedict/base.json | 1 - .../result/00-base.xml | 16 - .../tiramisu/base.py | 8 - .../result/00-base.xml | 1 - .../tiramisu/base.py | 2 +- .../makedict/base.json | 2 +- .../result/00-base.xml | 3 +- .../tiramisu/base.py | 2 +- .../40condition_fallback/00-base.xml | 6 + .../40condition_fallback/result/00-base.xml | 11 + .../40condition_fallback/tiramisu/base.py | 4 +- .../40hidden_if_in_group_fallback/00-base.xml | 35 + .../40hidden_if_in_group_fallback/__init__.py | 0 .../makedict/base.json | 1 + .../result/00-base.xml | 36 + .../tiramisu/__init__.py | 0 .../tiramisu/base.py | 11 + .../extra_dirs/extra1/00-base.xml | 2 +- .../extra_dirs/extra1/00-base.xml | 2 +- .../80action_onlyone/00-base.xml | 22 - .../extra_dirs/extra/00-base.xml | 26 - .../extra_dirs/extra/01-base.xml | 22 - .../80auto_autosave/00-base.xml | 25 - .../00-base.xml | 10 +- .../00-base.xml | 8 +- .../01-base.xml | 8 +- .../80empty_typeeole_container/00_base.xml | 24 - .../80empty_typeeole_eole/00_base.xml | 4 +- .../80empty_typeeole_number/00_base.xml | 4 +- .../00-base.xml | 11 +- .../80fill_autofreeze/__init__.py | 0 .../80fill_container/00-base.xml | 29 - .../00-base.xml | 10 +- .../flattener_dicos/80fill_error/__init__.py | 0 .../00-base.xml | 8 +- .../flattener_dicos/80fill_multi/__init__.py | 0 .../00-base.xml | 9 +- .../01-base.xml | 13 +- .../80redefine_fillerror/__init__.py | 0 tests/test_1_flattener.py | 4 +- tests/test_3_makedict.py | 17 +- 110 files changed, 1451 insertions(+), 1093 deletions(-) rename tests/{flattener_dicos/10load_disabled_if_inaccent => }/__init__.py (100%) create mode 100644 tests/flattener_dicos/10leadership_leader_hidden/00-base.xml rename tests/flattener_dicos/{10load_disabled_if_inaccent/tiramisu => 10leadership_leader_hidden}/__init__.py (100%) create mode 100644 tests/flattener_dicos/10leadership_leader_hidden/makedict/base.json create mode 100644 tests/flattener_dicos/10leadership_leader_hidden/result/00-base.xml rename tests/flattener_dicos/{10valid_enum_checkval_true => 10leadership_leader_hidden/tiramisu}/__init__.py (100%) create mode 100644 tests/flattener_dicos/10leadership_leader_hidden/tiramisu/base.py create mode 100644 tests/flattener_dicos/10leadership_leader_hidden_if_in/00-base.xml rename tests/flattener_dicos/{10valid_enum_checkval_true/tiramisu => 10leadership_leader_hidden_if_in}/__init__.py (100%) create mode 100644 tests/flattener_dicos/10leadership_leader_hidden_if_in/makedict/base.json create mode 100644 tests/flattener_dicos/10leadership_leader_hidden_if_in/result/00-base.xml rename tests/flattener_dicos/{80action_onlyone => 10leadership_leader_hidden_if_in/tiramisu}/__init__.py (100%) create mode 100644 tests/flattener_dicos/10leadership_leader_hidden_if_in/tiramisu/base.py rename tests/flattener_dicos/{10load_disabled_if_inaccent => 10load_disabled_if_inaccent_family}/00-base.xml (100%) rename tests/flattener_dicos/{80auto_autofreeze => 10load_disabled_if_inaccent_family}/__init__.py (100%) rename tests/flattener_dicos/{10load_disabled_if_inaccent => 10load_disabled_if_inaccent_family}/makedict/base.json (100%) rename tests/flattener_dicos/{10load_disabled_if_inaccent => 10load_disabled_if_inaccent_family}/result/00-base.xml (100%) rename tests/flattener_dicos/{80auto_autosave => 10load_disabled_if_inaccent_family/tiramisu}/__init__.py (100%) rename tests/flattener_dicos/{10load_disabled_if_inaccent => 10load_disabled_if_inaccent_family}/tiramisu/base.py (100%) create mode 100644 tests/flattener_dicos/10load_disabled_if_not_in_fallback/00-base.xml rename tests/flattener_dicos/{80auto_error => 10load_disabled_if_not_in_fallback}/__init__.py (100%) create mode 100644 tests/flattener_dicos/10load_disabled_if_not_in_fallback/makedict/base.json create mode 100644 tests/flattener_dicos/10load_disabled_if_not_in_fallback/result/00-base.xml rename tests/flattener_dicos/{80auto_multi => 10load_disabled_if_not_in_fallback/tiramisu}/__init__.py (100%) create mode 100644 tests/flattener_dicos/10load_disabled_if_not_in_fallback/tiramisu/base.py create mode 100644 tests/flattener_dicos/10load_disabled_if_not_in_fallback_force/00-base.xml rename tests/flattener_dicos/{80empty_typeeole_container => 10load_disabled_if_not_in_fallback_force}/__init__.py (100%) create mode 100644 tests/flattener_dicos/10load_disabled_if_not_in_fallback_force/makedict/base.json create mode 100644 tests/flattener_dicos/10load_disabled_if_not_in_fallback_force/result/00-base.xml rename tests/flattener_dicos/{80fill_container => 10load_disabled_if_not_in_fallback_force/tiramisu}/__init__.py (100%) create mode 100644 tests/flattener_dicos/10load_disabled_if_not_in_fallback_force/tiramisu/base.py create mode 100644 tests/flattener_dicos/10load_disabledifin_fallback_force/00-base.xml rename tests/flattener_dicos/{80redefine_autoerror => 10load_disabledifin_fallback_force}/__init__.py (100%) create mode 100644 tests/flattener_dicos/10load_disabledifin_fallback_force/makedict/base.json create mode 100644 tests/flattener_dicos/10load_disabledifin_fallback_force/result/00-base.xml create mode 100644 tests/flattener_dicos/10load_disabledifin_fallback_force/tiramisu/__init__.py create mode 100644 tests/flattener_dicos/10load_disabledifin_fallback_force/tiramisu/base.py create mode 100644 tests/flattener_dicos/10load_hidden_if_family/00-base.xml create mode 100644 tests/flattener_dicos/10load_hidden_if_family/__init__.py create mode 100644 tests/flattener_dicos/10load_hidden_if_family/makedict/base.json create mode 100644 tests/flattener_dicos/10load_hidden_if_family/result/00-base.xml create mode 100644 tests/flattener_dicos/10load_hidden_if_family/tiramisu/__init__.py create mode 100644 tests/flattener_dicos/10load_hidden_if_family/tiramisu/base.py delete mode 100644 tests/flattener_dicos/10valid_enum_checkval_true/00-base.xml delete mode 100644 tests/flattener_dicos/10valid_enum_checkval_true/makedict/base.json delete mode 100644 tests/flattener_dicos/10valid_enum_checkval_true/result/00-base.xml delete mode 100644 tests/flattener_dicos/10valid_enum_checkval_true/tiramisu/base.py create mode 100644 tests/flattener_dicos/40hidden_if_in_group_fallback/00-base.xml create mode 100644 tests/flattener_dicos/40hidden_if_in_group_fallback/__init__.py create mode 100644 tests/flattener_dicos/40hidden_if_in_group_fallback/makedict/base.json create mode 100644 tests/flattener_dicos/40hidden_if_in_group_fallback/result/00-base.xml create mode 100644 tests/flattener_dicos/40hidden_if_in_group_fallback/tiramisu/__init__.py create mode 100644 tests/flattener_dicos/40hidden_if_in_group_fallback/tiramisu/base.py delete mode 100644 tests/flattener_dicos/80action_onlyone/00-base.xml delete mode 100644 tests/flattener_dicos/80action_onlyone/extra_dirs/extra/00-base.xml delete mode 100644 tests/flattener_dicos/80action_onlyone/extra_dirs/extra/01-base.xml delete mode 100644 tests/flattener_dicos/80auto_autosave/00-base.xml delete mode 100644 tests/flattener_dicos/80empty_typeeole_container/00_base.xml rename tests/flattener_dicos/{80auto_autofreeze => 80fill_autofreeze}/00-base.xml (79%) create mode 100644 tests/flattener_dicos/80fill_autofreeze/__init__.py delete mode 100644 tests/flattener_dicos/80fill_container/00-base.xml rename tests/flattener_dicos/{80auto_error => 80fill_error}/00-base.xml (74%) create mode 100644 tests/flattener_dicos/80fill_error/__init__.py rename tests/flattener_dicos/{80auto_multi => 80fill_multi}/00-base.xml (81%) create mode 100644 tests/flattener_dicos/80fill_multi/__init__.py rename tests/flattener_dicos/{80redefine_autoerror => 80redefine_fillerror}/00-base.xml (80%) rename tests/flattener_dicos/{80redefine_autoerror => 80redefine_fillerror}/01-base.xml (50%) create mode 100644 tests/flattener_dicos/80redefine_fillerror/__init__.py diff --git a/src/rougail/annotator.py b/src/rougail/annotator.py index fd962c5b..ee5106fc 100644 --- a/src/rougail/annotator.py +++ b/src/rougail/annotator.py @@ -11,8 +11,6 @@ import imp from .i18n import _ from .utils import normalize_family from .error import DictConsistencyError -from .xmlreflector import HIGH_COMPATIBILITY -from .config import variable_namespace #mode order is important modes_level = ('basic', 'normal', 'expert') @@ -66,6 +64,24 @@ CONVERSION = {'number': int} FREEZE_AUTOFREEZE_VARIABLE = 'module_instancie' +class SpaceAnnotator: + """Transformations applied on a CreoleObjSpace instance + """ + def __init__(self, objectspace, eosfunc_file): + self.objectspace = objectspace + self.force_not_mandatory = [] + GroupAnnotator(objectspace) + ServiceAnnotator(objectspace) + VariableAnnotator(objectspace) + ConstraintAnnotator(objectspace, + eosfunc_file, + self.force_not_mandatory, + ) + FamilyAnnotator(objectspace, + self.force_not_mandatory, + ) + + class ServiceAnnotator: """Manage service's object for example:: @@ -78,38 +94,43 @@ class ServiceAnnotator: """ def __init__(self, objectspace): - self.space = objectspace.space - self.paths = objectspace.paths self.objectspace = objectspace - self.grouplist_conditions = {} self.convert_services() def gen_family(self, name, + path, ): family = self.objectspace.family() family.name = name family.doc = name family.mode = None + self.objectspace.paths.add_family('services', + path, + family, + ) return family def convert_services(self): - if not hasattr(self.space, 'services'): + if not hasattr(self.objectspace.space, 'services'): return - if not hasattr(self.space.services, 'service'): - del self.space.services + if not hasattr(self.objectspace.space.services, 'service'): + del self.objectspace.space.services return - self.space.services.hidden = True + self.objectspace.space.services.hidden = True families = {} - for idx, service_name in enumerate(self.space.services.service.keys()): - service = self.space.services.service[service_name] + for idx, service_name in enumerate(self.objectspace.space.services.service.keys()): + service = self.objectspace.space.services.service[service_name] new_service = self.objectspace.service() for elttype, values in vars(service).items(): if elttype == 'name' or elttype in ERASED_ATTRIBUTES: setattr(new_service, elttype, values) continue eltname = elttype + 's' - family = self.gen_family(eltname) + path = '.'.join(['services', eltname]) + family = self.gen_family(eltname, + path, + ) if isinstance(values, dict): values = list(values.values()) family.family = self.make_group_from_elts(service_name, @@ -119,7 +140,7 @@ class ServiceAnnotator: ) setattr(new_service, elttype, family) families[service_name] = new_service - self.space.services.service = families + self.objectspace.space.services.service = families def make_group_from_elts(self, service_name, @@ -151,16 +172,11 @@ class ServiceAnnotator: c_name = elt.source else: c_name = elt.name - family = self.gen_family(c_name) - family.variable = [] subpath = '{}.{}'.format(path, c_name) + family = self.gen_family(c_name, subpath) + family.variable = [] listname = '{}list'.format(name) activate_path = '.'.join([subpath, 'activate']) - if elt in self.grouplist_conditions: - # FIXME transformer le activate qui disparait en boolean - self.objectspace.list_conditions.setdefault(listname, - {}).setdefault(self.grouplist_conditions[elt], - []).append(activate_path) for key in dir(elt): if key.startswith('_') or key.endswith('_type') or key in ERASED_ATTRIBUTES: continue @@ -213,7 +229,10 @@ class ServiceAnnotator: type_ = 'string' variable.type = type_ if type_ == 'symlink': - variable.opt = value + variable.opt = self.objectspace.paths.get_variable_path(value, + 'services', + ) +# variable.opt = value variable.multi = None else: variable.doc = key @@ -221,12 +240,12 @@ class ServiceAnnotator: val.type = type_ val.name = value variable.value = [val] - self.paths.add_variable('services', - path, - 'service', - False, - variable, - ) + self.objectspace.paths.add_variable('services', + path, + 'service', + False, + variable, + ) return variable def _reorder_elts(self, @@ -279,75 +298,62 @@ class ServiceAnnotator: 'for {}').format(file_.name)) -class SpaceAnnotator(object): - """Transformations applied on a CreoleObjSpace instance - """ - def __init__(self, objectspace, eosfunc_file): - self.paths = objectspace.paths - self.space = objectspace.space +class GroupAnnotator: + def __init__(self, + objectspace, + ): self.objectspace = objectspace - self.valid_enums = {} - self.force_value = {} - self.force_not_mandatory = [] - if eosfunc_file: - self.eosfunc = imp.load_source('eosfunc', eosfunc_file) - else: - self.eosfunc = None - if HIGH_COMPATIBILITY: - self.has_hidden_if_in_condition = [] - self.convert_variable() - self.convert_auto_freeze() + if not hasattr(self.objectspace.space, 'constraints') or not hasattr(self.objectspace.space.constraints, 'group'): + return self.convert_groups() - self.filter_check() - self.filter_condition() - self.convert_valid_enums() - self.convert_check() - self.convert_fill() - self.remove_empty_families() - self.change_variable_mode() - self.change_family_mode() - self.dynamic_families() - self.filter_separators() - self.absolute_path_for_symlink_in_services() - self.convert_helps() - if hasattr(self.space, 'constraints'): - del self.space.constraints.index - del self.space.constraints.namespace - if vars(self.space.constraints): - raise Exception('constraints again?') - del self.space.constraints - def absolute_path_for_symlink_in_services(self): - if not hasattr(self.space, 'services'): - return - for family_name, family in vars(self.space.services).items(): - if not isinstance(family, dict): - continue - for fam in family.values(): - for fam1_name, fam1 in vars(fam).items(): - if fam1_name == 'name' or fam1_name in ERASED_ATTRIBUTES: - continue - for fam2 in fam1.family: - for variable in fam2.variable: - if variable.type == 'symlink' and '.' not in variable.name: - variable.opt = self.paths.get_variable_path(variable.opt, - variable_namespace, - ) - - def convert_helps(self): - # FIXME l'aide doit etre dans la variable! - if not hasattr(self.space, 'help'): - return - helps = self.space.help - if hasattr(helps, 'variable'): - for hlp in helps.variable.values(): - variable = self.paths.get_variable_obj(hlp.name) - variable.help = hlp.text - if hasattr(helps, 'family'): - for hlp in helps.family.values(): - variable = self.paths.get_family_obj(hlp.name) - variable.help = hlp.text - del self.space.help + def convert_groups(self): # pylint: disable=C0111 + for group in self.objectspace.space.constraints.group: + leader_fullname = group.leader + leader_family_name = self.objectspace.paths.get_variable_family_name(leader_fullname) + leader_name = self.objectspace.paths.get_variable_name(leader_fullname) + namespace = self.objectspace.paths.get_variable_namespace(leader_fullname) + if '.' not in leader_fullname: + leader_fullname = '.'.join([namespace, leader_family_name, leader_fullname]) + follower_names = list(group.follower.keys()) + has_a_leader = False + ori_leader_family = self.objectspace.paths.get_family_obj(leader_fullname.rsplit('.', 1)[0]) + for variable in list(ori_leader_family.variable.values()): + if has_a_leader: + # it's a follower + self.manage_follower(namespace, + leader_family_name, + variable, + leader_name, + follower_names, + leader_space, + leader_is_hidden, + ) + ori_leader_family.variable.pop(variable.name) + if follower_names == []: + # no more follower + break + elif variable.name == leader_name: + # it's a leader + if isinstance(variable, self.objectspace.Leadership): + # append follower to an existed leadership + leader_space = variable + # if variable.hidden: + # leader_is_hidden = True + else: + leader_space = self.objectspace.Leadership() + leader_is_hidden = self.manage_leader(leader_space, + leader_family_name, + leader_name, + namespace, + variable, + group, + leader_fullname, + ) + has_a_leader = True + else: + raise DictConsistencyError(_('cannot found followers {}').format(follower_names)) + del self.objectspace.space.constraints.group def manage_leader(self, leader_space: 'Leadership', @@ -373,21 +379,23 @@ class SpaceAnnotator(object): variable.hidden = None if hasattr(group, 'description'): leader_space.doc = group.description - else: + elif hasattr(variable, 'description'): leader_space.doc = variable.description + else: + leader_space.doc = variable.name leader_path = namespace + '.' + leader_family_name + '.' + leader_name - self.paths.add_family(namespace, - leader_path, - leader_space, - ) - leader_family = self.space.variables[namespace].family[leader_family_name] + self.objectspace.paths.add_family(namespace, + leader_path, + leader_space, + ) + leader_family = self.objectspace.space.variables[namespace].family[leader_family_name] leader_family.variable[leader_name] = leader_space leader_space.variable.append(variable) - self.paths.set_leader(namespace, - leader_family_name, - leader_name, - leader_name, - ) + self.objectspace.paths.set_leader(namespace, + leader_family_name, + leader_name, + leader_name, + ) leader_space.path = leader_fullname return leader_is_hidden @@ -407,377 +415,176 @@ class SpaceAnnotator(object): variable.frozen = True variable.force_default_on_freeze = True leader_space.variable.append(variable) # pylint: disable=E1101 - self.paths.set_leader(namespace, - leader_family_name, - variable.name, - leader_name, - ) + self.objectspace.paths.set_leader(namespace, + leader_family_name, + variable.name, + leader_name, + ) - def convert_groups(self): # pylint: disable=C0111 - if hasattr(self.space, 'constraints') and hasattr(self.space.constraints, 'group'): - for group in self.space.constraints.group: - leader_fullname = group.leader - follower_names = list(group.follower.keys()) - leader_family_name = self.paths.get_variable_family_name(leader_fullname) - namespace = self.paths.get_variable_namespace(leader_fullname) - leader_name = self.paths.get_variable_name(leader_fullname) - ori_leader_family = self.space.variables[namespace].family[leader_family_name] - has_a_leader = False - for variable in list(ori_leader_family.variable.values()): - if isinstance(variable, self.objectspace.Leadership): - # append follower to an existed leadership - if variable.name == leader_name: - leader_space = variable - has_a_leader = True - else: - if has_a_leader: - # it's a follower - self.manage_follower(namespace, - leader_family_name, - variable, - leader_name, - follower_names, - leader_space, - leader_is_hidden, - ) - ori_leader_family.variable.pop(variable.name) - if follower_names == []: - # no more follower - break - elif variable.name == leader_name: - # it's a leader - leader_space = self.objectspace.Leadership() - leader_is_hidden = self.manage_leader(leader_space, - leader_family_name, - leader_name, - namespace, - variable, - group, - leader_fullname, - ) - has_a_leader = True - else: - raise DictConsistencyError(_('cannot found followers {}').format(follower_names)) - del self.space.constraints.group - def remove_empty_families(self): # pylint: disable=C0111,R0201 - if hasattr(self.space, 'variables'): - for family in self.space.variables.values(): - if hasattr(family, 'family'): - space = family.family - removed_families = [] - for family_name, family in space.items(): - if not hasattr(family, 'variable') or len(family.variable) == 0: - removed_families.append(family_name) - del space[family_name] - # remove help too - if hasattr(self.space, 'help') and hasattr(self.space.help, 'family'): - for family in self.space.help.family.keys(): - if family in removed_families: - del self.space.help.family[family] - - def change_family_mode(self): # pylint: disable=C0111 - if not hasattr(self.space, 'variables'): - return - for family in self.space.variables.values(): - if hasattr(family, 'family'): - for family in family.family.values(): - mode = modes_level[-1] - for variable in family.variable.values(): - if isinstance(variable, self.objectspace.Leadership): - variable_mode = variable.variable[0].mode - variable.variable[0].mode = None - variable.mode = variable_mode - else: - variable_mode = variable.mode - if variable_mode is not None and modes[mode] > modes[variable_mode]: - mode = variable_mode - family.mode = mode - - def dynamic_families(self): # pylint: disable=C0111 - if not hasattr(self.space, 'variables'): - return - for family in self.space.variables.values(): - if hasattr(family, 'family'): - for family in family.family.values(): - if 'dynamic' in vars(family): - namespace = self.paths.get_variable_namespace(family.dynamic) - varpath = self.paths.get_variable_path(family.dynamic, namespace) - family.dynamic = varpath - - def annotate_variable(self, variable, family_mode, path, is_follower=False): - # if the variable is mandatory and doesn't have any value - # then the variable's mode is set to 'basic' - has_value = hasattr(variable, 'value') - if variable.mandatory is True and (not has_value or is_follower): - variable.mode = modes_level[0] - if variable.mode != None and modes[variable.mode] < modes[family_mode] and (not is_follower or variable.mode != modes_level[0]): - variable.mode = family_mode - if has_value and path not in self.force_not_mandatory: - variable.mandatory = True - if variable.hidden is True: - variable.frozen = True - if not variable.auto_save is True and 'force_default_on_freeze' not in vars(variable): - variable.force_default_on_freeze = True +class VariableAnnotator: + def __init__(self, + objectspace, + ): + self.objectspace = objectspace + self.convert_variable() + self.convert_helps() + self.convert_auto_freeze() + self.convert_separators() def convert_variable(self): - if not hasattr(self.space, 'variables'): + def _convert_variable(variable): + if not hasattr(variable, 'type'): + variable.type = 'string' + if variable.type != 'symlink' and not hasattr(variable, 'description'): + variable.description = variable.name + if hasattr(variable, 'value'): + for value in variable.value: + if not hasattr(value, 'type'): + value.type = variable.type + + def _convert_valid_enum(namespace, + variable, + path, + ): + if variable.type in FORCE_CHOICE: + check = self.objectspace.check() + check.name = 'valid_enum' + check.target = path + check.namespace = namespace + param = self.objectspace.param() + param.text = str(FORCE_CHOICE[variable.type]) + check.param = [param] + if not hasattr(self.objectspace.space, 'constraints'): + self.objectspace.space.constraints = self.objectspace.constraints() + self.objectspace.space.constraints.namespace = namespace + if not hasattr(self.objectspace.space.constraints, 'check'): + self.objectspace.space.constraints.check = [] + self.objectspace.space.constraints.check.append(check) + variable.type = 'string' + + if not hasattr(self.objectspace.space, 'variables'): return - for families in self.space.variables.values(): + for families in self.objectspace.space.variables.values(): + namespace = families.name if hasattr(families, 'family'): for family in families.family.values(): if hasattr(family, 'variable'): for variable in family.variable.values(): - if not hasattr(variable, 'type'): - variable.type = 'string' - if variable.type != 'symlink' and not hasattr(variable, 'description'): - variable.description = variable.name - if hasattr(variable, 'value'): - for value in variable.value: - if not hasattr(value, 'type'): - value.type = variable.type + if isinstance(variable, self.objectspace.Leadership): + for follower in variable.variable: + path = '{}.{}.{}.{}'.format(namespace, normalize_family(family.name), variable.name, follower.name) + _convert_variable(follower) + _convert_valid_enum(namespace, + follower, + path, + ) + else: + path = '{}.{}.{}'.format(namespace, normalize_family(family.name), variable.name) + _convert_variable(variable) + _convert_valid_enum(namespace, + variable, + path, + ) + + def convert_helps(self): + if not hasattr(self.objectspace.space, 'help'): + return + helps = self.objectspace.space.help + if hasattr(helps, 'variable'): + for hlp in helps.variable.values(): + variable = self.objectspace.paths.get_variable_obj(hlp.name) + variable.help = hlp.text + if hasattr(helps, 'family'): + for hlp in helps.family.values(): + variable = self.objectspace.paths.get_family_obj(hlp.name) + variable.help = hlp.text + del self.objectspace.space.help def convert_auto_freeze(self): # pylint: disable=C0111 - if hasattr(self.space, 'variables'): - for variables in self.space.variables.values(): + def _convert_auto_freeze(variable, namespace): + if variable.auto_freeze: + new_condition = self.objectspace.condition() + new_condition.name = 'auto_hidden_if_not_in' + new_condition.namespace = namespace + new_condition.source = FREEZE_AUTOFREEZE_VARIABLE + new_param = self.objectspace.param() + new_param.text = 'oui' + new_condition.param = [new_param] + new_target = self.objectspace.target() + new_target.type = 'variable' + path = variable.namespace + '.' + normalize_family(family.name) + '.' + variable.name + new_target.name = path + new_condition.target = [new_target] + if not hasattr(self.objectspace.space.constraints, 'condition'): + self.objectspace.space.constraints.condition = [] + self.objectspace.space.constraints.condition.append(new_condition) + if hasattr(self.objectspace.space, 'variables'): + for variables in self.objectspace.space.variables.values(): if hasattr(variables, 'family'): + namespace = variables.name for family in variables.family.values(): if hasattr(family, 'variable'): for variable in family.variable.values(): - if variable.auto_freeze: - new_condition = self.objectspace.condition() - new_condition.name = 'auto_hidden_if_not_in' - new_condition.namespace = variables.name - new_condition.source = FREEZE_AUTOFREEZE_VARIABLE - new_param = self.objectspace.param() - new_param.text = 'oui' - new_condition.param = [new_param] - new_target = self.objectspace.target() - new_target.type = 'variable' - if variables.name == variable_namespace: - path = variable.name - else: - path = variable.namespace + '.' + family.name + '.' + variable.name - new_target.name = path - new_condition.target = [new_target] - if not hasattr(self.space.constraints, 'condition'): - self.space.constraints.condition = [] - self.space.constraints.condition.append(new_condition) + if isinstance(variable, self.objectspace.Leadership): + for follower in variable.variable: + _convert_auto_freeze(follower, namespace) + else: + _convert_auto_freeze(variable, namespace) - def _set_valid_enum(self, variable, values, type_): - variable.mandatory = True - variable.choice = [] - choices = [] - for value in values: - choice = self.objectspace.choice() - try: - if type_ in CONVERSION: - choice.name = CONVERSION[type_](value) - else: - choice.name = str(value) - except: - raise DictConsistencyError(_(f'unable to change type of a valid_enum entry "{value}" is not a valid "{type_}" for "{variable.name}"')) - choices.append(choice.name) - choice.type = type_ - variable.choice.append(choice) - if not variable.choice: - raise DictConsistencyError(_('empty valid enum is not allowed for variable {}').format(variable.name)) - if hasattr(variable, 'value'): - for value in variable.value: - value.type = type_ - if type_ in CONVERSION: - cvalue = CONVERSION[type_](value.name) - else: - cvalue = value.name - if cvalue not in choices: - raise DictConsistencyError(_('value "{}" of variable "{}" is not in list of all expected values ({})').format(value.name, variable.name, choices)) - else: - new_value = self.objectspace.value() - new_value.name = values[0] - new_value.type = type_ - variable.value = [new_value] - variable.type = 'choice' - - def _convert_valid_enum(self, variable, path): - if variable.type in FORCE_CHOICE: - if path in self.valid_enums: - raise DictConsistencyError(_('cannot set valid enum for variable with type {}').format(variable.type)) - self._set_valid_enum(variable, FORCE_CHOICE[variable.type], 'string') - if path in self.valid_enums: - values = self.valid_enums[path]['values'] - self._set_valid_enum(variable, values, variable.type) - del self.valid_enums[path] - if path in self.force_value: - new_value = self.objectspace.value() - new_value.name = self.force_value[path] - new_value.type = variable.type - variable.value = [new_value] - del self.force_value[path] - - def convert_valid_enums(self): # pylint: disable=C0111 - if not hasattr(self.space, 'variables'): + def convert_separators(self): # pylint: disable=C0111,R0201 + if not hasattr(self.objectspace.space, 'variables'): return - for variables in self.space.variables.values(): - namespace = variables.name - if hasattr(variables, 'family'): - for family in variables.family.values(): - if hasattr(family, 'variable'): - for variable in family.variable.values(): - if isinstance(variable, self.objectspace.Leadership): - for follower in variable.variable: - path = '{}.{}.{}.{}'.format(namespace, family.name, variable.name, follower.name) - self._convert_valid_enum(follower, path) - else: - path = '{}.{}.{}'.format(namespace, family.name, variable.name) - self._convert_valid_enum(variable, path) - # valid_enums must be empty now (all information are store in objects) - if self.valid_enums: - raise DictConsistencyError(_('valid_enum sets for unknown variables {}').format(self.valid_enums.keys())) - - def change_variable_mode(self): # pylint: disable=C0111 - if not hasattr(self.space, 'variables'): - return - for variables in self.space.variables.values(): - if hasattr(variables, 'family'): - for family in variables.family.values(): - family_mode = family.mode - if hasattr(family, 'variable'): - for variable in family.variable.values(): - - if isinstance(variable, self.objectspace.Leadership): - mode = modes_level[-1] - for follower in variable.variable: - if follower.auto_save is True: - raise DictConsistencyError(_('leader/followers {} ' - 'could not be ' - 'auto_save').format(follower.name)) - if follower.auto_freeze is True: - raise DictConsistencyError(_('leader/followers {} ' - 'could not be ' - 'auto_freeze').format(follower.name)) - if HIGH_COMPATIBILITY and variable.name != follower.name: # and variable.variable[0].mode != modes_level[0]: - is_follower = True - else: - is_follower = False - path = '{}.{}.{}'.format(family.path, variable.name, follower.name) - self.annotate_variable(follower, family_mode, path, is_follower) - # leader's mode is minimum level - if modes[variable.variable[0].mode] > modes[follower.mode]: - follower.mode = variable.variable[0].mode - variable.mode = variable.variable[0].mode - else: - # auto_save's variable is set in 'basic' mode if its mode is 'normal' - if variable.auto_save is True and variable.mode != modes_level[-1]: - variable.mode = modes_level[0] - # auto_freeze's variable is set in 'basic' mode if its mode is 'normal' - if variable.auto_freeze is True and variable.mode != modes_level[-1]: - variable.mode = modes_level[0] - path = '{}.{}'.format(family.path, variable.name) - self.annotate_variable(variable, family_mode, path) - - def convert_fill(self): # pylint: disable=C0111,R0912 - if not hasattr(self.space, 'constraints') or not hasattr(self.space.constraints, 'fill'): - return - # sort fill/auto by index - fills = {fill.index: fill for idx, fill in enumerate(self.space.constraints.fill)} - indexes = list(fills.keys()) - indexes.sort() - targets = [] - eosfunc = dir(self.eosfunc) - for idx in indexes: - fill = fills[idx] - # test if it's redefined calculation - if fill.target in targets and not fill.redefine: - raise DictConsistencyError(_(f"A fill already exists for the target: {fill.target}")) - targets.append(fill.target) - # - if not fill.name in eosfunc: - raise DictConsistencyError(_('cannot find fill function {}').format(fill.name)) - - namespace = fill.namespace - # let's replace the target by the path - fill.target = self.paths.get_variable_path(fill.target, - namespace) - - value = self.objectspace.value() - value.type = 'calculation' - value.name = fill.name - if hasattr(fill, 'param'): - param_to_delete = [] - for fill_idx, param in enumerate(fill.param): - if param.type not in TYPE_PARAM_FILL: - raise DictConsistencyError(_(f'cannot use {param.type} type as a param in a fill/auto')) - if param.type != 'string' and not hasattr(param, 'text'): - raise DictConsistencyError(_(f"All '{param.type}' variables shall have a value in order to calculate {fill.target}")) - if param.type == 'variable': - try: - param.text, suffix = self.paths.get_variable_path(param.text, - namespace, - with_suffix=True) - if suffix: - param.suffix = suffix - except DictConsistencyError as err: - if param.optional is False: - raise err - param_to_delete.append(fill_idx) - continue - else: - param.notraisepropertyerror = None - param_to_delete.sort(reverse=True) - for param_idx in param_to_delete: - fill.param.pop(param_idx) - value.param = fill.param - variable = self.paths.get_variable_obj(fill.target) - variable.value = [value] - del self.space.constraints.fill - - def filter_separators(self): # pylint: disable=C0111,R0201 - if not hasattr(self.space, 'variables'): - return - for family in self.space.variables.values(): + for family in self.objectspace.space.variables.values(): if not hasattr(family, 'separators'): continue if hasattr(family.separators, 'separator'): for idx, separator in enumerate(family.separators.separator): - option = self.paths.get_variable_obj(separator.name) + option = self.objectspace.paths.get_variable_obj(separator.name) if hasattr(option, 'separator'): - subpath = self.paths.get_variable_path(separator.name, - separator.namespace, - ) + subpath = self.objectspace.paths.get_variable_path(separator.name, + separator.namespace, + ) raise DictConsistencyError(_('{} already has a separator').format(subpath)) option.separator = separator.text del family.separators - def load_params_in_validenum(self, param): - if param.type in ['string', 'python', 'number']: - if not hasattr(param, 'text') and (param.type == 'python' or param.type == 'number'): - raise DictConsistencyError(_("All '{}' variables shall be set in order to calculate {}").format(param.type, 'valid_enum')) - if param.type in ['string', 'number']: - try: - values = literal_eval(param.text) - except ValueError: - raise DictConsistencyError(_('Cannot load {}').format(param.text)) - elif param.type == 'python': - try: - #values = eval(param.text, {'eosfunc': self.eosfunc, '__builtins__': {'range': range, 'str': str}}) - values = eval(param.text, {'eosfunc': self.eosfunc, '__builtins__': {'range': range, 'str': str}}) - except NameError: - raise DictConsistencyError(_('The function {} is unknown').format(param.text)) - if not isinstance(values, list): - raise DictConsistencyError(_('Function {} shall return a list').format(param.text)) - new_values = [] - for val in values: - new_values.append(val) - values = new_values - else: - values = param.text - return values + +class ConstraintAnnotator: + def __init__(self, + objectspace, + eosfunc_file, + force_not_mandatory, + ): + if not hasattr(objectspace.space, 'constraints'): + return + self.objectspace = objectspace + self.eosfunc = imp.load_source('eosfunc', eosfunc_file) + self.valid_enums = {} + self.force_not_mandatory = force_not_mandatory + if hasattr(self.objectspace.space.constraints, 'check'): + self.check_check() + self.check_replace_text() + self.check_valid_enum() + self.check_change_warning() + self.convert_check() + if hasattr(self.objectspace.space.constraints, 'condition'): + self.check_params_target() + self.filter_targets() + self.convert_xxxlist_to_variable() + self.check_condition_fallback_optional() + self.check_choice_option_condition() + self.remove_condition_with_empty_target() + self.convert_condition() + if hasattr(self.objectspace.space.constraints, 'fill'): + self.convert_fill() + self.remove_constraints() def check_check(self): remove_indexes = [] functions = dir(self.eosfunc) functions.extend(['valid_enum', 'valid_in_network', 'valid_differ']) - for check_idx, check in enumerate(self.space.constraints.check): + for check_idx, check in enumerate(self.objectspace.space.constraints.check): if not check.name in functions: raise DictConsistencyError(_('cannot find check function {}').format(check.name)) if hasattr(check, 'param'): @@ -785,7 +592,7 @@ class SpaceAnnotator(object): for idx, param in enumerate(check.param): if param.type not in TYPE_PARAM_CHECK: raise DictConsistencyError(_('cannot use {} type as a param in check for {}').format(param.type, check.target)) - if param.type == 'variable' and not self.paths.path_is_defined(param.text): + if param.type == 'variable' and not self.objectspace.paths.path_is_defined(param.text): if param.optional is True: param_option_indexes.append(idx) else: @@ -800,90 +607,318 @@ class SpaceAnnotator(object): remove_indexes.append(check_idx) remove_indexes.sort(reverse=True) for idx in remove_indexes: - del self.space.constraints.check[idx] + del self.objectspace.space.constraints.check[idx] def check_replace_text(self): - for check_idx, check in enumerate(self.space.constraints.check): + for check_idx, check in enumerate(self.objectspace.space.constraints.check): if hasattr(check, 'param'): namespace = check.namespace for idx, param in enumerate(check.param): if param.type == 'variable': - param.text = self.paths.get_variable_path(param.text, namespace) - check.is_in_leadership = self.paths.get_leader(check.target) != None + param.text = self.objectspace.paths.get_variable_path(param.text, namespace) + check.is_in_leadership = self.objectspace.paths.get_leader(check.target) != None # let's replace the target by the path - check.target = self.paths.get_variable_path(check.target, namespace) + check.target = self.objectspace.paths.get_variable_path(check.target, namespace) def check_valid_enum(self): remove_indexes = [] - for idx, check in enumerate(self.space.constraints.check): + for idx, check in enumerate(self.objectspace.space.constraints.check): if check.name == 'valid_enum': - proposed_value_type = False - remove_params = [] - for param_idx, param in enumerate(check.param): - if hasattr(param, 'name') and param.name == 'checkval': - try: - proposed_value_type = self.objectspace.convert_boolean(param.text) == False - remove_params.append(param_idx) - except TypeError as err: - raise DictConsistencyError(_('cannot load checkval value for variable {}: {}').format(check.target, err)) - if proposed_value_type: - # no more supported - raise DictConsistencyError(_('cannot load checkval value for variable {}, no more supported').format(check.target)) - remove_params.sort(reverse=True) - for param_idx in remove_params: - del check.param[param_idx] if len(check.param) != 1: - raise DictConsistencyError(_('cannot set more than one param ' - 'for valid_enum for variable {}' - '').format(check.target)) + raise DictConsistencyError(_(f'cannot set more than one param for valid_enum for variable {check.target}')) param = check.param[0] if check.target in self.valid_enums: - raise DictConsistencyError(_('valid_enum already set for {}' - '').format(check.target)) - if proposed_value_type: - if param.type == 'variable': - try: - values = self.load_params_in_validenum(param) - except NameError as err: - raise DictConsistencyError(_('cannot load value for variable {}: {}').format(check.target, err)) - add_default_value = not check.is_in_leadership - if add_default_value and values: - self.force_value[check.target] = values[0] - else: - values = self.load_params_in_validenum(param) - self.valid_enums[check.target] = {'type': param.type, - 'values': values} - remove_indexes.append(idx) + raise DictConsistencyError(_(f'valid_enum already set for {check.target}')) + if param.type not in ['string', 'python', 'number']: + raise DictConsistencyError(_(f'unknown type {param.type} for param in valid_enum for {check.target}')) + variable = self.objectspace.paths.get_variable_obj(check.target) + values = self.load_params_in_validenum(param, + variable.name, + variable.type, + ) + self.valid_enums[check.target] = {'type': param.type, + 'values': values} + self._set_valid_enum(variable, + values, + variable.type, + ) + remove_indexes.append(idx) remove_indexes.sort(reverse=True) for idx in remove_indexes: - del self.space.constraints.check[idx] + del self.objectspace.space.constraints.check[idx] + + def load_params_in_validenum(self, + param, + variable_name, + variable_type, + ): + if not hasattr(param, 'text') and (param.type == 'python' or param.type == 'number'): + raise DictConsistencyError(_(f"All '{param.type}' variables shall be set in order to calculate valid_enum for variable {variable_name}")) + if variable_type == 'string' and param.type == 'number': + raise DictConsistencyError(_(f'Unconsistency valid_enum type ({param.type}), for variable {variable_name}')) + if param.type == 'python': + try: + values = eval(param.text, {'eosfunc': self.eosfunc, '__builtins__': {'range': range, 'str': str}}) + except NameError: + raise DictConsistencyError(_('The function {} is unknown').format(param.text)) + else: + try: + values = literal_eval(param.text) + except ValueError: + raise DictConsistencyError(_(f'Cannot load {param.text} in valid_enum')) + if not isinstance(values, list): + raise DictConsistencyError(_('Function {} shall return a list').format(param.text)) + for value in values: + if variable_type == 'string' and not isinstance(value, str): + raise DictConsistencyError(_(f'Cannot load "{param.text}", "{value}" is not a string')) + if variable_type == 'number' and not isinstance(value, int): + raise DictConsistencyError(_(f'Cannot load "{param.text}", "{value}" is not a number')) + return values def check_change_warning(self): #convert level to "warnings_only" - for check in self.space.constraints.check: + for check in self.objectspace.space.constraints.check: if check.level == 'warning': check.warnings_only = True else: check.warnings_only = False check.level = None - def filter_check(self): # pylint: disable=C0111 - # valid param in check - if not hasattr(self.space, 'constraints') or not hasattr(self.space.constraints, 'check'): - return - self.check_check() - self.check_replace_text() - self.check_valid_enum() - self.check_change_warning() - if not self.space.constraints.check: - del self.space.constraints.check + def _get_family_variables_from_target(self, + target, + ): + if target.type == 'variable': + variable = self.objectspace.paths.get_variable_obj(target.name) + family = self.objectspace.paths.get_family_obj(target.name.rsplit('.', 1)[0]) + if isinstance(family, self.objectspace.Leadership) and family.name == variable.name: + return family, family.variable + return variable, [variable] + # it's a family + variable = self.objectspace.paths.get_family_obj(target.name) + return variable, list(variable.variable.values()) + def check_params_target(self): + for condition in self.objectspace.space.constraints.condition: + for param in condition.param: + if param.type not in TYPE_PARAM_CONDITION: + raise DictConsistencyError(_(f'cannot use {param.type} type as a param in a condition')) + if not hasattr(condition, 'target'): + raise DictConsistencyError(_('target is mandatory in condition')) + for target in condition.target: + if target.type.endswith('list') and condition.name not in ['disabled_if_in', 'disabled_if_not_in']: + raise DictConsistencyError(_(f'target in condition for {target.type} not allow in {condition.name}')) + + def filter_targets(self): # pylint: disable=C0111 + for condition_idx, condition in enumerate(self.objectspace.space.constraints.condition): + namespace = condition.namespace + for idx, target in enumerate(condition.target): + if target.type == 'variable': + if condition.source == target.name: + raise DictConsistencyError(_('target name and source name must be different: {}').format(condition.source)) + try: + target.name = self.objectspace.paths.get_variable_path(target.name, namespace) + except DictConsistencyError: + # for optional variable + pass + elif target.type == 'family': + try: + target.name = self.objectspace.paths.get_family_path(target.name, namespace) + except KeyError: + raise DictConsistencyError(_('cannot found family {}').format(target.name)) + + def convert_xxxlist_to_variable(self): # pylint: disable=C0111 + # transform *list to variable or family + for condition_idx, condition in enumerate(self.objectspace.space.constraints.condition): + new_targets = [] + remove_targets = [] + for target_idx, target in enumerate(condition.target): + if target.type.endswith('list'): + listname = target.type + listvars = self.objectspace.list_conditions.get(listname, + {}).get(target.name) + if listvars: + for listvar in listvars: + variable = self.objectspace.paths.get_variable_obj(listvar) + type_ = 'variable' + new_target = self.objectspace.target() + new_target.type = type_ + new_target.name = listvar + new_target.index = target.index + new_targets.append(new_target) + remove_targets.append(target_idx) + remove_targets.sort(reverse=True) + for target_idx in remove_targets: + condition.target.pop(target_idx) + condition.target.extend(new_targets) + + def check_condition_fallback_optional(self): + # a condition with a fallback **and** the source variable doesn't exist + remove_conditions = [] + for idx, condition in enumerate(self.objectspace.space.constraints.condition): + # fallback + if condition.fallback is True and not self.objectspace.paths.path_is_defined(condition.source): + apply_action = False + if condition.name in ['disabled_if_in', 'mandatory_if_in', 'hidden_if_in']: + apply_action = not condition.force_condition_on_fallback + else: + apply_action = condition.force_inverse_condition_on_fallback + if apply_action: + actions = self._get_condition_actions(condition.name) + for target in condition.target: + leader_or_variable, variables = self._get_family_variables_from_target(target) + for action_idx, action in enumerate(actions): + if action_idx == 0: + setattr(leader_or_variable, action, True) + else: + for variable in variables: + setattr(variable, action, True) + remove_conditions.append(idx) + continue + + remove_targets = [] + # optional + for idx, target in enumerate(condition.target): + if target.optional is True and not self.objectspace.paths.path_is_defined(target.name): + remove_targets.append(idx) + remove_targets = list(set(remove_targets)) + remove_targets.sort(reverse=True) + for idx in remove_targets: + condition.target.pop(idx) + remove_conditions = list(set(remove_conditions)) + remove_conditions.sort(reverse=True) + for idx in remove_conditions: + self.objectspace.space.constraints.condition.pop(idx) + + def _get_condition_actions(self, condition_name): + if condition_name.startswith('disabled_if_'): + return ['disabled'] + elif condition_name.startswith('hidden_if_'): + return ['hidden', 'frozen', 'force_default_on_freeze'] + elif condition_name.startswith('mandatory_if_'): + return ['mandatory'] + elif condition_name == 'auto_hidden_if_not_in': + return ['auto_frozen'] + + def check_choice_option_condition(self): + # remove condition for ChoiceOption that don't have param + remove_conditions = [] + for condition_idx, condition in enumerate(self.objectspace.space.constraints.condition): + namespace = condition.namespace + condition.source = self.objectspace.paths.get_variable_path(condition.source, namespace, allow_source=True) + src_variable = self.objectspace.paths.get_variable_obj(condition.source) + valid_enum = None + if condition.source in self.valid_enums and self.valid_enums[condition.source]['type'] == 'string': + valid_enum = self.valid_enums[condition.source]['values'] + if valid_enum is not None: + remove_param = [] + for param_idx, param in enumerate(condition.param): + if param.text not in valid_enum: + remove_param.append(param_idx) + remove_param.sort(reverse=True) + for idx in remove_param: + del condition.param[idx] + if condition.param == []: + remove_targets = [] + for target in condition.target: + leader_or_variable, variables = self._get_family_variables_from_target(target) + if condition.name == 'disabled_if_not_in': + leader_or_variable.disabled = True + elif condition.name == 'hidden_if_not_in': + leader_or_variable.hidden = True + for variable in variables: + variable.frozen = True + variable.force_default_on_freeze = True + elif condition.name == 'mandatory_if_not_in': + variable.mandatory = True + remove_targets = list(set(remove_targets)) + remove_targets.sort(reverse=True) + for target_idx in remove_targets: + condition.target.pop(target_idx) + remove_conditions.append(condition_idx) + remove_conditions = list(set(remove_conditions)) + remove_conditions.sort(reverse=True) + for idx in remove_conditions: + self.objectspace.space.constraints.condition.pop(idx) + + def remove_condition_with_empty_target(self): + remove_conditions = [] + for condition_idx, condition in enumerate(self.objectspace.space.constraints.condition): + if not condition.target: + remove_conditions.append(condition_idx) + remove_conditions = list(set(remove_conditions)) + remove_conditions.sort(reverse=True) + for idx in remove_conditions: + self.objectspace.space.constraints.condition.pop(idx) + + def convert_condition(self): + for condition in self.objectspace.space.constraints.condition: + inverse = condition.name.endswith('_if_not_in') + actions = self._get_condition_actions(condition.name) + for param in condition.param: + if hasattr(param, 'text'): + param = param.text + else: + param = None + for target in condition.target: + leader_or_variable, variables = self._get_family_variables_from_target(target) + # if option is already disable, do not apply disable_if_in + if hasattr(leader_or_variable, actions[0]) and getattr(leader_or_variable, actions[0]) is True: + continue + for idx, action in enumerate(actions): + prop = self.objectspace.property_() + prop.type = 'calculation' + prop.inverse = inverse + prop.source = condition.source + prop.expected = param + prop.name = action + if idx == 0: + if not hasattr(leader_or_variable, 'property'): + leader_or_variable.property = [] + leader_or_variable.property.append(prop) + else: + for variable in variables: + if not hasattr(variable, 'property'): + variable.property = [] + variable.property.append(prop) + del self.objectspace.space.constraints.condition + + def _set_valid_enum(self, variable, values, type_): + # value for choice's variable is mandatory + variable.mandatory = True + # build choice + variable.choice = [] + choices = [] + for value in values: + choice = self.objectspace.choice() + try: + choice.name = CONVERSION.get(type_, str)(value) + except: + raise DictConsistencyError(_(f'unable to change type of a valid_enum entry "{value}" is not a valid "{type_}" for "{variable.name}"')) + choices.append(choice.name) + choice.type = type_ + variable.choice.append(choice) + if not variable.choice: + raise DictConsistencyError(_('empty valid enum is not allowed for variable {}').format(variable.name)) + # check value or set first choice value has default value + if hasattr(variable, 'value'): + for value in variable.value: + value.type = type_ + try: + cvalue = CONVERSION.get(type_, str)(value.name) + except: + raise DictConsistencyError(_(f'unable to change type of value "{value}" is not a valid "{type_}" for "{variable.name}"')) + if cvalue not in choices: + raise DictConsistencyError(_('value "{}" of variable "{}" is not in list of all expected values ({})').format(value.name, variable.name, choices)) + else: + new_value = self.objectspace.value() + new_value.name = values[0] + new_value.type = type_ + variable.value = [new_value] + variable.type = 'choice' def convert_check(self): - if not hasattr(self.space, 'constraints') or not hasattr(self.space.constraints, 'check'): - return - for check in self.space.constraints.check: - variable = self.paths.get_variable_obj(check.target) + for check in self.objectspace.space.constraints.check: + variable = self.objectspace.paths.get_variable_obj(check.target) check_ = self.objectspace.check() name = check.name if name == 'valid_differ': @@ -912,239 +947,168 @@ class SpaceAnnotator(object): if not hasattr(variable, 'check'): variable.check = [] variable.check.append(check_) - del self.space.constraints.check + del self.objectspace.space.constraints.check - def filter_targets(self): # pylint: disable=C0111 - for condition_idx, condition in enumerate(self.space.constraints.condition): - namespace = condition.namespace - for idx, target in enumerate(condition.target): - if target.type == 'variable': - if condition.source == target.name: - raise DictConsistencyError(_('target name and source name must be different: {}').format(condition.source)) - target.name = self.paths.get_variable_path(target.name, namespace) - elif target.type == 'family': - try: - target.name = self.paths.get_family_path(target.name, namespace) - except KeyError: - raise DictConsistencyError(_('cannot found family {}').format(target.name)) + def convert_fill(self): # pylint: disable=C0111,R0912 + # sort fill/auto by index + fills = {fill.index: fill for idx, fill in enumerate(self.objectspace.space.constraints.fill)} + indexes = list(fills.keys()) + indexes.sort() + targets = [] + eosfunc = dir(self.eosfunc) + for idx in indexes: + fill = fills[idx] + # test if it's redefined calculation + if fill.target in targets and not fill.redefine: + raise DictConsistencyError(_(f"A fill already exists for the target: {fill.target}")) + targets.append(fill.target) + # + if fill.name not in eosfunc: + raise DictConsistencyError(_('cannot find fill function {}').format(fill.name)) - def convert_xxxlist_to_variable(self): # pylint: disable=C0111 - # transform *list to variable or family - for condition_idx, condition in enumerate(self.space.constraints.condition): - new_targets = [] - remove_targets = [] - for target_idx, target in enumerate(condition.target): - if target.type not in ['variable', 'family']: - listname = target.type - if not listname.endswith('list'): - raise Exception('not yet implemented') - listvars = self.objectspace.list_conditions.get(listname, - {}).get(target.name) - if listvars: - for listvar in listvars: - variable = self.paths.get_variable_obj(listvar) - type_ = 'variable' - new_target = self.objectspace.target() - new_target.type = type_ - new_target.name = listvar - new_target.index = target.index - new_targets.append(new_target) - remove_targets.append(target_idx) - remove_targets = list(set(remove_targets)) - remove_targets.sort(reverse=True) - for target_idx in remove_targets: - condition.target.pop(target_idx) - condition.target.extend(new_targets) + namespace = fill.namespace + # let's replace the target by the path + fill.target = self.objectspace.paths.get_variable_path(fill.target, + namespace, + ) - def check_condition(self): - for condition in self.space.constraints.condition: - if condition.name not in ['disabled_if_in', 'disabled_if_not_in', 'hidden_if_in', 'auto_hidden_if_not_in', - 'hidden_if_not_in', 'mandatory_if_in', 'mandatory_if_not_in']: - raise DictConsistencyError(_(f'unknown condition {condition.name}')) - - def check_params(self): - for condition in self.space.constraints.condition: - for param in condition.param: - if param.type not in TYPE_PARAM_CONDITION: - raise DictConsistencyError(_(f'cannot use {param.type} type as a param in a condition')) - - def check_target(self): - for condition in self.space.constraints.condition: - if not hasattr(condition, 'target'): - raise DictConsistencyError(_('target is mandatory in condition')) - for target in condition.target: - if target.type.endswith('list') and condition.name not in ['disabled_if_in', 'disabled_if_not_in']: - raise DictConsistencyError(_(f'target in condition for {target.type} not allow in {condition.name}')) - - def check_condition_fallback_optional(self): - # a condition with a fallback **and** the source variable doesn't exist - remove_conditions = [] - for idx, condition in enumerate(self.space.constraints.condition): - remove_targets = [] - if condition.fallback is True and not self.paths.path_is_defined(condition.source): - for target in condition.target: - if target.type in ['variable', 'family']: - if target.name.startswith(variable_namespace + '.'): - name = target.name.split('.')[-1] - else: - name = target.name - if target.type == 'variable': - variable = self.paths.get_variable_obj(name) - else: - variable = self.paths.get_family_obj(name) - if condition.name == 'disabled_if_in': - variable.disabled = True - if condition.name == 'mandatory_if_in': - variable.mandatory = True - if condition.name == 'hidden_if_in': - variable.hidden = True + value = self.objectspace.value() + value.type = 'calculation' + value.name = fill.name + if hasattr(fill, 'param'): + param_to_delete = [] + for fill_idx, param in enumerate(fill.param): + if param.type not in TYPE_PARAM_FILL: + raise DictConsistencyError(_(f'cannot use {param.type} type as a param in a fill/auto')) + if param.type != 'string' and not hasattr(param, 'text'): + raise DictConsistencyError(_(f"All '{param.type}' variables shall have a value in order to calculate {fill.target}")) + if param.type == 'variable': + try: + param.text, suffix = self.objectspace.paths.get_variable_path(param.text, + namespace, + with_suffix=True, + ) + if suffix: + param.suffix = suffix + except DictConsistencyError as err: + if param.optional is False: + raise err + param_to_delete.append(fill_idx) + continue else: - listname = target.type - listvars = self.objectspace.list_conditions.get(listname, - {}).get(target.name, None) - if listvars is not None: - for listvar in listvars: - variable = self.paths.get_variable_obj(listvar) - if condition.name in ['disabled_if_in']: - variable.value[0].name = False - del self.objectspace.list_conditions[listname][target.name] - remove_conditions.append(idx) - for idx, target in enumerate(condition.target): - if target.optional is True and not self.paths.path_is_defined(target.name): - remove_targets.append(idx) - remove_targets = list(set(remove_targets)) - remove_targets.sort(reverse=True) - for idx in remove_targets: - condition.target.pop(idx) - remove_conditions = list(set(remove_conditions)) - remove_conditions.sort(reverse=True) - for idx in remove_conditions: - self.space.constraints.condition.pop(idx) + param.notraisepropertyerror = None + param_to_delete.sort(reverse=True) + for param_idx in param_to_delete: + fill.param.pop(param_idx) + value.param = fill.param + variable = self.objectspace.paths.get_variable_obj(fill.target) + variable.value = [value] + del self.objectspace.space.constraints.fill - def check_choice_option_condition(self): - # remove condition for ChoiceOption that don't have param - remove_conditions = [] - for condition_idx, condition in enumerate(self.space.constraints.condition): - namespace = condition.namespace - src_variable = self.paths.get_variable_obj(condition.source) - condition.source = self.paths.get_variable_path(condition.source, namespace, allow_source=True) - valid_enum = None - if condition.source in self.valid_enums and \ - self.valid_enums[condition.source]['type'] == 'string': - valid_enum = self.valid_enums[condition.source]['values'] - if src_variable.type in FORCE_CHOICE: - valid_enum = FORCE_CHOICE[src_variable.type] - if valid_enum is not None: - remove_param = [] - for param_idx, param in enumerate(condition.param): - if param.text not in valid_enum: - remove_param.append(param_idx) - remove_param.sort(reverse=True) - for idx in remove_param: - del condition.param[idx] - if condition.param == []: - remove_targets = [] - for target in condition.target: - if target.name.startswith(f'{variable_namespace}.'): - name = target.name.split('.')[-1] - else: - name = target.name - if target.type == 'variable': - variable = self.paths.get_variable_obj(name) - else: - variable = self.paths.get_family_obj(name) - if condition.name == 'disabled_if_not_in': - variable.disabled = True - elif condition.name == 'hidden_if_not_in': - variable.hidden = True - elif condition.name == 'mandatory_if_not_in': - variable.mandatory = True - remove_targets = list(set(remove_targets)) - remove_targets.sort(reverse=True) - for target_idx in remove_targets: - condition.target.pop(target_idx) - remove_conditions.append(condition_idx) - remove_conditions = list(set(remove_conditions)) - remove_conditions.sort(reverse=True) - for idx in remove_conditions: - self.space.constraints.condition.pop(idx) + def remove_constraints(self): + if hasattr(self.objectspace.space.constraints, 'index'): + del self.objectspace.space.constraints.index + del self.objectspace.space.constraints.namespace + if vars(self.objectspace.space.constraints): + raise Exception('constraints again?') + del self.objectspace.space.constraints - def manage_variable_property(self): - for condition in self.space.constraints.condition: - #parse each variable and family - for target_idx, target in enumerate(condition.target): - if target.name.startswith(f'{variable_namespace}.'): - name = target.name.split('.')[-1] - else: - name = target.name - if target.type == 'variable': - variable = self.paths.get_variable_obj(name) - else: - variable = self.paths.get_family_obj(name) - if condition.name in ['hidden_if_in', 'hidden_if_not_in']: - variable.hidden = False - if condition.name in ['mandatory_if_in', 'mandatory_if_not_in']: - variable.mandatory = False - if HIGH_COMPATIBILITY and condition.name in ['hidden_if_in', - 'hidden_if_not_in']: - self.has_hidden_if_in_condition.append(name) - if condition.name in ['mandatory_if_in', 'mandatory_if_not_in']: - self.force_not_mandatory.append(target.name) - def remove_condition_with_empty_target(self): - remove_conditions = [] - for condition_idx, condition in enumerate(self.space.constraints.condition): - if not condition.target: - remove_conditions.append(condition_idx) - remove_conditions = list(set(remove_conditions)) - remove_conditions.sort(reverse=True) - for idx in remove_conditions: - self.space.constraints.condition.pop(idx) +class FamilyAnnotator: + def __init__(self, objectspace, force_not_mandatory): + self.objectspace = objectspace + self.force_not_mandatory = force_not_mandatory + self.remove_empty_families() + self.change_variable_mode() + self.change_family_mode() + self.dynamic_families() - def filter_condition(self): # pylint: disable=C0111 - if not hasattr(self.space, 'constraints') or not hasattr(self.space.constraints, 'condition'): + def remove_empty_families(self): # pylint: disable=C0111,R0201 + if hasattr(self.objectspace.space, 'variables'): + for family in self.objectspace.space.variables.values(): + if hasattr(family, 'family'): + space = family.family + removed_families = [] + for family_name, family in space.items(): + if not hasattr(family, 'variable') or len(family.variable) == 0: + removed_families.append(family_name) + del space[family_name] + + def change_family_mode(self): # pylint: disable=C0111 + if not hasattr(self.objectspace.space, 'variables'): return - self.check_condition() - self.check_params() - self.check_target() - self.check_condition_fallback_optional() - self.filter_targets() - self.convert_xxxlist_to_variable() - self.check_choice_option_condition() - self.manage_variable_property() - self.remove_condition_with_empty_target() - for condition in self.space.constraints.condition: - inverse = condition.name.endswith('_if_not_in') - if condition.name.startswith('disabled_if_'): - actions = ['disabled'] - elif condition.name.startswith('hidden_if_'): - actions = ['frozen', 'hidden', 'force_default_on_freeze'] - elif condition.name.startswith('mandatory_if_'): - actions = ['mandatory'] - elif condition.name == 'auto_hidden_if_not_in': - actions = ['auto_frozen'] - for param in condition.param: - if hasattr(param, 'text'): - param = param.text - else: - param = None - for target in condition.target: - if target.name.startswith(f'{variable_namespace}.'): - name = target.name.split('.')[-1] - else: - name = target.name - if target.type == 'variable': - variable = self.paths.get_variable_obj(name) - else: - variable = self.paths.get_family_obj(name) - if not hasattr(variable, 'property'): - variable.property = [] - for action in actions: - prop = self.objectspace.property_() - prop.type = 'calculation' - prop.inverse = inverse - prop.source = condition.source - prop.expected = param - prop.name = action - variable.property.append(prop) - del self.space.constraints.condition + for family in self.objectspace.space.variables.values(): + if hasattr(family, 'family'): + for family in family.family.values(): + mode = modes_level[-1] + for variable in family.variable.values(): + if isinstance(variable, self.objectspace.Leadership): + variable_mode = variable.variable[0].mode + variable.variable[0].mode = None + variable.mode = variable_mode + else: + variable_mode = variable.mode + if variable_mode is not None and modes[mode] > modes[variable_mode]: + mode = variable_mode + family.mode = mode + + def dynamic_families(self): # pylint: disable=C0111 + if not hasattr(self.objectspace.space, 'variables'): + return + for family in self.objectspace.space.variables.values(): + if hasattr(family, 'family'): + for family in family.family.values(): + if 'dynamic' in vars(family): + namespace = self.objectspace.paths.get_variable_namespace(family.dynamic) + varpath = self.objectspace.paths.get_variable_path(family.dynamic, namespace) + family.dynamic = varpath + + def annotate_variable(self, variable, family_mode, path, is_follower=False): + # if the variable is mandatory and doesn't have any value + # then the variable's mode is set to 'basic' + has_value = hasattr(variable, 'value') + if variable.mandatory is True and (not has_value or is_follower): + variable.mode = modes_level[0] + if variable.mode != None and modes[variable.mode] < modes[family_mode] and (not is_follower or variable.mode != modes_level[0]): + variable.mode = family_mode + if has_value and path not in self.force_not_mandatory: + variable.mandatory = True + if variable.hidden is True: + variable.frozen = True + if not variable.auto_save is True and 'force_default_on_freeze' not in vars(variable): + variable.force_default_on_freeze = True + + def change_variable_mode(self): # pylint: disable=C0111 + if not hasattr(self.objectspace.space, 'variables'): + return + for variables in self.objectspace.space.variables.values(): + namespace = variables.name + if hasattr(variables, 'family'): + for family in variables.family.values(): + family_mode = family.mode + if hasattr(family, 'variable'): + for variable in family.variable.values(): + + if isinstance(variable, self.objectspace.Leadership): + mode = modes_level[-1] + for idx, follower in enumerate(variable.variable): + if follower.auto_save is True: + raise DictConsistencyError(_(f'leader/followers {follower.name} could not be auto_save')) + if follower.auto_freeze is True: + raise DictConsistencyError(_('leader/followers {follower.name} could not be auto_freeze')) + is_follower = idx != 0 + path = '{}.{}.{}'.format(family.path, variable.name, follower.name) + self.annotate_variable(follower, family_mode, path, is_follower) + # leader's mode is minimum level + if modes[variable.variable[0].mode] > modes[follower.mode]: + follower.mode = variable.variable[0].mode + variable.mode = variable.variable[0].mode + else: + # auto_save's variable is set in 'basic' mode if its mode is 'normal' + if variable.auto_save is True and variable.mode != modes_level[-1]: + variable.mode = modes_level[0] + # auto_freeze's variable is set in 'basic' mode if its mode is 'normal' + if variable.auto_freeze is True and variable.mode != modes_level[-1]: + variable.mode = modes_level[0] + path = '{}.{}'.format(family.path, variable.name) + self.annotate_variable(variable, family_mode, path) diff --git a/src/rougail/data/rougail.dtd b/src/rougail/data/rougail.dtd index 1f50c910..51eb9a47 100644 --- a/src/rougail/data/rougail.dtd +++ b/src/rougail/data/rougail.dtd @@ -129,9 +129,11 @@ - + + + diff --git a/src/rougail/objspace.py b/src/rougail/objspace.py index c21a0690..955229ef 100644 --- a/src/rougail/objspace.py +++ b/src/rougail/objspace.py @@ -27,8 +27,8 @@ from collections import OrderedDict from lxml.etree import Element, SubElement # pylint: disable=E0611 from .i18n import _ -from .xmlreflector import XMLReflector, HIGH_COMPATIBILITY -from .annotator import ERASED_ATTRIBUTES, ServiceAnnotator, SpaceAnnotator +from .xmlreflector import XMLReflector +from .annotator import ERASED_ATTRIBUTES, SpaceAnnotator from .utils import normalize_family from .error import OperationError, SpaceObjShallNotBeUpdated, DictConsistencyError from .path import Path @@ -183,7 +183,7 @@ class CreoleObjSpace: family_names.append(child.attrib['name']) if child.tag == 'variables': child.attrib['name'] = namespace - if HIGH_COMPATIBILITY and child.tag == 'value' and child.text == None: + if child.tag == 'value' and child.text == None: # FIXME should not be here continue # variable objects creation @@ -444,8 +444,6 @@ class CreoleObjSpace: ): redefine = self.convert_boolean(child.attrib.get('redefine', False)) has_value = hasattr(variableobj, 'value') - if HIGH_COMPATIBILITY and has_value: - has_value = len(child) != 1 or child[0].text != None if redefine is True and child.tag == 'variable' and has_value and len(child) != 0: del variableobj.value for attr, val in child.attrib.items(): @@ -522,7 +520,6 @@ class CreoleObjSpace: variableobj.path = self.paths.get_family_path(family_name, namespace) def space_visitor(self, eosfunc_file): # pylint: disable=C0111 - ServiceAnnotator(self) SpaceAnnotator(self, eosfunc_file) def save(self, filename, force_no_save=False): diff --git a/src/rougail/path.py b/src/rougail/path.py index abcf4f84..b3796a57 100644 --- a/src/rougail/path.py +++ b/src/rougail/path.py @@ -13,6 +13,7 @@ class Path: def __init__(self): self.variables = {} self.families = {} + self.full_paths = {} # Family def add_family(self, @@ -20,33 +21,40 @@ class Path: name: str, variableobj: str, ) -> str: # pylint: disable=C0111 - self.families[name] = dict(name=name, - namespace=namespace, - variableobj=variableobj, - ) + if '.' not in name and namespace == variable_namespace: + full_name = '.'.join([namespace, name]) + self.full_paths[name] = full_name + else: + full_name = name + self.families[full_name] = dict(name=name, + namespace=namespace, + variableobj=variableobj, + ) def get_family_path(self, name: str, current_namespace: str, ) -> str: # pylint: disable=C0111 + name = normalize_family(name, + check_name=False, + allow_dot=True, + ) + if '.' not in name and current_namespace == variable_namespace and name in self.full_paths: + name = self.full_paths[name] if current_namespace is None: # pragma: no cover raise OperationError('current_namespace must not be None') - dico = self.families[normalize_family(name, - check_name=False, - allow_dot=True, - )] + dico = self.families[name] if dico['namespace'] != variable_namespace and current_namespace != dico['namespace']: raise DictConsistencyError(_('A family located in the {} namespace ' 'shall not be used in the {} namespace').format( dico['namespace'], current_namespace)) - path = dico['name'] - if dico['namespace'] is not None and '.' not in dico['name']: - path = '.'.join([dico['namespace'], path]) - return path + return dico['name'] def get_family_obj(self, name: str, ) -> 'Family': # pylint: disable=C0111 + if '.' not in name and name in self.full_paths: + name = self.full_paths[name] if name not in self.families: raise DictConsistencyError(_('unknown family {}').format(name)) dico = self.families[name] @@ -59,23 +67,25 @@ class Path: name: str, leader_name: str, ) -> None: # pylint: disable=C0111 - if namespace != variable_namespace: - # need rebuild path and move object in new path - old_path = namespace + '.' + leader_family_name + '.' + name - dico = self._get_variable(old_path) - del self.variables[old_path] - new_path = namespace + '.' + leader_family_name + '.' + leader_name + '.' + name - self.add_variable(namespace, - new_path, - dico['family'], - False, - dico['variableobj'], - ) + # need rebuild path and move object in new path + old_path = namespace + '.' + leader_family_name + '.' + name + dico = self._get_variable(old_path) + del self.variables[old_path] + new_path = namespace + '.' + leader_family_name + '.' + leader_name + '.' + name + self.add_variable(namespace, + new_path, + dico['family'], + False, + dico['variableobj'], + ) + if namespace == variable_namespace: + self.full_paths[name] = new_path + else: name = new_path dico = self._get_variable(name) if dico['leader'] != None: raise DictConsistencyError(_('Already defined leader {} for variable' - ' {}'.format(dico['leader'], name))) + ' {}'.format(dico['leader'], name))) dico['leader'] = leader_name def get_leader(self, name): # pylint: disable=C0111 @@ -89,16 +99,19 @@ class Path: is_dynamic: bool, variableobj, ) -> str: # pylint: disable=C0111 - if namespace == variable_namespace or '.' in name: - varname = name + if '.' not in name: + full_name = '.'.join([namespace, family, name]) + self.full_paths[name] = full_name else: - varname = '.'.join([namespace, family, name]) - self.variables[varname] = dict(name=name, - family=family, - namespace=namespace, - leader=None, - is_dynamic=is_dynamic, - variableobj=variableobj) + full_name = name + if namespace == variable_namespace: + name = name.rsplit('.', 1)[1] + self.variables[full_name] = dict(name=name, + family=family, + namespace=namespace, + leader=None, + is_dynamic=is_dynamic, + variableobj=variableobj) def get_variable_name(self, name, @@ -154,6 +167,8 @@ class Path: def path_is_defined(self, name: str, ) -> str: # pylint: disable=C0111 + if '.' not in name and name not in self.variables and name in self.full_paths: + return True return name in self.variables def _get_variable(self, @@ -161,14 +176,20 @@ class Path: with_suffix: bool=False, ) -> str: if name not in self.variables: - if name.startswith(f'{variable_namespace}.'): - name = name.split('.')[-1] + if name not in self.variables: + if '.' not in name and name in self.full_paths: + name = self.full_paths[name] if name not in self.variables: for var_name, variable in self.variables.items(): if variable['is_dynamic'] and name.startswith(var_name): return variable, name[len(var_name):] + if '.' not in name: + for var_name, path in self.full_paths.items(): + if name.startswith(var_name): + variable = self.variables[self.full_paths[var_name]] + if variable['is_dynamic']: + return variable, name[len(var_name):] raise DictConsistencyError(_('unknown option {}').format(name)) if with_suffix: return self.variables[name], None return self.variables[name] - diff --git a/src/rougail/xmlreflector.py b/src/rougail/xmlreflector.py index 368fcfa8..81cc5d75 100644 --- a/src/rougail/xmlreflector.py +++ b/src/rougail/xmlreflector.py @@ -8,7 +8,6 @@ from lxml.etree import DTD, parse, tostring # , XMLParser from .i18n import _ from .error import DictConsistencyError -HIGH_COMPATIBILITY = True class XMLReflector(object): """Helper class for loading the Creole XML file, diff --git a/tests/flattener_dicos/10load_disabled_if_inaccent/__init__.py b/tests/__init__.py similarity index 100% rename from tests/flattener_dicos/10load_disabled_if_inaccent/__init__.py rename to tests/__init__.py diff --git a/tests/flattener_dicos/10autosave_hidden_frozenifin/00-base.xml b/tests/flattener_dicos/10autosave_hidden_frozenifin/00-base.xml index 825fc8eb..3a48d4d7 100644 --- a/tests/flattener_dicos/10autosave_hidden_frozenifin/00-base.xml +++ b/tests/flattener_dicos/10autosave_hidden_frozenifin/00-base.xml @@ -8,7 +8,7 @@ - @@ -25,8 +25,8 @@ non mandatory normal - frozen hidden + frozen force_default_on_freeze non diff --git a/tests/flattener_dicos/10load_frozenifin/tiramisu/base.py b/tests/flattener_dicos/10load_frozenifin/tiramisu/base.py index 5a4e9b0f..2ce0a2f3 100644 --- a/tests/flattener_dicos/10load_frozenifin/tiramisu/base.py +++ b/tests/flattener_dicos/10load_frozenifin/tiramisu/base.py @@ -3,8 +3,8 @@ from rougail.tiramisu import ConvertDynOptionDescription import imp func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') option_3 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='condition', default='non', values=('oui', 'non')) -option_4 = ChoiceOption(properties=frozenset(['mandatory', 'normal', Calculation(calc_value, Params(ParamValue('frozen'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue('oui')})), Calculation(calc_value, Params(ParamValue('hidden'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue('oui')})), Calculation(calc_value, Params(ParamValue('force_default_on_freeze'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue('oui')}))]), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non')) -option_5 = ChoiceOption(properties=frozenset(['mandatory', 'normal', Calculation(calc_value, Params(ParamValue('frozen'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue('oui')})), Calculation(calc_value, Params(ParamValue('hidden'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue('oui')})), Calculation(calc_value, Params(ParamValue('force_default_on_freeze'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue('oui')}))]), doc='No change', multi=False, name='mode_conteneur_actif2', default='non', values=('oui', 'non')) +option_4 = ChoiceOption(properties=frozenset(['mandatory', 'normal', Calculation(calc_value, Params(ParamValue('hidden'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue('oui')})), Calculation(calc_value, Params(ParamValue('frozen'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue('oui')})), Calculation(calc_value, Params(ParamValue('force_default_on_freeze'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue('oui')}))]), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non')) +option_5 = ChoiceOption(properties=frozenset(['mandatory', 'normal', Calculation(calc_value, Params(ParamValue('hidden'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue('oui')})), Calculation(calc_value, Params(ParamValue('frozen'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue('oui')})), Calculation(calc_value, Params(ParamValue('force_default_on_freeze'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue('oui')}))]), doc='No change', multi=False, name='mode_conteneur_actif2', default='non', values=('oui', 'non')) option_2 = OptionDescription(doc='general', name='general', properties=frozenset(['normal']), children=[option_3, option_4, option_5]) option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1]) diff --git a/tests/flattener_dicos/10load_frozenifin_auto/00-base.xml b/tests/flattener_dicos/10load_frozenifin_auto/00-base.xml index 19e1647f..3a89b4b8 100644 --- a/tests/flattener_dicos/10load_frozenifin_auto/00-base.xml +++ b/tests/flattener_dicos/10load_frozenifin_auto/00-base.xml @@ -8,10 +8,10 @@ non - diff --git a/tests/flattener_dicos/40condition_fallback/result/00-base.xml b/tests/flattener_dicos/40condition_fallback/result/00-base.xml index 11191a20..25a2ff37 100644 --- a/tests/flattener_dicos/40condition_fallback/result/00-base.xml +++ b/tests/flattener_dicos/40condition_fallback/result/00-base.xml @@ -27,5 +27,16 @@ non + + disabled + normal + + oui + non + mandatory + normal + non + + diff --git a/tests/flattener_dicos/40condition_fallback/tiramisu/base.py b/tests/flattener_dicos/40condition_fallback/tiramisu/base.py index fac953f4..a40b5a13 100644 --- a/tests/flattener_dicos/40condition_fallback/tiramisu/base.py +++ b/tests/flattener_dicos/40condition_fallback/tiramisu/base.py @@ -6,5 +6,7 @@ option_3 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='No c option_4 = ChoiceOption(properties=frozenset(['disabled', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif1', default='non', values=('oui', 'non')) option_5 = ChoiceOption(properties=frozenset(['disabled', 'mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif2', default='non', values=('oui', 'non')) option_2 = OptionDescription(doc='general', name='general', properties=frozenset(['normal']), children=[option_3, option_4, option_5]) -option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_7 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif3', default='non', values=('oui', 'non')) +option_6 = OptionDescription(doc='disabled_family', name='disabled_family', properties=frozenset(['disabled', 'normal']), children=[option_7]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2, option_6]) option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1]) diff --git a/tests/flattener_dicos/40hidden_if_in_group_fallback/00-base.xml b/tests/flattener_dicos/40hidden_if_in_group_fallback/00-base.xml new file mode 100644 index 00000000..d814f125 --- /dev/null +++ b/tests/flattener_dicos/40hidden_if_in_group_fallback/00-base.xml @@ -0,0 +1,35 @@ + + + + + + + + + non + + + non + + + non + + + + + + + + oui + mode_conteneur_actif1 + + + mode_conteneur_actif2 + + + + + + + diff --git a/tests/flattener_dicos/40hidden_if_in_group_fallback/__init__.py b/tests/flattener_dicos/40hidden_if_in_group_fallback/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/40hidden_if_in_group_fallback/makedict/base.json b/tests/flattener_dicos/40hidden_if_in_group_fallback/makedict/base.json new file mode 100644 index 00000000..8e8eadbe --- /dev/null +++ b/tests/flattener_dicos/40hidden_if_in_group_fallback/makedict/base.json @@ -0,0 +1 @@ +{"rougail.general.mode_conteneur_actif": "non", "rougail.general.mode_conteneur_actif1.mode_conteneur_actif1": ["non"], "rougail.general.mode_conteneur_actif1.mode_conteneur_actif2": ["non"]} diff --git a/tests/flattener_dicos/40hidden_if_in_group_fallback/result/00-base.xml b/tests/flattener_dicos/40hidden_if_in_group_fallback/result/00-base.xml new file mode 100644 index 00000000..e475eddd --- /dev/null +++ b/tests/flattener_dicos/40hidden_if_in_group_fallback/result/00-base.xml @@ -0,0 +1,36 @@ + + + + + normal + + oui + non + mandatory + normal + non + + + hidden + normal + + oui + non + force_default_on_freeze + frozen + mandatory + non + + + oui + non + force_default_on_freeze + frozen + mandatory + normal + non + + + + + diff --git a/tests/flattener_dicos/40hidden_if_in_group_fallback/tiramisu/__init__.py b/tests/flattener_dicos/40hidden_if_in_group_fallback/tiramisu/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/flattener_dicos/40hidden_if_in_group_fallback/tiramisu/base.py b/tests/flattener_dicos/40hidden_if_in_group_fallback/tiramisu/base.py new file mode 100644 index 00000000..b22f2ee5 --- /dev/null +++ b/tests/flattener_dicos/40hidden_if_in_group_fallback/tiramisu/base.py @@ -0,0 +1,11 @@ +from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +import imp +func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') +option_3 = ChoiceOption(properties=frozenset(['mandatory', 'normal']), doc='No change', multi=False, name='mode_conteneur_actif', default='non', values=('oui', 'non')) +option_5 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'mandatory']), doc='No change', multi=True, name='mode_conteneur_actif1', default=['non'], values=('oui', 'non')) +option_6 = ChoiceOption(properties=frozenset(['force_default_on_freeze', 'frozen', 'mandatory', 'normal']), doc='No change', multi=True, name='mode_conteneur_actif2', default_multi='non', values=('oui', 'non')) +option_4 = Leadership(doc='No change', name='mode_conteneur_actif1', properties=frozenset(['hidden', 'normal']), children=[option_5, option_6]) +option_2 = OptionDescription(doc='general', name='general', properties=frozenset(['normal']), children=[option_3, option_4]) +option_1 = OptionDescription(doc='rougail', name='rougail', children=[option_2]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1]) diff --git a/tests/flattener_dicos/60extra_externalspace/extra_dirs/extra1/00-base.xml b/tests/flattener_dicos/60extra_externalspace/extra_dirs/extra1/00-base.xml index b74b1c18..f5cf6635 100644 --- a/tests/flattener_dicos/60extra_externalspace/extra_dirs/extra1/00-base.xml +++ b/tests/flattener_dicos/60extra_externalspace/extra_dirs/extra1/00-base.xml @@ -11,7 +11,7 @@ non - activer_ejabberd + activer_ejabberd none daily diff --git a/tests/flattener_dicos/60extra_externalspaceauto/extra_dirs/extra1/00-base.xml b/tests/flattener_dicos/60extra_externalspaceauto/extra_dirs/extra1/00-base.xml index 9c90cb17..1b015543 100644 --- a/tests/flattener_dicos/60extra_externalspaceauto/extra_dirs/extra1/00-base.xml +++ b/tests/flattener_dicos/60extra_externalspaceauto/extra_dirs/extra1/00-base.xml @@ -11,7 +11,7 @@ non - extra.ejabberd.day + extra.ejabberd.day none daily diff --git a/tests/flattener_dicos/80action_onlyone/00-base.xml b/tests/flattener_dicos/80action_onlyone/00-base.xml deleted file mode 100644 index bc7628d5..00000000 --- a/tests/flattener_dicos/80action_onlyone/00-base.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/tests/flattener_dicos/80action_onlyone/extra_dirs/extra/00-base.xml b/tests/flattener_dicos/80action_onlyone/extra_dirs/extra/00-base.xml deleted file mode 100644 index 83c7672b..00000000 --- a/tests/flattener_dicos/80action_onlyone/extra_dirs/extra/00-base.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - Reconfigurer - ead_admin - ead - reconfigure - - - - - - 0 - - - - - - - diff --git a/tests/flattener_dicos/80action_onlyone/extra_dirs/extra/01-base.xml b/tests/flattener_dicos/80action_onlyone/extra_dirs/extra/01-base.xml deleted file mode 100644 index fa96a98d..00000000 --- a/tests/flattener_dicos/80action_onlyone/extra_dirs/extra/01-base.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - Reconfigurer2 - ead_admin - ead - reconfigure - - - - - - - - - diff --git a/tests/flattener_dicos/80auto_autosave/00-base.xml b/tests/flattener_dicos/80auto_autosave/00-base.xml deleted file mode 100644 index e2d06393..00000000 --- a/tests/flattener_dicos/80auto_autosave/00-base.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - non - - - - - - - - value - - - - - - - diff --git a/tests/flattener_dicos/80container_files_symlink_without_source/00-base.xml b/tests/flattener_dicos/80container_files_symlink_without_source/00-base.xml index 1b3526fa..33542d3a 100644 --- a/tests/flattener_dicos/80container_files_symlink_without_source/00-base.xml +++ b/tests/flattener_dicos/80container_files_symlink_without_source/00-base.xml @@ -1,10 +1,10 @@ - - - - - + + + + + - + diff --git a/tests/flattener_dicos/10check_no_param/tiramisu/base.py b/tests/flattener_dicos/10check_no_param/tiramisu/base.py index 0a8d1d57..f0fade69 100644 --- a/tests/flattener_dicos/10check_no_param/tiramisu/base.py +++ b/tests/flattener_dicos/10check_no_param/tiramisu/base.py @@ -3,7 +3,7 @@ from rougail.tiramisu import ConvertDynOptionDescription import imp func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') option_3 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='b') -option_4 = IntOption(properties=frozenset({'normal'}), validators=[Calculation(func.valid_entier, Params((ParamSelfOption()), kwargs={}), warnings_only=False)], name='int', doc='No change', multi=False) +option_4 = IntOption(properties=frozenset({'normal'}), validators=[Calculation(func.valid_lower, Params((ParamSelfOption()), kwargs={}), warnings_only=False)], name='int', doc='No change', multi=False) option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3, option_4]) option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2]) option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1]) diff --git a/tests/flattener_dicos/10check_option/00-base.xml b/tests/flattener_dicos/10check_option/00-base.xml index 9663d5c1..5abff47b 100644 --- a/tests/flattener_dicos/10check_option/00-base.xml +++ b/tests/flattener_dicos/10check_option/00-base.xml @@ -17,7 +17,7 @@ - + 0 int2 diff --git a/tests/flattener_dicos/10check_option/tiramisu/base.py b/tests/flattener_dicos/10check_option/tiramisu/base.py index 34beec3b..4856560b 100644 --- a/tests/flattener_dicos/10check_option/tiramisu/base.py +++ b/tests/flattener_dicos/10check_option/tiramisu/base.py @@ -4,7 +4,7 @@ import imp func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') option_3 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='b') option_4 = IntOption(properties=frozenset({'mandatory', 'normal'}), name='int2', doc='No change', multi=False, default=100) -option_5 = IntOption(properties=frozenset({'normal'}), validators=[Calculation(func.valid_entier, Params((ParamSelfOption()), kwargs={'mini': ParamValue("0"), 'maxi': ParamOption(option_4, notraisepropertyerror=False, todict=False)}), warnings_only=False)], name='int', doc='No change', multi=False) +option_5 = IntOption(properties=frozenset({'normal'}), validators=[Calculation(func.valid_lower, Params((ParamSelfOption()), kwargs={'mini': ParamValue("0"), 'maxi': ParamOption(option_4, notraisepropertyerror=False, todict=False)}), warnings_only=False)], name='int', doc='No change', multi=False) option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3, option_4, option_5]) option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2]) option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1]) From 8f7fa59333d892fce205230512c0bba5f5f084ae Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Tue, 4 Aug 2020 16:50:45 +0200 Subject: [PATCH 32/32] add mandatory properties is more conveniant --- src/rougail/annotator.py | 53 +++++++++++-------- src/rougail/tiramisureflector.py | 6 ++- .../10leadership_append/tiramisu/base.py | 2 +- .../10leadership_auto/tiramisu/base.py | 4 +- .../10leadership_autoleader/tiramisu/base.py | 2 +- .../tiramisu/base.py | 2 +- .../tiramisu/base.py | 2 +- .../tiramisu/base.py | 4 +- .../10leadership_mandatory/tiramisu/base.py | 2 +- .../10leadership_multi/tiramisu/base.py | 2 +- .../10load_leadership/tiramisu/base.py | 2 +- .../tiramisu/base.py | 2 +- .../tiramisu/base.py | 2 +- .../20family_dynamic_calc/tiramisu/base.py | 2 +- .../20family_dynamic_number/tiramisu/base.py | 2 +- 15 files changed, 49 insertions(+), 40 deletions(-) diff --git a/src/rougail/annotator.py b/src/rougail/annotator.py index f02bd556..5e527dbd 100644 --- a/src/rougail/annotator.py +++ b/src/rougail/annotator.py @@ -75,17 +75,13 @@ class SpaceAnnotator: """ def __init__(self, objectspace, eosfunc_file): self.objectspace = objectspace - self.force_not_mandatory = [] GroupAnnotator(objectspace) ServiceAnnotator(objectspace) VariableAnnotator(objectspace) ConstraintAnnotator(objectspace, eosfunc_file, - self.force_not_mandatory, ) - FamilyAnnotator(objectspace, - self.force_not_mandatory, - ) + FamilyAnnotator(objectspace) PropertyAnnotator(objectspace) @@ -597,14 +593,12 @@ class ConstraintAnnotator: def __init__(self, objectspace, eosfunc_file, - force_not_mandatory, ): if not hasattr(objectspace.space, 'constraints'): return self.objectspace = objectspace self.eosfunc = imp.load_source('eosfunc', eosfunc_file) self.valid_enums = {} - self.force_not_mandatory = force_not_mandatory if hasattr(self.objectspace.space.constraints, 'check'): self.check_check() self.check_replace_text() @@ -974,7 +968,6 @@ class ConstraintAnnotator: if param.name == 'mini': variable.min_number = int(param.text) elif param.name == 'maxi': - print('pppp', param.text) variable.max_number = int(param.text) else: raise DictConsistencyError(_(f'unknown parameter {param.text} in check "valid_entier" for variable {check.target}')) @@ -1074,9 +1067,10 @@ class ConstraintAnnotator: class FamilyAnnotator: - def __init__(self, objectspace, force_not_mandatory): + def __init__(self, + objectspace, + ): self.objectspace = objectspace - self.force_not_mandatory = force_not_mandatory self.remove_empty_families() self.change_variable_mode() self.change_family_mode() @@ -1126,23 +1120,36 @@ class FamilyAnnotator: def annotate_variable(self, variable, family_mode, path, is_follower=False): # if the variable is mandatory and doesn't have any value # then the variable's mode is set to 'basic' - has_value = hasattr(variable, 'value') - if variable.mandatory is True and (not has_value or is_follower): - variable.mode = modes_level[0] - if variable.mode != None and modes[variable.mode] < modes[family_mode] and (not is_follower or variable.mode != modes_level[0]): - variable.mode = family_mode - if has_value and path not in self.force_not_mandatory: - variable.mandatory = True - if variable.hidden is True: - variable.frozen = True - if not variable.auto_save is True and 'force_default_on_freeze' not in vars(variable): - variable.force_default_on_freeze = True - if not has_value and variable.type == 'boolean': + if not hasattr(variable, 'value') and variable.type == 'boolean': new_value = self.objectspace.value() new_value.name = True new_value.type = 'boolean' variable.value = [new_value] - variable.mandatory = True + if hasattr(variable, 'value') and variable.value: + has_value = True + for value in variable.value: + if value.type == 'calculation': + has_value = False + has_variable = False + if hasattr(value, 'param'): + for param in value.param: + if param.type == 'variable': + has_variable = True + break + if not has_variable: + # if one parameter is a variable, let variable choice if it's mandatory + variable.mandatory = True + if has_value: + # if has value but without any calculation + variable.mandatory = True + if variable.mandatory is True and (not hasattr(variable, 'value') or is_follower): + variable.mode = modes_level[0] + if variable.mode != None and modes[variable.mode] < modes[family_mode] and (not is_follower or variable.mode != modes_level[0]): + variable.mode = family_mode + if variable.hidden is True: + variable.frozen = True + if not variable.auto_save is True and 'force_default_on_freeze' not in vars(variable): + variable.force_default_on_freeze = True def change_variable_mode(self): # pylint: disable=C0111 if not hasattr(self.objectspace.space, 'variables'): diff --git a/src/rougail/tiramisureflector.py b/src/rougail/tiramisureflector.py index f408aff2..a0d821ad 100644 --- a/src/rougail/tiramisureflector.py +++ b/src/rougail/tiramisureflector.py @@ -337,8 +337,10 @@ class Variable(Common): for key in self.get_attributes(self.elt): value = getattr(self.elt, key) if key in FORCE_INFORMATIONS: - if key == 'test' and self.object_type == 'IntOption': - value = int(value) + if key == 'test': + value = value.split(',') + if self.object_type == 'IntOption': + value = [int(v) for v in value] self.informations[key] = value else: self.attrib[key] = value diff --git a/tests/flattener_dicos/10leadership_append/tiramisu/base.py b/tests/flattener_dicos/10leadership_append/tiramisu/base.py index 871dce92..031afd31 100644 --- a/tests/flattener_dicos/10leadership_append/tiramisu/base.py +++ b/tests/flattener_dicos/10leadership_append/tiramisu/base.py @@ -6,7 +6,7 @@ option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mod option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3]) option_6 = StrOption(name='leader', doc='leader', multi=True) option_7 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='follower1', doc='follower1', multi=True, default=Calculation(func.calc_val, Params((), kwargs={'valeur': ParamValue("valfill")}))) -option_8 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='follower2', doc='follower2', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_7, notraisepropertyerror=False, todict=False)), kwargs={}))) +option_8 = StrOption(properties=frozenset({'normal'}), name='follower2', doc='follower2', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_7, notraisepropertyerror=False, todict=False)), kwargs={}))) option_9 = StrOption(properties=frozenset({'normal'}), name='follower3', doc='follower3', multi=True) option_5 = Leadership(name='leader', doc='leader', properties=frozenset({'normal'}), children=[option_6, option_7, option_8, option_9]) option_4 = OptionDescription(name='general1', doc='general1', properties=frozenset({'normal'}), children=[option_5]) diff --git a/tests/flattener_dicos/10leadership_auto/tiramisu/base.py b/tests/flattener_dicos/10leadership_auto/tiramisu/base.py index 287a62e4..5f95d40d 100644 --- a/tests/flattener_dicos/10leadership_auto/tiramisu/base.py +++ b/tests/flattener_dicos/10leadership_auto/tiramisu/base.py @@ -5,8 +5,8 @@ func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='non', values=('oui', 'non')) option_5 = StrOption(name='leader', doc='leader', multi=True) option_6 = StrOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal'}), name='follower1', doc='follower1', multi=True, default=Calculation(func.calc_val, Params((), kwargs={'valeur': ParamValue("valfill")}))) -option_7 = StrOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal'}), name='follower2', doc='follower2', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_6, notraisepropertyerror=False, todict=False)), kwargs={}))) -option_8 = StrOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal'}), name='follower3', doc='follower3', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_5, notraisepropertyerror=False, todict=False)), kwargs={}))) +option_7 = StrOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'normal'}), name='follower2', doc='follower2', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_6, notraisepropertyerror=False, todict=False)), kwargs={}))) +option_8 = StrOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'normal'}), name='follower3', doc='follower3', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_5, notraisepropertyerror=False, todict=False)), kwargs={}))) option_4 = Leadership(name='leader', doc='leader', properties=frozenset({'normal'}), children=[option_5, option_6, option_7, option_8]) option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3, option_4]) option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2]) diff --git a/tests/flattener_dicos/10leadership_autoleader/tiramisu/base.py b/tests/flattener_dicos/10leadership_autoleader/tiramisu/base.py index 8c83821c..b8c12fbb 100644 --- a/tests/flattener_dicos/10leadership_autoleader/tiramisu/base.py +++ b/tests/flattener_dicos/10leadership_autoleader/tiramisu/base.py @@ -5,7 +5,7 @@ func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='non', values=('oui', 'non')) option_5 = StrOption(name='leader', doc='leader', multi=True) option_6 = StrOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal'}), name='follower1', doc='follower1', multi=True, default=Calculation(func.calc_val, Params((), kwargs={'valeur': ParamValue("valfill")}))) -option_7 = StrOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal'}), name='follower2', doc='follower2', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_5, notraisepropertyerror=False, todict=False)), kwargs={}))) +option_7 = StrOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'normal'}), name='follower2', doc='follower2', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_5, notraisepropertyerror=False, todict=False)), kwargs={}))) option_4 = Leadership(name='leader', doc='leader', properties=frozenset({'normal'}), children=[option_5, option_6, option_7]) option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3, option_4]) option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2]) diff --git a/tests/flattener_dicos/10leadership_autosaveexpert/tiramisu/base.py b/tests/flattener_dicos/10leadership_autosaveexpert/tiramisu/base.py index 9921b16e..902d56e0 100644 --- a/tests/flattener_dicos/10leadership_autosaveexpert/tiramisu/base.py +++ b/tests/flattener_dicos/10leadership_autosaveexpert/tiramisu/base.py @@ -5,7 +5,7 @@ func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='non', values=('oui', 'non')) option_5 = StrOption(name='leader', doc='leader', multi=True) option_6 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='follower1', doc='follower1', multi=True, default=Calculation(func.calc_val, Params((), kwargs={'valeur': ParamValue("valfill")}))) -option_7 = StrOption(properties=frozenset({'expert', 'mandatory'}), name='follower2', doc='follower2', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_6, notraisepropertyerror=False, todict=False)), kwargs={}))) +option_7 = StrOption(properties=frozenset({'expert'}), name='follower2', doc='follower2', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_6, notraisepropertyerror=False, todict=False)), kwargs={}))) option_4 = Leadership(name='leader', doc='leader', properties=frozenset({'normal'}), children=[option_5, option_6, option_7]) option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3, option_4]) option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2]) diff --git a/tests/flattener_dicos/10leadership_familyaccent/tiramisu/base.py b/tests/flattener_dicos/10leadership_familyaccent/tiramisu/base.py index 042a4e16..e2974971 100644 --- a/tests/flattener_dicos/10leadership_familyaccent/tiramisu/base.py +++ b/tests/flattener_dicos/10leadership_familyaccent/tiramisu/base.py @@ -5,7 +5,7 @@ func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='non', values=('oui', 'non')) option_5 = StrOption(name='leader', doc='leader', multi=True) option_6 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='follower1', doc='follower1', multi=True, default=Calculation(func.calc_val, Params((), kwargs={'valeur': ParamValue("valfill")}))) -option_7 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='follower2', doc='follower2', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_6, notraisepropertyerror=False, todict=False)), kwargs={}))) +option_7 = StrOption(properties=frozenset({'normal'}), name='follower2', doc='follower2', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_6, notraisepropertyerror=False, todict=False)), kwargs={}))) option_4 = Leadership(name='leader', doc='leader', properties=frozenset({'normal'}), children=[option_5, option_6, option_7]) option_2 = OptionDescription(name='general', doc='Général', properties=frozenset({'normal'}), children=[option_3, option_4]) option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2]) diff --git a/tests/flattener_dicos/10leadership_leadermandatory/tiramisu/base.py b/tests/flattener_dicos/10leadership_leadermandatory/tiramisu/base.py index 7a6a493f..9aecedf3 100644 --- a/tests/flattener_dicos/10leadership_leadermandatory/tiramisu/base.py +++ b/tests/flattener_dicos/10leadership_leadermandatory/tiramisu/base.py @@ -4,8 +4,8 @@ import imp func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='non', values=('oui', 'non')) option_5 = StrOption(properties=frozenset({'mandatory'}), name='leader', doc='leader', multi=True) -option_6 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='follower1', doc='follower1', multi=True, default=Calculation(func.calc_val, Params((), kwargs={'valeur': ParamValue("valfill")}))) -option_7 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='follower2', doc='follower2', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_6, notraisepropertyerror=False, todict=False)), kwargs={}))) +option_6 = StrOption(properties=frozenset({'basic', 'mandatory'}), name='follower1', doc='follower1', multi=True, default=Calculation(func.calc_val, Params((), kwargs={'valeur': ParamValue("valfill")}))) +option_7 = StrOption(properties=frozenset({'normal'}), name='follower2', doc='follower2', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_6, notraisepropertyerror=False, todict=False)), kwargs={}))) option_4 = Leadership(name='leader', doc='leader', properties=frozenset({'basic'}), children=[option_5, option_6, option_7]) option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'basic'}), children=[option_3, option_4]) option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2]) diff --git a/tests/flattener_dicos/10leadership_mandatory/tiramisu/base.py b/tests/flattener_dicos/10leadership_mandatory/tiramisu/base.py index 6784aa3d..74d1555f 100644 --- a/tests/flattener_dicos/10leadership_mandatory/tiramisu/base.py +++ b/tests/flattener_dicos/10leadership_mandatory/tiramisu/base.py @@ -5,7 +5,7 @@ func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py') option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='non', values=('oui', 'non')) option_5 = StrOption(name='leader', doc='leader', multi=True) option_6 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='follower1', doc='follower1', multi=True, default=Calculation(func.calc_val, Params((), kwargs={'valeur': ParamValue("valfill")}))) -option_7 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='follower2', doc='follower2', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_6, notraisepropertyerror=False, todict=False)), kwargs={}))) +option_7 = StrOption(properties=frozenset({'normal'}), name='follower2', doc='follower2', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_6, notraisepropertyerror=False, todict=False)), kwargs={}))) option_4 = Leadership(name='leader', doc='leader', properties=frozenset({'normal'}), children=[option_5, option_6, option_7]) option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3, option_4]) option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2]) diff --git a/tests/flattener_dicos/10leadership_multi/tiramisu/base.py b/tests/flattener_dicos/10leadership_multi/tiramisu/base.py index 132a14b0..7e92cabd 100644 --- a/tests/flattener_dicos/10leadership_multi/tiramisu/base.py +++ b/tests/flattener_dicos/10leadership_multi/tiramisu/base.py @@ -6,7 +6,7 @@ option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mod option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3]) option_6 = StrOption(name='leader', doc='leader', multi=True) option_7 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='follower1', doc='follower1', multi=True, default=Calculation(func.calc_val, Params((), kwargs={'valeur': ParamValue("valfill")}))) -option_8 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='follower2', doc='follower2', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_7, notraisepropertyerror=False, todict=False)), kwargs={}))) +option_8 = StrOption(properties=frozenset({'normal'}), name='follower2', doc='follower2', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_7, notraisepropertyerror=False, todict=False)), kwargs={}))) option_5 = Leadership(name='leader', doc='leader', properties=frozenset({'normal'}), children=[option_6, option_7, option_8]) option_10 = StrOption(name='leader1', doc='leader', multi=True) option_11 = StrOption(properties=frozenset({'normal'}), name='follower11', doc='follower1', multi=True) diff --git a/tests/flattener_dicos/10load_leadership/tiramisu/base.py b/tests/flattener_dicos/10load_leadership/tiramisu/base.py index 5e1492a4..3e65f494 100644 --- a/tests/flattener_dicos/10load_leadership/tiramisu/base.py +++ b/tests/flattener_dicos/10load_leadership/tiramisu/base.py @@ -6,7 +6,7 @@ option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mod option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3]) option_6 = StrOption(name='leader', doc='leader', multi=True) option_7 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='follower1', doc='follower1', multi=True, default=Calculation(func.calc_val, Params((), kwargs={'valeur': ParamValue("valfill")}))) -option_8 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='follower2', doc='follower2', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_7, notraisepropertyerror=False, todict=False)), kwargs={}))) +option_8 = StrOption(properties=frozenset({'normal'}), name='follower2', doc='follower2', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_7, notraisepropertyerror=False, todict=False)), kwargs={}))) option_5 = Leadership(name='leader', doc='leader', properties=frozenset({'normal'}), children=[option_6, option_7, option_8]) option_4 = OptionDescription(name='general1', doc='general1', properties=frozenset({'normal'}), children=[option_5]) option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2, option_4]) diff --git a/tests/flattener_dicos/10load_leadership_description/tiramisu/base.py b/tests/flattener_dicos/10load_leadership_description/tiramisu/base.py index 0504ad75..a7a108bb 100644 --- a/tests/flattener_dicos/10load_leadership_description/tiramisu/base.py +++ b/tests/flattener_dicos/10load_leadership_description/tiramisu/base.py @@ -6,7 +6,7 @@ option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mod option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3]) option_6 = StrOption(name='leader', doc='leader', multi=True) option_7 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='follower1', doc='follower1', multi=True, default=Calculation(func.calc_val, Params((), kwargs={'valeur': ParamValue("valfill")}))) -option_8 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='follower2', doc='follower2', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_7, notraisepropertyerror=False, todict=False)), kwargs={}))) +option_8 = StrOption(properties=frozenset({'normal'}), name='follower2', doc='follower2', multi=True, default=Calculation(func.calc_val, Params((ParamOption(option_7, notraisepropertyerror=False, todict=False)), kwargs={}))) option_5 = Leadership(name='leader', doc='other description', properties=frozenset({'normal'}), children=[option_6, option_7, option_8]) option_4 = OptionDescription(name='general1', doc='general1', properties=frozenset({'normal'}), children=[option_5]) option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2, option_4]) diff --git a/tests/flattener_dicos/10load_leadership_submulti/tiramisu/base.py b/tests/flattener_dicos/10load_leadership_submulti/tiramisu/base.py index e72e3459..198cf443 100644 --- a/tests/flattener_dicos/10load_leadership_submulti/tiramisu/base.py +++ b/tests/flattener_dicos/10load_leadership_submulti/tiramisu/base.py @@ -6,7 +6,7 @@ option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mod option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3]) option_6 = StrOption(name='leader', doc='leader', multi=True) option_7 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='follower1', doc='follower1', multi=True, default=Calculation(func.calc_val, Params((), kwargs={'valeur': ParamValue("valfill")}))) -option_8 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='follower2', doc='follower2', multi=submulti, default=Calculation(func.calc_val, Params((ParamOption(option_7, notraisepropertyerror=False, todict=False)), kwargs={})), default_multi=[]) +option_8 = StrOption(properties=frozenset({'normal'}), name='follower2', doc='follower2', multi=submulti, default=Calculation(func.calc_val, Params((ParamOption(option_7, notraisepropertyerror=False, todict=False)), kwargs={})), default_multi=[]) option_5 = Leadership(name='leader', doc='leader', properties=frozenset({'normal'}), children=[option_6, option_7, option_8]) option_4 = OptionDescription(name='general1', doc='general1', properties=frozenset({'normal'}), children=[option_5]) option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2, option_4]) diff --git a/tests/flattener_dicos/20family_dynamic_calc/tiramisu/base.py b/tests/flattener_dicos/20family_dynamic_calc/tiramisu/base.py index da389eaf..5f7e13a9 100644 --- a/tests/flattener_dicos/20family_dynamic_calc/tiramisu/base.py +++ b/tests/flattener_dicos/20family_dynamic_calc/tiramisu/base.py @@ -6,7 +6,7 @@ option_3 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='varnam option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3]) option_5 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='vardyn', doc='No change', multi=False, default='val') option_4 = ConvertDynOptionDescription(name='dyn', doc='dyn', suffixes=Calculation(func.calc_value, Params((ParamOption(option_3)))), properties=frozenset({'normal'}), children=[option_5]) -option_7 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='newvar', doc='No change', multi=False, default=Calculation(func.calc_val, Params((ParamDynOption(option_5, 'val1', option_4, notraisepropertyerror=False, todict=False)), kwargs={}))) +option_7 = StrOption(properties=frozenset({'normal'}), name='newvar', doc='No change', multi=False, default=Calculation(func.calc_val, Params((ParamDynOption(option_5, 'val1', option_4, notraisepropertyerror=False, todict=False)), kwargs={}))) option_6 = OptionDescription(name='new', doc='new', properties=frozenset({'normal'}), children=[option_7]) option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2, option_4, option_6]) option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1]) diff --git a/tests/flattener_dicos/20family_dynamic_number/tiramisu/base.py b/tests/flattener_dicos/20family_dynamic_number/tiramisu/base.py index 05bb4080..0f461578 100644 --- a/tests/flattener_dicos/20family_dynamic_number/tiramisu/base.py +++ b/tests/flattener_dicos/20family_dynamic_number/tiramisu/base.py @@ -6,7 +6,7 @@ option_3 = IntOption(properties=frozenset({'mandatory', 'normal'}), name='varnam option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3]) option_5 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='vardyn', doc='No change', multi=False, default='val') option_4 = ConvertDynOptionDescription(name='dyn', doc='dyn', suffixes=Calculation(func.calc_value, Params((ParamOption(option_3)))), properties=frozenset({'normal'}), children=[option_5]) -option_7 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='newvar', doc='No change', multi=False, default=Calculation(func.calc_val, Params((ParamDynOption(option_5, '1', option_4, notraisepropertyerror=False, todict=False)), kwargs={}))) +option_7 = StrOption(properties=frozenset({'normal'}), name='newvar', doc='No change', multi=False, default=Calculation(func.calc_val, Params((ParamDynOption(option_5, '1', option_4, notraisepropertyerror=False, todict=False)), kwargs={}))) option_6 = OptionDescription(name='new', doc='new', properties=frozenset({'normal'}), children=[option_7]) option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2, option_4, option_6]) option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])