fix: always remove choice type + support warnings

This commit is contained in:
egarette@silique.fr 2025-11-03 20:22:38 +01:00
parent bae0368356
commit ff78033c9a
5 changed files with 5 additions and 8 deletions

View file

@ -152,8 +152,6 @@ class RougailOutputFormatter:
def get_attributes(self, obj, excludes=[]) -> dict:
type_name = obj.__name__
if type_name == "Variable" and excludes == []:
raise Exception("pff")
if type_name not in self.attributes:
self.attributes[type_name] = {
str(attr): o.default
@ -392,8 +390,6 @@ class RougailOutputFormatter:
and isinstance(variable["default"], list)
):
del variable["multi"]
elif variable.get("type") == "choice" and "choices" in variable:
del variable["type"]
elif variable.get("type") == "string":
# default type is string
del variable["type"]
@ -404,6 +400,8 @@ class RougailOutputFormatter:
# if boolean, the default value is True
del variable["type"]
variable["default"] = True
if variable.get("type") == "choice" and "choices" in variable:
del variable["type"]
if (
"default" not in variable
and variable.get("multi") is True
@ -528,6 +526,8 @@ class RougailOutputFormatter:
jinja["description"] = LiteralScalarString(value.description.strip())
else:
jinja["description"] = value.description.strip()
if value.warnings:
jinja["warnings"] = True
if value.params:
jinja["params"] = self.object_to_yaml(
"params", type_, value.params, multi, object_path

View file

@ -4,7 +4,6 @@ version: 1.1
var:
description: A choice
type: choice
choices:
- quote'
- quote"

View file

@ -8,7 +8,6 @@ source_variable_2: val2 # the second source variable
my_variable:
description: a variable
type: choice
choices:
- variable: _.source_variable_1
- variable: _.source_variable_2

View file

@ -4,7 +4,6 @@ version: 1.1
var:
description: A choice
type: choice
choices:
- a
- b

View file

@ -15,7 +15,7 @@ excludes = [
]
test_ok = get_structures_list(excludes)
# test_ok = [Path('../rougail-tests/structures/60_6family_dynamic_sub_dynamic_1_0_2')]
# test_ok = [Path('../rougail-tests/structures/04_5validators_warnings')]
def idfn(fixture_value):