diff --git a/tests/dictionaries/80unknown_type/errno_36 b/FIXME similarity index 100% rename from tests/dictionaries/80unknown_type/errno_36 rename to FIXME diff --git a/src/rougail/annotator/constrainte.py b/src/rougail/annotator/constrainte.py index 921918b5..4a62c9e2 100644 --- a/src/rougail/annotator/constrainte.py +++ b/src/rougail/annotator/constrainte.py @@ -44,15 +44,15 @@ class ConstrainteAnnotator: objectspace, eosfunc_file, ): - if not hasattr(objectspace.space, 'constraints'): - return self.objectspace = objectspace eosfunc = SourceFileLoader('eosfunc', eosfunc_file).load_module() self.functions = dir(eosfunc) self.functions.extend(INTERNAL_FUNCTIONS) self.valid_enums = {} - - self.convert_auto_freeze() + if hasattr(objectspace.space, 'variables'): + self.convert_auto_freeze() + if not hasattr(objectspace.space, 'constraints'): + return if hasattr(self.objectspace.space.constraints, 'check'): self.check_check() self.check_valid_enum() @@ -73,15 +73,15 @@ class ConstrainteAnnotator: """convert auto_freeze only if FREEZE_AUTOFREEZE_VARIABLE == 'oui' this variable is frozen """ - def _convert_auto_freeze(variable, namespace): + def _convert_auto_freeze(variable): if variable.auto_freeze: - if namespace != Config['variable_namespace']: + if variable.namespace != Config['variable_namespace']: xmlfiles = self.objectspace.display_xmlfiles(variable.xmlfiles) - msg = _(f'auto_freeze is not allowed in extra "{namespace}" in {xmlfiles}') + msg = _(f'auto_freeze is not allowed in extra "{variable.namespace}" in {xmlfiles}') raise DictConsistencyError(msg, 49) new_condition = self.objectspace.condition(variable.xmlfiles) new_condition.name = 'auto_frozen_if_not_in' - new_condition.namespace = namespace + new_condition.namespace = variable.namespace new_condition.source = FREEZE_AUTOFREEZE_VARIABLE new_param = self.objectspace.param(variable.xmlfiles) new_param.text = 'oui' @@ -90,25 +90,21 @@ class ConstrainteAnnotator: new_target.type = 'variable' new_target.name = variable.name new_condition.target = [new_target] + if not hasattr(self.objectspace.space, 'constraints'): + self.objectspace.space.constraints = self.objectspace.constraints(variable.xmlfiles) if not hasattr(self.objectspace.space.constraints, 'condition'): self.objectspace.space.constraints.condition = [] self.objectspace.space.constraints.condition.append(new_condition) for variables in self.objectspace.space.variables.values(): - if not hasattr(variables, 'family'): - continue for family in variables.family.values(): if not hasattr(family, 'variable'): continue for variable in family.variable.values(): if isinstance(variable, self.objectspace.leadership): for follower in variable.variable: - _convert_auto_freeze(follower, - variables.namespace, - ) + _convert_auto_freeze(follower) else: - _convert_auto_freeze(variable, - variables.namespace, - ) + _convert_auto_freeze(variable) def check_check(self): """valid and manage diff --git a/src/rougail/annotator/property.py b/src/rougail/annotator/property.py index 88b1e61b..bfdceb73 100644 --- a/src/rougail/annotator/property.py +++ b/src/rougail/annotator/property.py @@ -54,13 +54,8 @@ class PropertyAnnotator: if not isinstance(service, self.objectspace.family): continue self.convert_property(service) - if not hasattr(service, 'family'): - continue - self.convert_property(service) for family in service.family: self.convert_property(family) - if not hasattr(family, 'variable'): - continue for variable in family.variable: self.convert_property(variable) @@ -68,16 +63,11 @@ class PropertyAnnotator: """convert variables """ for variables in self.objectspace.space.variables.values(): - if not hasattr(variables, 'family'): - continue for family in variables.family.values(): self.convert_property(family) - if not hasattr(family, 'variable'): - continue for variable in family.variable.values(): - if isinstance(variable, self.objectspace.leadership): - self.convert_property(variable) - for follower in variable.variable: - self.convert_property(follower) - else: - self.convert_property(variable) + self.convert_property(variable) + if not isinstance(variable, self.objectspace.leadership): + continue + for follower in variable.variable: + self.convert_property(follower) diff --git a/src/rougail/annotator/service.py b/src/rougail/annotator/service.py index d99fd279..588afa3e 100644 --- a/src/rougail/annotator/service.py +++ b/src/rougail/annotator/service.py @@ -7,7 +7,7 @@ from ..error import DictConsistencyError # that shall not be present in the exported (flatened) XML ERASED_ATTRIBUTES = ('redefine', 'exists', 'fallback', 'optional', 'remove_check', 'namespace', 'remove_condition', 'path', 'instance_mode', 'index', 'is_in_leadership', - 'level', 'remove_fill', 'xmlfiles') + 'level', 'remove_fill', 'xmlfiles', 'type') KEY_TYPE = {'variable': 'symlink', diff --git a/src/rougail/annotator/variable.py b/src/rougail/annotator/variable.py index 3e75a6a9..d490276d 100644 --- a/src/rougail/annotator/variable.py +++ b/src/rougail/annotator/variable.py @@ -37,11 +37,9 @@ CONVERT_OPTION = {'number': dict(opttype="IntOption", func=int), } -FORCE_CHOICE = {'oui/non': ['oui', 'non'], - 'on/off': ['on', 'off'], - 'yes/no': ['yes', 'no'], - 'schedule': ['none', 'daily', 'weekly', 'monthly'], - 'schedulemod': ['pre', 'post']} +FORCE_CHOICE = {'schedule': ['none', 'daily', 'weekly', 'monthly'], + 'schedulemod': ['pre', 'post'], + } RENAME_ATTIBUTES = {'description': 'doc'} @@ -63,8 +61,6 @@ class VariableAnnotator: variable, variable_type: str, ) -> None: - 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'): @@ -83,7 +79,6 @@ class VariableAnnotator: self._convert_valid_enum(namespace, variable, ) - self._valid_type(variable) def _convert_valid_enum(self, namespace, @@ -111,20 +106,10 @@ class VariableAnnotator: self.objectspace.space.constraints.check.append(check) variable.type = 'string' - def _valid_type(self, - variable - ) -> None: - if variable.type not in CONVERT_OPTION: - xmlf = self.objectspace.display_xmlfiles(variable.xmlfiles) - msg = _(f'unvalid type "{variable.type}" for variable "{variable.name}" in {xmlf}') - raise DictConsistencyError(msg, 36) - def convert_variable(self): """convert variable """ for families in self.objectspace.space.variables.values(): - if not hasattr(families, 'family'): - continue families.doc = families.name for family in families.family.values(): family.doc = family.name diff --git a/src/rougail/data/rougail.dtd b/src/rougail/data/rougail.dtd index 9985dc55..aa9cbe68 100644 --- a/src/rougail/data/rougail.dtd +++ b/src/rougail/data/rougail.dtd @@ -90,7 +90,7 @@ - + diff --git a/src/rougail/tiramisureflector.py b/src/rougail/tiramisureflector.py index be6f161b..aef03d03 100644 --- a/src/rougail/tiramisureflector.py +++ b/src/rougail/tiramisureflector.py @@ -266,7 +266,6 @@ class Variable(Common): ) self.is_follower = is_follower convert_option = CONVERT_OPTION[elt.type] - del elt.type self.object_type = convert_option['opttype'] self.attrib.update(convert_option.get('initkwargs', {})) if self.object_type != 'SymLinkOption': diff --git a/tests/dictionaries/00load_autofreeze/00-base.xml b/tests/dictionaries/00load_autofreeze/00-base.xml index aefd954e..fd503179 100644 --- a/tests/dictionaries/00load_autofreeze/00-base.xml +++ b/tests/dictionaries/00load_autofreeze/00-base.xml @@ -2,10 +2,10 @@ - + non - + non diff --git a/tests/dictionaries/00load_autofreeze/tiramisu/base.py b/tests/dictionaries/00load_autofreeze/tiramisu/base.py index f54bce7f..8e2f715b 100644 --- a/tests/dictionaries/00load_autofreeze/tiramisu/base.py +++ b/tests/dictionaries/00load_autofreeze/tiramisu/base.py @@ -8,8 +8,8 @@ try: except: from tiramisu import * from rougail.tiramisu import ConvertDynOptionDescription -option_4 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='module_instancie', doc='No change', multi=False, default='non', values=('oui', 'non')) -option_3 = ChoiceOption(properties=frozenset({'auto_freeze', 'basic', 'force_store_value', 'mandatory', Calculation(calc_value, Params(ParamValue('auto_frozen'), kwargs={'condition': ParamOption(option_4, todict=True), 'expected': ParamValue('oui'), 'reverse_condition': ParamValue(True)}))}), name='mode_conteneur_actif', doc='No change', multi=False, default='non', values=('oui', 'non')) +option_4 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='module_instancie', doc='No change', multi=False, default='non') +option_3 = StrOption(properties=frozenset({'auto_freeze', 'basic', 'force_store_value', 'mandatory', Calculation(calc_value, Params(ParamValue('auto_frozen'), kwargs={'condition': ParamOption(option_4, todict=True), 'expected': ParamValue('oui'), 'reverse_condition': ParamValue(True)}))}), name='mode_conteneur_actif', doc='No change', multi=False, default='non') option_2 = OptionDescription(name='general', doc='général', properties=frozenset({'basic'}), 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/dictionaries/00load_autofreezeexpert/00-base.xml b/tests/dictionaries/00load_autofreezeexpert/00-base.xml index 2c66f0dc..f344cdef 100644 --- a/tests/dictionaries/00load_autofreezeexpert/00-base.xml +++ b/tests/dictionaries/00load_autofreezeexpert/00-base.xml @@ -2,10 +2,10 @@ - + non - + non diff --git a/tests/dictionaries/00load_autofreezeexpert/tiramisu/base.py b/tests/dictionaries/00load_autofreezeexpert/tiramisu/base.py index 34cd6727..f01b4ad9 100644 --- a/tests/dictionaries/00load_autofreezeexpert/tiramisu/base.py +++ b/tests/dictionaries/00load_autofreezeexpert/tiramisu/base.py @@ -8,8 +8,8 @@ try: except: from tiramisu import * from rougail.tiramisu import ConvertDynOptionDescription -option_4 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='module_instancie', doc='No change', multi=False, default='non', values=('oui', 'non')) -option_3 = ChoiceOption(properties=frozenset({'auto_freeze', 'expert', 'force_store_value', 'mandatory', Calculation(calc_value, Params(ParamValue('auto_frozen'), kwargs={'condition': ParamOption(option_4, todict=True), 'expected': ParamValue('oui'), 'reverse_condition': ParamValue(True)}))}), name='mode_conteneur_actif', doc='No change', multi=False, default='non', values=('oui', 'non')) +option_4 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='module_instancie', doc='No change', multi=False, default='non') +option_3 = StrOption(properties=frozenset({'auto_freeze', 'expert', 'force_store_value', 'mandatory', Calculation(calc_value, Params(ParamValue('auto_frozen'), kwargs={'condition': ParamOption(option_4, todict=True), 'expected': ParamValue('oui'), 'reverse_condition': ParamValue(True)}))}), name='mode_conteneur_actif', doc='No change', multi=False, default='non') 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]) option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1]) diff --git a/tests/dictionaries/00load_autosave/00-base.xml b/tests/dictionaries/00load_autosave/00-base.xml index 8825e85b..8be2a32d 100644 --- a/tests/dictionaries/00load_autosave/00-base.xml +++ b/tests/dictionaries/00load_autosave/00-base.xml @@ -2,7 +2,7 @@ - + non diff --git a/tests/dictionaries/00load_autosave/tiramisu/base.py b/tests/dictionaries/00load_autosave/tiramisu/base.py index 0353b8dd..fd39dd72 100644 --- a/tests/dictionaries/00load_autosave/tiramisu/base.py +++ b/tests/dictionaries/00load_autosave/tiramisu/base.py @@ -8,7 +8,7 @@ try: except: from tiramisu import * from rougail.tiramisu import ConvertDynOptionDescription -option_3 = ChoiceOption(properties=frozenset({'basic', 'force_store_value', 'mandatory'}), name='mode_conteneur_actif', doc='No change', multi=False, default='non', values=('oui', 'non')) +option_3 = StrOption(properties=frozenset({'basic', 'force_store_value', 'mandatory'}), name='mode_conteneur_actif', doc='No change', multi=False, default='non') option_2 = OptionDescription(name='general', doc='général', properties=frozenset({'basic'}), children=[option_3]) option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2]) option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1]) diff --git a/tests/dictionaries/00load_autosaveexpert/00-base.xml b/tests/dictionaries/00load_autosaveexpert/00-base.xml index 7fa79f58..0ed16b71 100644 --- a/tests/dictionaries/00load_autosaveexpert/00-base.xml +++ b/tests/dictionaries/00load_autosaveexpert/00-base.xml @@ -2,7 +2,7 @@ - + non diff --git a/tests/dictionaries/00load_autosaveexpert/tiramisu/base.py b/tests/dictionaries/00load_autosaveexpert/tiramisu/base.py index a2270173..0e5f43a9 100644 --- a/tests/dictionaries/00load_autosaveexpert/tiramisu/base.py +++ b/tests/dictionaries/00load_autosaveexpert/tiramisu/base.py @@ -8,7 +8,7 @@ try: except: from tiramisu import * from rougail.tiramisu import ConvertDynOptionDescription -option_3 = ChoiceOption(properties=frozenset({'expert', 'force_store_value', 'mandatory'}), name='mode_conteneur_actif', doc='No change', multi=False, default='non', values=('oui', 'non')) +option_3 = StrOption(properties=frozenset({'expert', 'force_store_value', 'mandatory'}), name='mode_conteneur_actif', doc='No change', multi=False, default='non') option_2 = OptionDescription(name='general', doc='général', properties=frozenset({'expert'}), children=[option_3]) option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2]) option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1]) diff --git a/tests/dictionaries/00load_comment/00-base.xml b/tests/dictionaries/00load_comment/00-base.xml index a5e543fe..3b468b1f 100644 --- a/tests/dictionaries/00load_comment/00-base.xml +++ b/tests/dictionaries/00load_comment/00-base.xml @@ -3,7 +3,7 @@ - diff --git a/tests/dictionaries/00load_comment/tiramisu/base.py b/tests/dictionaries/00load_comment/tiramisu/base.py index 1706e7d2..e7b834cb 100644 --- a/tests/dictionaries/00load_comment/tiramisu/base.py +++ b/tests/dictionaries/00load_comment/tiramisu/base.py @@ -8,7 +8,7 @@ try: except: from tiramisu import * from rougail.tiramisu import ConvertDynOptionDescription -option_3 = ChoiceOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='non', values=('oui', 'non')) +option_3 = StrOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='non') option_2 = OptionDescription(name='general', doc='général', properties=frozenset({'normal'}), children=[option_3]) option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2]) option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1]) diff --git a/tests/dictionaries/00load_notype/00-base.xml b/tests/dictionaries/00load_notype/00-base.xml index aac6f7fe..05d4be90 100644 --- a/tests/dictionaries/00load_notype/00-base.xml +++ b/tests/dictionaries/00load_notype/00-base.xml @@ -2,7 +2,7 @@ -