diff --git a/src/rougail/config.py b/src/rougail/config.py index 6f4bb8d25..3c2455fba 100644 --- a/src/rougail/config.py +++ b/src/rougail/config.py @@ -305,7 +305,6 @@ base_option_name: not_export_with_import: description: {_("In cache file, do not importation of Tiramisu and other dependencies")} - negative_description: {_("In cache file, do importation of Tiramisu and other dependencies")} default: false commandline: false @@ -337,12 +336,10 @@ suffix: force_optional: description: {_("Every variables in calculation are optionals")} - negative_description: {_("Variables in calculation are not optional by default")} default: False load_unexist_redefine: description: {_("Loads redefine variables even if there don't already exists")} - negative_description: {_("Loads redefine variables even if there don't already exists")} commandline: false default: False diff --git a/src/rougail/structural_commandline/annotator.py b/src/rougail/structural_commandline/annotator.py index 6e5c3942b..7fdd9de47 100644 --- a/src/rougail/structural_commandline/annotator.py +++ b/src/rougail/structural_commandline/annotator.py @@ -50,7 +50,6 @@ class Annotator(Walk): self.not_for_commandline(variable) else: self.manage_alternative_name(variable) - self.manage_negative_description(variable) def not_for_commandline(self, variable) -> None: self.objectspace.properties.add(variable.path, "not_for_commandline", True) @@ -87,29 +86,3 @@ class Annotator(Walk): False, variable.version, ) - - def manage_negative_description(self, variable) -> None: - if not variable.negative_description: - if variable.type == "boolean" and not self.objectspace.add_extra_options: - if variable.name == variable.description: - variable.negative_description = variable.name - else: - raise DictConsistencyError( - _( - 'negative_description is mandatory for boolean variable, but "{0}" hasn\'t' - ).format(variable.path), - 200, - variable.xmlfiles, - ) - elif variable.type != "boolean": - raise DictConsistencyError( - _( - 'negative_description is only available for boolean variable, but "{0}" is "{1}"' - ).format(variable.path, variable.type), - 201, - variable.xmlfiles, - ) - if variable.negative_description: - self.objectspace.informations.add( - variable.path, "negative_description", variable.negative_description - ) diff --git a/src/rougail/structural_commandline/config.py b/src/rougail/structural_commandline/config.py index f865fdc47..99aa6506b 100644 --- a/src/rougail/structural_commandline/config.py +++ b/src/rougail/structural_commandline/config.py @@ -30,7 +30,6 @@ structural_commandline: add_extra_options: description: Add extra options to tiramisu-cmdline-parser - negative_description: Remove extra options to tiramisu-cmdline-parser default: true """ return { diff --git a/src/rougail/structural_commandline/object_model.py b/src/rougail/structural_commandline/object_model.py index 404051ee2..c17462a2b 100644 --- a/src/rougail/structural_commandline/object_model.py +++ b/src/rougail/structural_commandline/object_model.py @@ -24,7 +24,6 @@ from pydantic import BaseModel class Variable(BaseModel): alternative_name: Optional[str] = None commandline: bool = True - negative_description: Optional[str] = None class Family(BaseModel): diff --git a/src/rougail/structural_directory/config.py b/src/rougail/structural_directory/config.py index a8f35228a..c8a60317e 100644 --- a/src/rougail/structural_directory/config.py +++ b/src/rougail/structural_directory/config.py @@ -47,7 +47,6 @@ main_dictionaries: sort_dictionaries_all: description: {_("Sort dictionaries from differents directories")} - negative_description: Sort dictionaries directory by directory default: false disabled: jinja: >- diff --git a/tests/dictionaries/16_3family_empty_at_ends/tiramisu/base.py b/tests/dictionaries/16_3family_empty_at_ends/tiramisu/base.py index 632fc20e3..53ff62d98 100644 --- a/tests/dictionaries/16_3family_empty_at_ends/tiramisu/base.py +++ b/tests/dictionaries/16_3family_empty_at_ends/tiramisu/base.py @@ -11,6 +11,6 @@ ALLOWED_LEADER_PROPERTIES.add("basic") ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("advanced") option_3 = StrOption(name="var1", doc="var1", properties=frozenset({"basic", "mandatory"}), informations={'ymlfiles': ['../rougail-tests/structures/16_3family_empty_at_ends/rougail/00-base.yml'], 'type': 'string'}) -optiondescription_2 = OptionDescription(name="family", doc="family", children=[option_3], properties=frozenset({"basic"}), informations={'ymlfiles': ['../rougail-tests/structures/16_3family_empty_at_ends/rougail/00-base.yml']}) +optiondescription_2 = OptionDescription(name="family", doc="family", children=[option_3], properties=frozenset({"basic"}), informations={'ymlfiles': ['../rougail-tests/structures/16_3family_empty_at_ends/rougail/00-base.yml', '../rougail-tests/structures/16_3family_empty_at_ends/rougail/01-base.yml']}) optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[optiondescription_2], properties=frozenset({"basic"}), informations={'ymlfiles': ['']}) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) diff --git a/tests/dictionaries/16_3family_empty_at_ends/tiramisu/no_namespace.py b/tests/dictionaries/16_3family_empty_at_ends/tiramisu/no_namespace.py index 05ac648d1..3e512db71 100644 --- a/tests/dictionaries/16_3family_empty_at_ends/tiramisu/no_namespace.py +++ b/tests/dictionaries/16_3family_empty_at_ends/tiramisu/no_namespace.py @@ -7,5 +7,5 @@ ALLOWED_LEADER_PROPERTIES.add("basic") ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("advanced") option_2 = StrOption(name="var1", doc="var1", properties=frozenset({"basic", "mandatory"}), informations={'ymlfiles': ['../rougail-tests/structures/16_3family_empty_at_ends/rougail/00-base.yml'], 'type': 'string'}) -optiondescription_1 = OptionDescription(name="family", doc="family", children=[option_2], properties=frozenset({"basic"}), informations={'ymlfiles': ['../rougail-tests/structures/16_3family_empty_at_ends/rougail/00-base.yml']}) +optiondescription_1 = OptionDescription(name="family", doc="family", children=[option_2], properties=frozenset({"basic"}), informations={'ymlfiles': ['../rougail-tests/structures/16_3family_empty_at_ends/rougail/00-base.yml', '../rougail-tests/structures/16_3family_empty_at_ends/rougail/01-base.yml']}) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) diff --git a/tests/test_1_flattener.py b/tests/test_1_flattener.py index 494ebfc88..8ef8fad48 100644 --- a/tests/test_1_flattener.py +++ b/tests/test_1_flattener.py @@ -47,7 +47,7 @@ excludes = set([ ]) test_ok -= excludes test_raise -= excludes -# test_ok = ['40_9leadership-calculation-outside-follower-no-mandatory'] +test_ok = ['00_2default_calculated_params_permissive'] #test_ok = [] # test_raise = ['22_0calculation_variable_leader_follower_multi'] #test_raise = [] diff --git a/tests/test_2_makedict.py b/tests/test_2_makedict.py index 64c2c4592..bf01ea911 100644 --- a/tests/test_2_makedict.py +++ b/tests/test_2_makedict.py @@ -31,7 +31,7 @@ excludes = set([]) # excludes = set(['60_5family_dynamic_variable_outside_sub_suffix']) test_ok -= excludes -# test_ok = ['40_9calculation_variable_leader_follower_multi_inside'] +test_ok = ['00_2default_calculated_params_permissive'] test_ok = list(test_ok) @@ -79,6 +79,7 @@ def launch_flattener(test_dir, ): makedict_dir = join(test_dir, 'makedict') makedict_file = join(makedict_dir, 'base.json') + makedict_read_write = join(makedict_dir, 'read_write.json') makedict_before = join(makedict_dir, 'before.json') makedict_after = join(makedict_dir, 'after.json') informations_file = join(test_dir, 'informations.json') @@ -163,6 +164,35 @@ def launch_flattener(test_dir, value_owner(test_dir, makedict_after, config, filename) # mandatory(test_dir, mandatory_file, config.value.mandatory(), filename) + # + # read_write + config.property.read_write() + config_dict = dict(option_value(config.value.get())) + if not isfile(makedict_read_write) or debug: + with open(makedict_read_write, 'w') as fh: + dump(config_dict, fh, indent=4) + fh.write('\n') + with open(makedict_read_write, 'r') as fh: + loaded_config_dict = load(fh) + if filename == 'no_namespace': + config_dict = config_add_rougail(config_dict) + elif filename != 'base': + config_dict_prefix = {'1': {}, '2': {}} + for key, value in config_dict.items(): + prefix, path = key.split('.', 1) + if value and isinstance(value, list) and isinstance(value[0], dict): + new_value = [] + for dct in value: + new_dct = {} + for k, v in dct.items(): + k = k.split('.', 1)[-1] + new_dct[k] = v + new_value.append(new_dct) + value = new_value + config_dict_prefix[prefix][path] = value + assert loads(dumps(config_dict_prefix['1'])) == loads(dumps(config_dict_prefix['2'])) + config_dict = config_dict_prefix['1'] + assert loaded_config_dict == loads(dumps(config_dict)), f"error in file {makedict_read_write}" def config_add_rougail(config):