diff --git a/doc/dev/config.md b/doc/dev/config.md index 7c804f88..5e1210f8 100644 --- a/doc/dev/config.md +++ b/doc/dev/config.md @@ -73,3 +73,22 @@ Le répertoire de destination des fichiers générés est géré dans la clef "d ## La variable auto_freeze La propriété auto_freeze n'est appliqué que une variable spécifique passe à True. Par défaut le nom de la variable est "instancied_module", mais il est possible de changer le nom de cette variable via la clef "auto_freeze_variable". + +## Les modes + +Les modes sont personnalisables dans Rougail. Par défaut les modes sont "basic", "normal" et "expert". +Il est possible de changer cette liste via la clef "modes_level". + +Si vous changer ces valeurs, penser à changer les modes par défaut des familles et des variables. + +## Le mode par défaut pour une famille + +Le mode par défaut d'une famille est "basic". Il est possible de changer le mode par défaut d'une famille via la clef "default_family_mode". + +## Le mode par défaut pour une variable + +Le mode par défaut d'une variable est "normal". Il est possible de changer le mode par défaut d'une variable via la clef "default_variable_mode". + +## Le nom des fonctions internes + +Il est possible d'ajouter des fonctions interne via la clef "internal_functions". diff --git a/doc/mode.md b/doc/mode.md index 66bc294e..21d928d0 100644 --- a/doc/mode.md +++ b/doc/mode.md @@ -1,8 +1,10 @@ Mode ==== -Il existe trois "mode" dans Rougail : +Par défault, il existe trois "mode" dans Rougail : - basic : variables indispensables à la mise en place d'un service - normal : variables couramment modifié par l'utilisateur - expert : variables a manipuler avec précausion et en toute connaissance de cause + +Il est possible de personnaliser les modes dans la [configuration de rougail](dev/config.md) diff --git a/src/rougail/__init__.py b/src/rougail/__init__.py index ccad5b9a..a36f3a94 100644 --- a/src/rougail/__init__.py +++ b/src/rougail/__init__.py @@ -27,6 +27,5 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA from .convert import RougailConvert from .template.systemd import RougailSystemdTemplate from .config import RougailConfig -from .annotator import modes -__ALL__ = ('RougailConvert', 'RougailSystemdTemplate', 'RougailConfig', 'modes') +__ALL__ = ('RougailConvert', 'RougailSystemdTemplate', 'RougailConfig') diff --git a/src/rougail/annotator/__init__.py b/src/rougail/annotator/__init__.py index 9b1faa68..6c1ee0c6 100644 --- a/src/rougail/annotator/__init__.py +++ b/src/rougail/annotator/__init__.py @@ -31,11 +31,11 @@ from .check import CheckAnnotator from .value import ValueAnnotator from .condition import ConditionAnnotator from .fill import FillAnnotator -from .family import FamilyAnnotator, modes +from .family import FamilyAnnotator from .property import PropertyAnnotator class SpaceAnnotator: # pylint: disable=R0903 - """Transformations applied on a CreoleObjSpace instance + """Transformations applied on a object instance """ def __init__(self, objectspace, eosfunc_file): self.objectspace = objectspace @@ -54,4 +54,4 @@ class SpaceAnnotator: # pylint: disable=R0903 PropertyAnnotator(objectspace) -__all__ = ('SpaceAnnotator', 'CONVERT_OPTION', 'modes') +__all__ = ('SpaceAnnotator', 'CONVERT_OPTION') diff --git a/src/rougail/annotator/check.py b/src/rougail/annotator/check.py index 8d497a14..00915f04 100644 --- a/src/rougail/annotator/check.py +++ b/src/rougail/annotator/check.py @@ -50,6 +50,7 @@ class CheckAnnotator(TargetAnnotator, ParamAnnotator): self.only_variable = True self.functions = dir(load_modules(eosfunc_file)) self.functions.extend(INTERNAL_FUNCTIONS) + self.functions.extend(self.objectspace.rougailconfig['internal_functions']) self.target_is_uniq = False self.convert_target(self.objectspace.space.constraints.check) self.convert_param(self.objectspace.space.constraints.check) diff --git a/src/rougail/annotator/condition.py b/src/rougail/annotator/condition.py index 4c7ba92c..8272705a 100644 --- a/src/rougail/annotator/condition.py +++ b/src/rougail/annotator/condition.py @@ -72,13 +72,16 @@ class ConditionAnnotator(TargetAnnotator, ParamAnnotator, Walk): only if auto_freeze_variable is True this variable is frozen """ for variable in self.get_variables(): - if not variable.auto_freeze: + if not variable.auto_freeze and not variable.auto_save: continue if variable.namespace != self.objectspace.rougailconfig['variable_namespace']: msg = _(f'auto_freeze is not allowed in extra "{variable.namespace}"') raise DictConsistencyError(msg, 49, variable.xmlfiles) new_condition = self.objectspace.condition(variable.xmlfiles) - new_condition.name = 'auto_frozen_if_not_in' + if variable.auto_freeze: + new_condition.name = 'auto_frozen_if_not_in' + else: + new_condition.name = 'auto_saved_if_not_in' new_condition.namespace = variable.namespace new_condition.source = self.objectspace.rougailconfig['auto_freeze_variable'] new_param = self.objectspace.param(variable.xmlfiles) @@ -147,7 +150,9 @@ class ConditionAnnotator(TargetAnnotator, ParamAnnotator, Walk): if condition_name.startswith('hidden_if_'): return ['hidden', 'frozen', 'force_default_on_freeze'] if condition_name == 'auto_frozen_if_not_in': - return ['auto_frozen'] + return ['force_store_value', 'frozen'] + if condition_name == 'auto_saved_if_not_in': + return ['force_store_value'] return [condition_name.split('_', 1)[0]] def _get_family_variables_from_target(self, diff --git a/src/rougail/annotator/family.py b/src/rougail/annotator/family.py index eec0c4ff..da3c4421 100644 --- a/src/rougail/annotator/family.py +++ b/src/rougail/annotator/family.py @@ -30,18 +30,12 @@ from ..utils import normalize_family from .variable import Walk -#mode order is important -modes_level = ('basic', 'normal', 'expert') - - class Mode: # pylint: disable=R0903 """Class to manage mode level """ def __init__(self, - name: str, level: int, ) -> None: - self.name = name self.level = level def __gt__(self, @@ -50,9 +44,6 @@ class Mode: # pylint: disable=R0903 return other.level < self.level -modes = {name: Mode(name, idx) for idx, name in enumerate(modes_level)} - - class FamilyAnnotator(Walk): """Annotate family """ @@ -62,6 +53,7 @@ class FamilyAnnotator(Walk): self.objectspace = objectspace if not hasattr(self.objectspace.space, 'variables'): return + self.modes = {name: Mode(idx) for idx, name in enumerate(self.objectspace.rougailconfig['modes_level'])} self.remove_empty_families() self.family_names() self.change_modes() @@ -104,13 +96,34 @@ class FamilyAnnotator(Walk): def change_modes(self): """change the mode of variables """ + modes_level = self.objectspace.rougailconfig['modes_level'] + default_variable_mode = self.objectspace.rougailconfig['default_variable_mode'] + if default_variable_mode not in modes_level: + msg = _(f'default variable mode "{default_variable_mode}" is not a valid mode, ' + f'valid modes are {modes_level}') + raise DictConsistencyError(msg, 72, None) + default_family_mode = self.objectspace.rougailconfig['default_family_mode'] + if default_family_mode not in modes_level: + msg = _(f'default family mode "{default_family_mode}" is not a valid mode, ' + f'valid modes are {modes_level}') + raise DictConsistencyError(msg, 73, None) families = list(self.get_families()) for family in families: + self.valid_mode(family) self._set_default_mode(family) families.reverse() for family in families: self._change_family_mode(family) + def valid_mode(self, + obj, + ) -> None: + modes_level = self.objectspace.rougailconfig['modes_level'] + if hasattr(obj, 'mode') and obj.mode not in modes_level: + msg = _(f'mode "{obj.mode}" for "{obj.name}" is not a valid mode, ' + f'valid modes are {modes_level}') + raise DictConsistencyError(msg, 71, obj.xmlfiles) + def _set_default_mode(self, family: 'self.objectspace.family', ) -> None: @@ -121,6 +134,7 @@ class FamilyAnnotator(Walk): if not hasattr(family, 'variable'): return for variable in family.variable.values(): + self.valid_mode(variable) if isinstance(variable, self.objectspace.family): if family_mode and not self._has_mode(variable): self._set_auto_mode(variable, family_mode) @@ -143,13 +157,13 @@ class FamilyAnnotator(Walk): # if its mode is not defined by the user if not self._has_mode(variable) and \ (variable.auto_save is True or variable.auto_freeze is True): - self._set_auto_mode(variable, modes_level[0]) + variable.mode = self.objectspace.rougailconfig['modes_level'][0] # mandatory variable without value is a basic variable elif not self._has_mode(variable) and \ variable.mandatory is True and \ not hasattr(variable, 'default') and \ not hasattr(variable, 'default_multi'): - self._set_auto_mode(variable, modes_level[0]) + variable.mode = self.objectspace.rougailconfig['modes_level'][0] elif family_mode and not self._has_mode(variable): self._set_auto_mode(variable, family_mode) @@ -164,6 +178,7 @@ class FamilyAnnotator(Walk): ) -> None: leader_mode = None for follower in leadership.variable: + self.valid_mode(follower) if follower.auto_save is True: msg = _(f'leader/followers "{follower.name}" could not be auto_save') raise DictConsistencyError(msg, 29, leadership.xmlfiles) @@ -171,14 +186,18 @@ class FamilyAnnotator(Walk): msg = f'leader/followers "{follower.name}" could not be auto_freeze' raise DictConsistencyError(_(msg), 30, leadership.xmlfiles) if leader_mode is not None: - if modes[leader_mode] > modes[follower.mode]: + if hasattr(follower, 'mode'): + follower_mode = follower.mode + else: + follower_mode = self.objectspace.rougailconfig['default_variable_mode'] + if self.modes[leader_mode] > self.modes[follower_mode]: if self._has_mode(follower) and not self._has_mode(leadership.variable[0]): # if follower has mode but not the leader - self._set_auto_mode(leadership.variable[0], follower.mode) + self._set_auto_mode(leadership.variable[0], follower_mode) else: # leader's mode is minimum level if self._has_mode(follower): - msg = _(f'the follower "{follower.name}" is in "{follower.mode}" mode ' + msg = _(f'the follower "{follower.name}" is in "{follower_mode}" mode ' f'but leader have the higher mode "{leader_mode}"') raise DictConsistencyError(msg, 63, follower.xmlfiles) self._set_auto_mode(follower, leader_mode) @@ -186,8 +205,13 @@ class FamilyAnnotator(Walk): family_mode, ) if leader_mode is None: - leader_mode = leadership.variable[0].mode - self._set_auto_mode(leadership, leadership.variable[0].mode) + if hasattr(leadership.variable[0], 'mode'): + leader_mode = leadership.variable[0].mode + else: + leader_mode = self.objectspace.rougailconfig['default_variable_mode'] + if hasattr(leadership.variable[0], 'mode'): + leader_mode = leadership.variable[0].mode + self._set_auto_mode(leadership, leader_mode) def _change_family_mode(self, family: 'self.objectspace.family', @@ -195,8 +219,8 @@ class FamilyAnnotator(Walk): if hasattr(family, 'mode'): family_mode = family.mode else: - family_mode = modes_level[1] - min_variable_mode = modes_level[-1] + family_mode = self.objectspace.rougailconfig['default_family_mode'] + min_variable_mode = self.objectspace.rougailconfig['modes_level'][-1] # change variable mode, but not if variables are not in a family if hasattr(family, 'variable'): for variable in family.variable.values(): @@ -208,9 +232,12 @@ class FamilyAnnotator(Walk): func(variable, family_mode, ) - if modes[min_variable_mode] > modes[variable.mode]: + elif not hasattr(variable, 'mode'): + variable.mode = self.objectspace.rougailconfig['default_family_mode'] + if self.modes[min_variable_mode] > self.modes[variable.mode]: min_variable_mode = variable.mode - if hasattr(family, 'mode') and family.mode != min_variable_mode: + if isinstance(family, self.objectspace.family) and \ + (not hasattr(family, 'mode') or family.mode != min_variable_mode): # set the lower variable mode to family if self._has_mode(family): msg = _(f'the family "{family.name}" is in "{family.mode}" mode but variables and ' @@ -222,13 +249,19 @@ class FamilyAnnotator(Walk): variable, family_mode: str, ) -> None: + if hasattr(variable, 'mode'): + variable_mode = variable.mode + else: + variable_mode = self.objectspace.rougailconfig['default_variable_mode'] # none basic variable in high level family has to be in high level - if modes[variable.mode] < modes[family_mode]: + if self.modes[variable_mode] < self.modes[family_mode]: if self._has_mode(variable): - msg = _(f'the variable "{variable.name}" is in "{variable.mode}" mode ' + msg = _(f'the variable "{variable.name}" is in "{variable_mode}" mode ' f'but family has the higher family mode "{family_mode}"') raise DictConsistencyError(msg, 61, variable.xmlfiles) self._set_auto_mode(variable, family_mode) + if not hasattr(variable, 'mode'): + variable.mode = variable_mode def _change_variable_mode_leader(self, leadership, diff --git a/src/rougail/annotator/property.py b/src/rougail/annotator/property.py index 848320ba..f81207da 100644 --- a/src/rougail/annotator/property.py +++ b/src/rougail/annotator/property.py @@ -29,11 +29,8 @@ from ..error import DictConsistencyError from .variable import Walk -PROPERTIES = ('hidden', 'frozen', 'auto_freeze', 'auto_save', 'force_default_on_freeze', +PROPERTIES = ('hidden', 'frozen', 'force_default_on_freeze', 'force_store_value', 'disabled', 'mandatory') -CONVERT_PROPERTIES = {'auto_save': ['force_store_value'], - 'auto_freeze': ['force_store_value', 'auto_freeze'], - } class PropertyAnnotator(Walk): @@ -54,7 +51,8 @@ class PropertyAnnotator(Walk): """ # hidden variable is also frozen if isinstance(variable, self.objectspace.variable) and variable.hidden is True: - variable.frozen = True + if not variable.auto_freeze: + variable.frozen = True if not variable.auto_save and \ not variable.auto_freeze and \ 'force_default_on_freeze' not in vars(variable): @@ -64,8 +62,8 @@ class PropertyAnnotator(Walk): for prop in PROPERTIES: if hasattr(variable, prop): if getattr(variable, prop) is True: - for subprop in CONVERT_PROPERTIES.get(prop, [prop]): - variable.properties.append(subprop) +# for subprop in CONVERT_PROPERTIES.get(prop, [prop]): + variable.properties.append(prop) setattr(variable, prop, None) if hasattr(variable, 'mode') and variable.mode: variable.properties.append(variable.mode) diff --git a/src/rougail/annotator/service.py b/src/rougail/annotator/service.py index e75c3170..e09260e9 100644 --- a/src/rougail/annotator/service.py +++ b/src/rougail/annotator/service.py @@ -31,7 +31,7 @@ from ..i18n import _ from ..utils import normalize_family from ..error import DictConsistencyError from ..config import RougailConfig -# a CreoleObjSpace's attribute has some annotations +# a object's attribute has some annotations # that shall not be present in the exported (flatened) XML ERASED_ATTRIBUTES = ('redefine', 'exists', 'optional', 'remove_check', 'namespace', 'remove_condition', 'path', 'instance_mode', 'index', diff --git a/src/rougail/config.py b/src/rougail/config.py index 6f8dbdd0..b9690dee 100644 --- a/src/rougail/config.py +++ b/src/rougail/config.py @@ -43,4 +43,8 @@ RougailConfig = {'dictionaries_dir': [join(ROUGAILROOT, 'dictionaries')], 'variable_namespace': 'rougail', 'auto_freeze_variable': 'instanciated_module', 'default_engine': 'creole', + 'internal_functions': [], + 'modes_level': ['basic', 'normal', 'expert'], + 'default_family_mode': 'basic', + 'default_variable_mode': 'normal', } diff --git a/src/rougail/convert.py b/src/rougail/convert.py index 2e746a6b..9d6a595c 100644 --- a/src/rougail/convert.py +++ b/src/rougail/convert.py @@ -27,12 +27,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Sample usage:: - >>> from rougail import Rougail - >>> rougail = Rougail() - >>> rougail.load_dictionaries(['/usr/share/rougail/dicos']) - >>> rougail.load_extra_dictionaries('extra1', ['/usr/share/rougail/extra1']) - >>> rougail.space_visitor('/usr/share/rougail/funcs.py') - >>> tiramisu = rougail.save() + >>> from rougail import RougailConvert + >>> rougail = RougailConvert() + >>> tiramisu = rougail.save('tiramisu.py') The Rougail diff --git a/src/rougail/data/rougail.dtd b/src/rougail/data/rougail.dtd index 8fbb6c05..ddf92e3f 100644 --- a/src/rougail/data/rougail.dtd +++ b/src/rougail/data/rougail.dtd @@ -80,7 +80,7 @@ - + @@ -97,7 +97,7 @@ - + diff --git a/src/rougail/path.py b/src/rougail/path.py index f18d055d..acfdebe1 100644 --- a/src/rougail/path.py +++ b/src/rougail/path.py @@ -30,8 +30,7 @@ from .utils import normalize_family class Path: - """Helper class to handle the `path` attribute of a CreoleObjSpace - instance. + """Helper class to handle the `path` attribute. sample: path="creole.general.condition" """ diff --git a/src/rougail/tiramisureflector.py b/src/rougail/tiramisureflector.py index 3fff6b2a..c589dfa4 100644 --- a/src/rougail/tiramisureflector.py +++ b/src/rougail/tiramisureflector.py @@ -55,7 +55,7 @@ class TiramisuReflector: ): self.index = 0 self.text = [] - if isfile(funcs_path): + if funcs_path and isfile(funcs_path): self.text.extend(["from importlib.machinery import SourceFileLoader", "from importlib.util import spec_from_loader, module_from_spec", f"loader = SourceFileLoader('func', '{funcs_path}')", diff --git a/tests/dictionaries/00load_autofreeze/tiramisu/base.py b/tests/dictionaries/00load_autofreeze/tiramisu/base.py index 43889062..d8e34b87 100644 --- a/tests/dictionaries/00load_autofreeze/tiramisu/base.py +++ b/tests/dictionaries/00load_autofreeze/tiramisu/base.py @@ -12,6 +12,6 @@ try: except: from tiramisu import * option_3 = BoolOption(name="instanciated_module", doc="instanciated_module", default=False, properties=frozenset({"mandatory", "normal"})) -option_2 = StrOption(name="myvar", doc="myvar", default="no", properties=frozenset({"auto_freeze", "force_store_value", "mandatory", "normal", Calculation(func.calc_value, Params(ParamValue('auto_frozen'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue(True), 'reverse_condition': ParamValue(True)}))})) +option_2 = StrOption(name="myvar", doc="myvar", default="no", properties=frozenset({"basic", "mandatory", Calculation(func.calc_value, Params(ParamValue('force_store_value'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue(True), 'reverse_condition': ParamValue(True)})), Calculation(func.calc_value, Params(ParamValue('frozen'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue(True), 'reverse_condition': ParamValue(True)}))})) option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2, option_3]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1]) diff --git a/tests/dictionaries/00load_autofreezeexpert/tiramisu/base.py b/tests/dictionaries/00load_autofreezeexpert/tiramisu/base.py index 85abcb29..c4dd11b4 100644 --- a/tests/dictionaries/00load_autofreezeexpert/tiramisu/base.py +++ b/tests/dictionaries/00load_autofreezeexpert/tiramisu/base.py @@ -12,6 +12,6 @@ try: except: from tiramisu import * option_3 = BoolOption(name="instanciated_module", doc="instanciated_module", default=False, properties=frozenset({"mandatory", "normal"})) -option_2 = StrOption(name="my_var", doc="my_var", default="no", properties=frozenset({"auto_freeze", "expert", "force_store_value", "mandatory", Calculation(func.calc_value, Params(ParamValue('auto_frozen'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue(True), 'reverse_condition': ParamValue(True)}))})) +option_2 = StrOption(name="my_var", doc="my_var", default="no", properties=frozenset({"expert", "mandatory", Calculation(func.calc_value, Params(ParamValue('force_store_value'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue(True), 'reverse_condition': ParamValue(True)})), Calculation(func.calc_value, Params(ParamValue('frozen'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue(True), 'reverse_condition': ParamValue(True)}))})) option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2, option_3]) 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 7a44967a..216d5cd5 100644 --- a/tests/dictionaries/00load_autosave/00-base.xml +++ b/tests/dictionaries/00load_autosave/00-base.xml @@ -1,6 +1,7 @@ + non diff --git a/tests/dictionaries/00load_autosave/makedict/base.json b/tests/dictionaries/00load_autosave/makedict/base.json index 25056378..dfcc8f87 100644 --- a/tests/dictionaries/00load_autosave/makedict/base.json +++ b/tests/dictionaries/00load_autosave/makedict/base.json @@ -1,3 +1,4 @@ { + "rougail.instanciated_module": true, "rougail.general.mode_conteneur_actif": "non" } diff --git a/tests/dictionaries/00load_autosave/tiramisu/base.py b/tests/dictionaries/00load_autosave/tiramisu/base.py index e5f8b1dc..cd1929b0 100644 --- a/tests/dictionaries/00load_autosave/tiramisu/base.py +++ b/tests/dictionaries/00load_autosave/tiramisu/base.py @@ -11,7 +11,8 @@ try: from tiramisu3 import * except: from tiramisu import * -option_3 = StrOption(name="mode_conteneur_actif", doc="No change", default="non", properties=frozenset({"basic", "force_store_value", "mandatory"})) -option_2 = OptionDescription(name="general", doc="général", children=[option_3], properties=frozenset({"basic"})) -option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2]) +option_2 = BoolOption(name="instanciated_module", doc="instanciated_module", default=True, properties=frozenset({"mandatory", "normal"})) +option_4 = StrOption(name="mode_conteneur_actif", doc="No change", default="non", properties=frozenset({"basic", "mandatory", Calculation(func.calc_value, Params(ParamValue('force_store_value'), kwargs={'condition': ParamOption(option_2, todict=True), 'expected': ParamValue(True), 'reverse_condition': ParamValue(True)}))})) +option_3 = OptionDescription(name="general", doc="général", children=[option_4], properties=frozenset({"basic"})) +option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2, option_3]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1]) diff --git a/tests/dictionaries/00load_autosaveexpert/00-base.xml b/tests/dictionaries/00load_autosaveexpert/00-base.xml index a9cd293b..66db324d 100644 --- a/tests/dictionaries/00load_autosaveexpert/00-base.xml +++ b/tests/dictionaries/00load_autosaveexpert/00-base.xml @@ -1,6 +1,7 @@ + non diff --git a/tests/dictionaries/00load_autosaveexpert/makedict/base.json b/tests/dictionaries/00load_autosaveexpert/makedict/base.json index 25056378..dfcc8f87 100644 --- a/tests/dictionaries/00load_autosaveexpert/makedict/base.json +++ b/tests/dictionaries/00load_autosaveexpert/makedict/base.json @@ -1,3 +1,4 @@ { + "rougail.instanciated_module": true, "rougail.general.mode_conteneur_actif": "non" } diff --git a/tests/dictionaries/00load_autosaveexpert/tiramisu/base.py b/tests/dictionaries/00load_autosaveexpert/tiramisu/base.py index 7e90b49c..b4cf6221 100644 --- a/tests/dictionaries/00load_autosaveexpert/tiramisu/base.py +++ b/tests/dictionaries/00load_autosaveexpert/tiramisu/base.py @@ -11,7 +11,8 @@ try: from tiramisu3 import * except: from tiramisu import * -option_3 = StrOption(name="mode_conteneur_actif", doc="No change", default="non", properties=frozenset({"expert", "force_store_value", "mandatory"})) -option_2 = OptionDescription(name="general", doc="général", children=[option_3], properties=frozenset({"expert"})) -option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2]) +option_2 = BoolOption(name="instanciated_module", doc="instanciated_module", default=True, properties=frozenset({"mandatory", "normal"})) +option_4 = StrOption(name="mode_conteneur_actif", doc="No change", default="non", properties=frozenset({"expert", "mandatory", Calculation(func.calc_value, Params(ParamValue('force_store_value'), kwargs={'condition': ParamOption(option_2, todict=True), 'expected': ParamValue(True), 'reverse_condition': ParamValue(True)}))})) +option_3 = OptionDescription(name="general", doc="général", children=[option_4], properties=frozenset({"expert"})) +option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2, option_3]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1]) diff --git a/tests/dictionaries/01auto_autofreeze/tiramisu/base.py b/tests/dictionaries/01auto_autofreeze/tiramisu/base.py index 37cd5726..47062f40 100644 --- a/tests/dictionaries/01auto_autofreeze/tiramisu/base.py +++ b/tests/dictionaries/01auto_autofreeze/tiramisu/base.py @@ -12,6 +12,6 @@ try: except: from tiramisu import * option_2 = BoolOption(name="instanciated_module", doc="instanciated_module", default=False, properties=frozenset({"mandatory", "normal"})) -option_3 = StrOption(name="my_variable", doc="my_variable", default=Calculation(func.calc_val, Params((ParamValue("yes")))), properties=frozenset({"auto_freeze", "force_store_value", "frozen", "hidden", "normal", Calculation(func.calc_value, Params(ParamValue('auto_frozen'), kwargs={'condition': ParamOption(option_2, todict=True), 'expected': ParamValue(True), 'reverse_condition': ParamValue(True)}))})) +option_3 = StrOption(name="my_variable", doc="my_variable", default=Calculation(func.calc_val, Params((ParamValue("yes")))), properties=frozenset({"basic", "hidden", Calculation(func.calc_value, Params(ParamValue('force_store_value'), kwargs={'condition': ParamOption(option_2, todict=True), 'expected': ParamValue(True), 'reverse_condition': ParamValue(True)})), Calculation(func.calc_value, Params(ParamValue('frozen'), kwargs={'condition': ParamOption(option_2, todict=True), 'expected': ParamValue(True), 'reverse_condition': ParamValue(True)}))})) option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2, option_3]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1]) diff --git a/tests/dictionaries/01fill_autofreeze/tiramisu/base.py b/tests/dictionaries/01fill_autofreeze/tiramisu/base.py index 6fbfb95a..c129f050 100644 --- a/tests/dictionaries/01fill_autofreeze/tiramisu/base.py +++ b/tests/dictionaries/01fill_autofreeze/tiramisu/base.py @@ -13,6 +13,6 @@ except: from tiramisu import * option_3 = StrOption(name="my_var2", doc="my_var2", default="no", properties=frozenset({"mandatory", "normal"})) option_4 = BoolOption(name="instanciated_module", doc="instanciated_module", default=False, properties=frozenset({"mandatory", "normal"})) -option_2 = StrOption(name="my_var1", doc="my_var1", default=Calculation(func.calc_val, Params((ParamOption(option_3)))), properties=frozenset({"auto_freeze", "force_store_value", "normal", Calculation(func.calc_value, Params(ParamValue('auto_frozen'), kwargs={'condition': ParamOption(option_4, todict=True), 'expected': ParamValue(True), 'reverse_condition': ParamValue(True)}))})) +option_2 = StrOption(name="my_var1", doc="my_var1", default=Calculation(func.calc_val, Params((ParamOption(option_3)))), properties=frozenset({"basic", Calculation(func.calc_value, Params(ParamValue('force_store_value'), kwargs={'condition': ParamOption(option_4, todict=True), 'expected': ParamValue(True), 'reverse_condition': ParamValue(True)})), Calculation(func.calc_value, Params(ParamValue('frozen'), kwargs={'condition': ParamOption(option_4, todict=True), 'expected': ParamValue(True), 'reverse_condition': ParamValue(True)}))})) option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2, option_3, option_4]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1]) diff --git a/tests/dictionaries/01fill_autosave/00-base.xml b/tests/dictionaries/01fill_autosave/00-base.xml index 8f8e5745..fb85eacb 100644 --- a/tests/dictionaries/01fill_autosave/00-base.xml +++ b/tests/dictionaries/01fill_autosave/00-base.xml @@ -1,6 +1,7 @@ + non diff --git a/tests/dictionaries/01fill_autosave/makedict/base.json b/tests/dictionaries/01fill_autosave/makedict/base.json index 3f1a7b00..2cff867e 100644 --- a/tests/dictionaries/01fill_autosave/makedict/base.json +++ b/tests/dictionaries/01fill_autosave/makedict/base.json @@ -1,4 +1,5 @@ { + "rougail.instanciated_module": true, "rougail.general.mode_conteneur_actif": "non", "rougail.general.mode_conteneur_actif1": "non" } diff --git a/tests/dictionaries/01fill_autosave/tiramisu/base.py b/tests/dictionaries/01fill_autosave/tiramisu/base.py index c862d7ed..7bfb4956 100644 --- a/tests/dictionaries/01fill_autosave/tiramisu/base.py +++ b/tests/dictionaries/01fill_autosave/tiramisu/base.py @@ -11,8 +11,9 @@ try: from tiramisu3 import * except: from tiramisu import * -option_4 = StrOption(name="mode_conteneur_actif1", doc="No change", default="non", properties=frozenset({"mandatory", "normal"})) -option_3 = StrOption(name="mode_conteneur_actif", doc="No change", default=Calculation(func.calc_val, Params((ParamOption(option_4)))), properties=frozenset({"basic", "force_store_value"})) -option_2 = OptionDescription(name="general", doc="general", children=[option_3, option_4], properties=frozenset({"basic"})) -option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2]) +option_2 = BoolOption(name="instanciated_module", doc="instanciated_module", default=True, properties=frozenset({"mandatory", "normal"})) +option_5 = StrOption(name="mode_conteneur_actif1", doc="No change", default="non", properties=frozenset({"mandatory", "normal"})) +option_4 = StrOption(name="mode_conteneur_actif", doc="No change", default=Calculation(func.calc_val, Params((ParamOption(option_5)))), properties=frozenset({"basic", Calculation(func.calc_value, Params(ParamValue('force_store_value'), kwargs={'condition': ParamOption(option_2, todict=True), 'expected': ParamValue(True), 'reverse_condition': ParamValue(True)}))})) +option_3 = OptionDescription(name="general", doc="general", children=[option_4, option_5], properties=frozenset({"basic"})) +option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2, option_3]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1]) diff --git a/tests/dictionaries/01hidden_if_in_autofreeze/tiramisu/base.py b/tests/dictionaries/01hidden_if_in_autofreeze/tiramisu/base.py index 5704e7b6..7f8f70c6 100644 --- a/tests/dictionaries/01hidden_if_in_autofreeze/tiramisu/base.py +++ b/tests/dictionaries/01hidden_if_in_autofreeze/tiramisu/base.py @@ -12,6 +12,6 @@ try: except: from tiramisu import * option_2 = BoolOption(name="instanciated_module", doc="instanciated_module", default=False, properties=frozenset({"mandatory", "normal"})) -option_3 = StrOption(name="my_var", doc="my_var", default=Calculation(func.calc_val, Params((ParamValue("yes")))), properties=frozenset({"auto_freeze", "force_store_value", "normal", Calculation(func.calc_value, Params(ParamValue('hidden'), kwargs={'condition': ParamOption(option_2, todict=True), 'expected': ParamValue(True)})), Calculation(func.calc_value, Params(ParamValue('auto_frozen'), kwargs={'condition': ParamOption(option_2, todict=True), 'expected': ParamValue(True), 'reverse_condition': ParamValue(True)}))})) +option_3 = StrOption(name="my_var", doc="my_var", default=Calculation(func.calc_val, Params((ParamValue("yes")))), properties=frozenset({"basic", Calculation(func.calc_value, Params(ParamValue('hidden'), kwargs={'condition': ParamOption(option_2, todict=True), 'expected': ParamValue(True)})), Calculation(func.calc_value, Params(ParamValue('force_store_value'), kwargs={'condition': ParamOption(option_2, todict=True), 'expected': ParamValue(True), 'reverse_condition': ParamValue(True)})), Calculation(func.calc_value, Params(ParamValue('frozen'), kwargs={'condition': ParamOption(option_2, todict=True), 'expected': ParamValue(True), 'reverse_condition': ParamValue(True)}))})) option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2, option_3]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1]) diff --git a/tests/dictionaries/02autosave_hidden_frozenifin/00-base.xml b/tests/dictionaries/02autosave_hidden_frozenifin/00-base.xml index 905827c6..a11fb61b 100644 --- a/tests/dictionaries/02autosave_hidden_frozenifin/00-base.xml +++ b/tests/dictionaries/02autosave_hidden_frozenifin/00-base.xml @@ -1,6 +1,7 @@ +