feat: remove json.read_write option

This commit is contained in:
egarette@silique.fr 2025-09-29 10:47:05 +02:00
parent 39de31c459
commit 9d478ab76a
3 changed files with 17 additions and 17 deletions

View file

@ -57,7 +57,6 @@ class RougailOutputJson:
self.warnings = user_data_warnings self.warnings = user_data_warnings
else: else:
self.warnings = [] self.warnings = []
self.read_write = self.rougailconfig["json.read_write"]
self.is_mandatory = self.rougailconfig["json.mandatory"] self.is_mandatory = self.rougailconfig["json.mandatory"]
self.get = self.rougailconfig["json.get"] self.get = self.rougailconfig["json.get"]
self.dico = {} self.dico = {}
@ -76,14 +75,14 @@ class RougailOutputJson:
return ret return ret
def exporter(self) -> None: def exporter(self) -> None:
self.config.property.read_write() if self.is_mandatory:
self.mandatory() ori_properties = self.config.property.exportation()
self.config.property.read_only() self.config.property.read_write()
self.mandatory()
self.config.property.importation(ori_properties)
if self.manage_errors(): if self.manage_errors():
return False return False
self.manage_warnings() self.manage_warnings()
if self.read_write:
self.config.property.read_write()
if self.get: if self.get:
config = self.config.option(self.get) config = self.config.option(self.get)
if not config.isoptiondescription(): if not config.isoptiondescription():
@ -98,8 +97,6 @@ class RougailOutputJson:
return True return True
def mandatory(self): def mandatory(self):
if not self.is_mandatory:
return
title = False title = False
options_with_error = [] options_with_error = []
try: try:
@ -114,7 +111,6 @@ class RougailOutputJson:
try: try:
option.value.get() option.value.get()
if not title: if not title:
# self.errors.append("Les variables suivantes sont obligatoires mais n'ont pas de valeur :")
self.errors.append( self.errors.append(
_("The following variables are mandatory but have no value:") _("The following variables are mandatory but have no value:")
) )
@ -125,7 +121,6 @@ class RougailOutputJson:
if not title: if not title:
for idx, option in enumerate(options_with_error): for idx, option in enumerate(options_with_error):
if not idx: if not idx:
# self.errors.append("Les variables suivantes sont inaccessibles mais sont vides et obligatoires :")
self.errors.append( self.errors.append(
_( _(
"The following variables are inaccessible but are empty and mandatory :" "The following variables are inaccessible but are empty and mandatory :"

View file

@ -28,19 +28,21 @@ def get_rougail_config(
json: json:
description: {_('configuration rougail-json')} description: {_('configuration rougail-json')}
disabled: disabled:
type: jinja
jinja: | jinja: |
{{% if step.output is propertyerror or step.output != 'json' %}} {{% if step.output is propertyerror or step.output != 'json' %}}
disabled disabled
{{% endif %}} {{% endif %}}
read_write:
description: {_('display variables available in read_write mode')}
default: false
mandatory: mandatory:
description: {_('test mandatories variables before display in json')} description: {_('test mandatories variables before display in json')}
default: true type: boolean
default:
jinja: |-
{{% if cli.read_write is defined and cli.read_write %}}
false
{{% else %}}
true
{{% endif %}}
get: get:
description: {_('get value for a variable or a family')} description: {_('get value for a variable or a family')}

View file

@ -34,7 +34,6 @@ def _test_structural_files(test_dir, namespace, ext, *, read_write=True, mandato
return return
################################## ##################################
rougailconfig['step.output'] = 'json' rougailconfig['step.output'] = 'json'
rougailconfig["json.read_write"] = read_write
rougailconfig["json.mandatory"] = mandatory rougailconfig["json.mandatory"] = mandatory
################################## ##################################
dir_name = 'test' dir_name = 'test'
@ -56,6 +55,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():