fix: always remove choice type + support warnings
This commit is contained in:
parent
bae0368356
commit
ff78033c9a
5 changed files with 5 additions and 8 deletions
|
|
@ -152,8 +152,6 @@ class RougailOutputFormatter:
|
||||||
|
|
||||||
def get_attributes(self, obj, excludes=[]) -> dict:
|
def get_attributes(self, obj, excludes=[]) -> dict:
|
||||||
type_name = obj.__name__
|
type_name = obj.__name__
|
||||||
if type_name == "Variable" and excludes == []:
|
|
||||||
raise Exception("pff")
|
|
||||||
if type_name not in self.attributes:
|
if type_name not in self.attributes:
|
||||||
self.attributes[type_name] = {
|
self.attributes[type_name] = {
|
||||||
str(attr): o.default
|
str(attr): o.default
|
||||||
|
|
@ -392,8 +390,6 @@ class RougailOutputFormatter:
|
||||||
and isinstance(variable["default"], list)
|
and isinstance(variable["default"], list)
|
||||||
):
|
):
|
||||||
del variable["multi"]
|
del variable["multi"]
|
||||||
elif variable.get("type") == "choice" and "choices" in variable:
|
|
||||||
del variable["type"]
|
|
||||||
elif variable.get("type") == "string":
|
elif variable.get("type") == "string":
|
||||||
# default type is string
|
# default type is string
|
||||||
del variable["type"]
|
del variable["type"]
|
||||||
|
|
@ -404,6 +400,8 @@ class RougailOutputFormatter:
|
||||||
# if boolean, the default value is True
|
# if boolean, the default value is True
|
||||||
del variable["type"]
|
del variable["type"]
|
||||||
variable["default"] = True
|
variable["default"] = True
|
||||||
|
if variable.get("type") == "choice" and "choices" in variable:
|
||||||
|
del variable["type"]
|
||||||
if (
|
if (
|
||||||
"default" not in variable
|
"default" not in variable
|
||||||
and variable.get("multi") is True
|
and variable.get("multi") is True
|
||||||
|
|
@ -528,6 +526,8 @@ class RougailOutputFormatter:
|
||||||
jinja["description"] = LiteralScalarString(value.description.strip())
|
jinja["description"] = LiteralScalarString(value.description.strip())
|
||||||
else:
|
else:
|
||||||
jinja["description"] = value.description.strip()
|
jinja["description"] = value.description.strip()
|
||||||
|
if value.warnings:
|
||||||
|
jinja["warnings"] = True
|
||||||
if value.params:
|
if value.params:
|
||||||
jinja["params"] = self.object_to_yaml(
|
jinja["params"] = self.object_to_yaml(
|
||||||
"params", type_, value.params, multi, object_path
|
"params", type_, value.params, multi, object_path
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ version: 1.1
|
||||||
|
|
||||||
var:
|
var:
|
||||||
description: A choice
|
description: A choice
|
||||||
type: choice
|
|
||||||
choices:
|
choices:
|
||||||
- quote'
|
- quote'
|
||||||
- quote"
|
- quote"
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ source_variable_2: val2 # the second source variable
|
||||||
|
|
||||||
my_variable:
|
my_variable:
|
||||||
description: a variable
|
description: a variable
|
||||||
type: choice
|
|
||||||
choices:
|
choices:
|
||||||
- variable: _.source_variable_1
|
- variable: _.source_variable_1
|
||||||
- variable: _.source_variable_2
|
- variable: _.source_variable_2
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ version: 1.1
|
||||||
|
|
||||||
var:
|
var:
|
||||||
description: A choice
|
description: A choice
|
||||||
type: choice
|
|
||||||
choices:
|
choices:
|
||||||
- a
|
- a
|
||||||
- b
|
- b
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ excludes = [
|
||||||
]
|
]
|
||||||
|
|
||||||
test_ok = get_structures_list(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):
|
def idfn(fixture_value):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue