feat: better mandatories support (centralized)
This commit is contained in:
parent
105b4fd654
commit
437664e95a
2 changed files with 19 additions and 5 deletions
|
|
@ -27,7 +27,7 @@ from tiramisu.error import PropertiesOptionError
|
||||||
from tiramisu import MetaConfig
|
from tiramisu import MetaConfig
|
||||||
|
|
||||||
from rougail import Rougail
|
from rougail import Rougail
|
||||||
from rougail.user_data import UserData
|
from rougail.user_data import UserData, mandatories
|
||||||
from rougail.config import get_rougail_config
|
from rougail.config import get_rougail_config
|
||||||
from rougail.utils import load_modules
|
from rougail.utils import load_modules
|
||||||
from rougail.error import RougailWarning
|
from rougail.error import RougailWarning
|
||||||
|
|
@ -63,6 +63,10 @@ def _main(arguments, do_not_print):
|
||||||
print(version)
|
print(version)
|
||||||
exit()
|
exit()
|
||||||
layer_datas, metaconfig, config, err_warn = load_user_data(rougailconfig)
|
layer_datas, metaconfig, config, err_warn = load_user_data(rougailconfig)
|
||||||
|
if config and (not rougailconfig["cli.load_config"] or not rougailconfig["cli.read_write"]):
|
||||||
|
config.property.read_only()
|
||||||
|
if rougailconfig["cli.mandatory"]:
|
||||||
|
mandatories(config, err_warn["errors"])
|
||||||
output = get_output(rougailconfig,
|
output = get_output(rougailconfig,
|
||||||
metaconfig,
|
metaconfig,
|
||||||
config,
|
config,
|
||||||
|
|
@ -106,7 +110,10 @@ def load_cmd_user_data(rougailconfig, arguments):
|
||||||
for warning in user_data["warnings"]:
|
for warning in user_data["warnings"]:
|
||||||
if isinstance(warning, dict):
|
if isinstance(warning, dict):
|
||||||
for w, var in warning.items():
|
for w, var in warning.items():
|
||||||
warn(UserWarning(f'unable to load "{var.option.impl_get_display_name(var)}", {str(w)}'))
|
if var:
|
||||||
|
warn(UserWarning(f'unable to load "{var.option.impl_get_display_name(var)}", {str(w)}'))
|
||||||
|
else:
|
||||||
|
warn(UserWarning(f'{str(w)}'))
|
||||||
else:
|
else:
|
||||||
warn(warning)
|
warn(warning)
|
||||||
if manage_warnings:
|
if manage_warnings:
|
||||||
|
|
@ -288,8 +295,6 @@ def load_user_data(rougailconfig):
|
||||||
|
|
||||||
def get_output(rougailconfig, metaconfig, config, err_warn, layer_datas):
|
def get_output(rougailconfig, metaconfig, config, err_warn, layer_datas):
|
||||||
# output
|
# output
|
||||||
if config and (not rougailconfig["cli.load_config"] or not rougailconfig["cli.read_write"]):
|
|
||||||
config.property.read_only()
|
|
||||||
output_name = rougailconfig["step.output"]
|
output_name = rougailconfig["step.output"]
|
||||||
path = Path(__file__).parent.parent / ("output_" + output_name) / "__init__.py"
|
path = Path(__file__).parent.parent / ("output_" + output_name) / "__init__.py"
|
||||||
if not path.is_file():
|
if not path.is_file():
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ def get_rougail_config(
|
||||||
options = f"""
|
options = f"""
|
||||||
tiramisu_cache:
|
tiramisu_cache:
|
||||||
redefine: true
|
redefine: true
|
||||||
hidden: true
|
|
||||||
default:
|
default:
|
||||||
variable: _.cli.tiramisu_cache
|
variable: _.cli.tiramisu_cache
|
||||||
|
|
||||||
|
|
@ -100,6 +99,16 @@ cli:
|
||||||
|
|
||||||
read_write: false # {_('Configuration in output step is in read_write mode')}
|
read_write: false # {_('Configuration in output step is in read_write mode')}
|
||||||
|
|
||||||
|
mandatory:
|
||||||
|
description: {_('test mandatories variables')}
|
||||||
|
help: |-
|
||||||
|
{_("The configuration must be valid before process output. It's better to validate the values at the beginning of the process.")}
|
||||||
|
type: boolean
|
||||||
|
default:
|
||||||
|
jinja: |-
|
||||||
|
{{{{ cli.read_write == false }}}}
|
||||||
|
description: {_('if "cli.read_write" is false')}
|
||||||
|
|
||||||
description_type:
|
description_type:
|
||||||
description: {_('Type of variables description')}
|
description: {_('Type of variables description')}
|
||||||
alternative_name: cd
|
alternative_name: cd
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue