From cba9eeab1bb0a16dc701bb2b6eba1959e3f9cf19 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 29 Sep 2025 10:48:59 +0200 Subject: [PATCH] feat: remove json.read_write option --- src/rougail/output_ansible/__init__.py | 11 ----------- tests/hosts/00-ip.yml | 1 - tests/test_load.py | 9 ++++++--- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/rougail/output_ansible/__init__.py b/src/rougail/output_ansible/__init__.py index f62f072..ec0b839 100644 --- a/src/rougail/output_ansible/__init__.py +++ b/src/rougail/output_ansible/__init__.py @@ -79,17 +79,6 @@ class RougailOutputAnsible(RougailOutputJson): return super().manage_errors() return True - def parse_family( - self, - conf, - child, - ): - if self.read_write and conf.path() == self.host_namespace: - self.config.property.read_only() - super().parse_family(conf, child) - if self.read_write and conf.path() == self.host_namespace: - self.config.property.read_write() - def json_to_ansible(self): ret = {"_meta": {"hostvars": {}}} if "_warnings" in self.dico: diff --git a/tests/hosts/00-ip.yml b/tests/hosts/00-ip.yml index e4aa49d..5bad3b5 100644 --- a/tests/hosts/00-ip.yml +++ b/tests/hosts/00-ip.yml @@ -2,7 +2,6 @@ version: "1.1" hostnames: - hidden: true group1: diff --git a/tests/test_load.py b/tests/test_load.py index 5bf3923..2098a90 100644 --- a/tests/test_load.py +++ b/tests/test_load.py @@ -37,7 +37,6 @@ def _test_structural_files(test_dir, namespace, ext, *, read_write=True, mandato return ################################## rougailconfig['step.output'] = 'ansible' - rougailconfig["json.read_write"] = read_write rougailconfig["json.mandatory"] = mandatory extra_namespaces = rougailconfig["extra_namespaces"] extra_namespaces["hosts"] = [str(Path(__file__).parent / "hosts")] @@ -61,10 +60,14 @@ def _test_structural_files(test_dir, namespace, ext, *, read_write=True, mandato ################################## if do_calc and (mandatory or not read_write): if mandatory: - get_values_for_config(config) + get_values_for_config(config, exclude_namespace="hosts") else: - get_values_for_config(config, level="mandatories") + get_values_for_config(config, level="mandatories", exclude_namespace="hosts") ################################## + if read_write: + config.property.read_write() + else: + config.property.read_only() generated_output = RougailOutput(config, rougailconfig=rougailconfig).run()[1] output_file = Path(__file__).parent / 'results' / dir_name / (test_dir.name + "." + ext) if not output_file.is_file():