diff --git a/src/rougail/output_formatter/__init__.py b/src/rougail/output_formatter/__init__.py index 9f3a43e..b5f4a35 100644 --- a/src/rougail/output_formatter/__init__.py +++ b/src/rougail/output_formatter/__init__.py @@ -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 diff --git a/tests/results/00_7choice_quote/rougail/00-base.yml b/tests/results/00_7choice_quote/rougail/00-base.yml index 1eea5b9..9aaf127 100644 --- a/tests/results/00_7choice_quote/rougail/00-base.yml +++ b/tests/results/00_7choice_quote/rougail/00-base.yml @@ -4,7 +4,6 @@ version: 1.1 var: description: A choice - type: choice choices: - quote' - quote" diff --git a/tests/results/00_9choice_variables/rougail/00-base.yml b/tests/results/00_9choice_variables/rougail/00-base.yml index 63fd4f7..2b55ba0 100644 --- a/tests/results/00_9choice_variables/rougail/00-base.yml +++ b/tests/results/00_9choice_variables/rougail/00-base.yml @@ -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 diff --git a/tests/results/16_6choice_redefine/rougail/00-base.yml b/tests/results/16_6choice_redefine/rougail/00-base.yml index 58d3662..e04fb65 100644 --- a/tests/results/16_6choice_redefine/rougail/00-base.yml +++ b/tests/results/16_6choice_redefine/rougail/00-base.yml @@ -4,7 +4,6 @@ version: 1.1 var: description: A choice - type: choice choices: - a - b diff --git a/tests/test_load.py b/tests/test_load.py index c28e4ea..83bcece 100644 --- a/tests/test_load.py +++ b/tests/test_load.py @@ -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):