Compare commits

..

3 commits

12 changed files with 80 additions and 10 deletions

View file

@ -1,3 +1,13 @@
## 0.1.0a21 (2025-11-06)
### Feat
- add some tests
### Fix
- always remove choice type + support warnings
## 0.1.0a20 (2025-11-03) ## 0.1.0a20 (2025-11-03)
### Feat ### Feat

View file

@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
[project] [project]
name = "rougail.output_formatter" name = "rougail.output_formatter"
version = "0.1.0a20" version = "0.1.0a21"
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}] authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
readme = "README.md" readme = "README.md"
description = "Rougail output formatter" description = "Rougail output formatter"

View file

@ -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

View file

@ -1 +1 @@
__version__ = "0.1.0a20" __version__ = "0.1.0a21"

View file

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

View file

@ -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

View file

@ -0,0 +1,15 @@
%YAML 1.2
---
version: 1.1
int:
description: An integer
validators:
- jinja: |-
{% if _.int > 100 %}
value is too high
{% endif %}
description: the max value is 100
warnings: true
default: 1000
...

View file

@ -0,0 +1,12 @@
%YAML 1.2
---
version: 1.1
int:
description: An integer
params:
min_integer: 10
max_integer: 100
warnings: true
default: 1000
...

View file

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

View file

@ -0,0 +1,18 @@
%YAML 1.2
---
version: 1.1
dyn{{ identifier }}:
description: A dynamic famify for {{ identifier }}
dynamic:
- val1
- val2
var1: # A dynamic variable
var2:
description: A new variable
disabled:
variable: _.var1
when: val1
...

View file

@ -0,0 +1,18 @@
%YAML 1.2
---
version: 1.1
dyn{{ identifier }}:
description: A dynamic famify for {{ identifier }}
dynamic:
- val1
- val2
var1: # A dynamic variable
var2:
description: A new variable
disabled:
variable: _.dynval1.var1
when: val1
...

View file

@ -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):