feat: remove console.read_write option

This commit is contained in:
egarette@silique.fr 2025-09-29 10:47:37 +02:00
parent f05ce289bc
commit 94db932ba3
3 changed files with 18 additions and 12 deletions

View file

@ -52,7 +52,6 @@ class RougailOutputConsole:
rougailconfig = RougailConfig rougailconfig = RougailConfig
self.rougailconfig = rougailconfig self.rougailconfig = rougailconfig
self.config = config self.config = config
self.read_write = self.rougailconfig["console.read_write"]
self.is_mandatory = self.rougailconfig["console.mandatory"] self.is_mandatory = self.rougailconfig["console.mandatory"]
self.show_secrets = self.rougailconfig["console.show_secrets"] self.show_secrets = self.rougailconfig["console.show_secrets"]
self.key_is_description = self.rougailconfig["console.key_is_description"] self.key_is_description = self.rougailconfig["console.key_is_description"]
@ -76,8 +75,6 @@ class RougailOutputConsole:
self.root = self.get_root() self.root = self.get_root()
def mandatory(self): def mandatory(self):
if not self.is_mandatory:
return
try: try:
mandatories = self.config.value.mandatory() mandatories = self.config.value.mandatory()
except (ConfigError, PropertiesOptionError) as err: except (ConfigError, PropertiesOptionError) as err:
@ -109,12 +106,11 @@ class RougailOutputConsole:
self.errors.append([option.description() for option in options_with_error]) self.errors.append([option.description() for option in options_with_error])
def exporter(self) -> bool: def exporter(self) -> bool:
self.config.property.read_write() if self.is_mandatory:
self.mandatory() ori_properties = self.config.property.exportation()
if self.read_write:
self.config.property.read_write() self.config.property.read_write()
else: self.mandatory()
self.config.property.read_only() self.config.property.importation(ori_properties)
warnings = self.user_data_warnings + self.warnings warnings = self.user_data_warnings + self.warnings
if warnings: if warnings:
self.display_warnings(warnings) self.display_warnings(warnings)

View file

@ -34,11 +34,18 @@ console:
disabled disabled
{{% endif %}} {{% endif %}}
read_write: false # {_('Display variables available in read_write mode')}
show_secrets: false # {_('Show secrets instead of obscuring them')} show_secrets: false # {_('Show secrets instead of obscuring them')}
mandatory: true # {_('Test mandatories variable before display in console')} mandatory:
description: {_('test mandatories variables before display in json')}
type: boolean
default:
jinja: |-
{{% if cli.read_write is defined and cli.read_write %}}
false
{{% else %}}
true
{{% endif %}}
key_is_description: true # {_("In tree the key is the family or variable description inside of it's name")} key_is_description: true # {_("In tree the key is the family or variable description inside of it's name")}
""" """

View file

@ -34,7 +34,6 @@ def _test_structural_files(test_dir, namespace, ext, *, read_write=True, mandato
return return
################################## ##################################
rougailconfig['step.output'] = 'console' rougailconfig['step.output'] = 'console'
rougailconfig["console.read_write"] = read_write
rougailconfig["console.mandatory"] = mandatory rougailconfig["console.mandatory"] = mandatory
rougailconfig["console.show_secrets"] = show_secrets rougailconfig["console.show_secrets"] = show_secrets
rougailconfig["console.key_is_description"] = key_is_description rougailconfig["console.key_is_description"] = key_is_description
@ -62,6 +61,10 @@ def _test_structural_files(test_dir, namespace, ext, *, read_write=True, mandato
if do_calc and (mandatory or not read_write): if do_calc and (mandatory or not read_write):
get_values_for_config(config) get_values_for_config(config)
################################## ##################################
if read_write:
config.property.read_write()
else:
config.property.read_only()
generated_output = RougailOutput(config, rougailconfig=rougailconfig).run()[1] generated_output = RougailOutput(config, rougailconfig=rougailconfig).run()[1]
output_file = Path(__file__).parent / 'results' / dir_name / (test_dir.name + "." + ext) output_file = Path(__file__).parent / 'results' / dir_name / (test_dir.name + "." + ext)
if not output_file.is_file(): if not output_file.is_file():