first version

This commit is contained in:
egarette@silique.fr 2024-12-23 20:54:52 +01:00
parent f70ced37ef
commit d28c5aae0a
245 changed files with 4378 additions and 0 deletions

View file

@ -0,0 +1,388 @@
"""
Silique (https://www.silique.fr)
Copyright (C) 2024
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from io import BytesIO
from pathlib import Path
from typing import Optional
from ruamel.yaml import YAML, CommentedMap
from ruamel.yaml.tokens import CommentToken
from ruamel.yaml.error import CommentMark
from ruamel.yaml.comments import CommentedSeq
from ruamel.yaml.scalarstring import LiteralScalarString, FoldedScalarString
from tiramisu import undefined
from tiramisu.config import get_common_path
from rougail.convert import RougailConvert
from rougail.object_model import Variable, Family, Calculation, JinjaCalculation, IdentifierCalculation, IdentifierPropertyCalculation, IdentifierParam, IndexCalculation, IndexParam, Param
from rougail.utils import normalize_family
from .upgrade import RougailUpgrade
def _(text):
return text
class RougailOutputFormatter:
output_name = 'formatter'
def __init__(
self,
config: "Config",
*,
rougailconfig: "RougailConfig" = None,
user_data_errors: Optional[list] = None,
user_data_warnings: Optional[list] = None,
) -> None:
self.basic_types = {
str: "string",
int: "number",
bool: "boolean",
float: "float",
}
if rougailconfig is None:
from rougail import RougailConfig
rougailconfig = RougailConfig
rougailconfig["step.output"] = self.output_name
if rougailconfig["step.output"] != self.output_name:
raise ExtentionError(_('the "step.output" is not set to "{0}"').format(self.output_name))
# yaml.top_level_colon_align = True
self.main_namespace = rougailconfig["main_namespace"]
filenames = rougailconfig["main_dictionaries"]
if len(rougailconfig["main_dictionaries"]) > 1:
raise Exception(_('only one file is allowed'))
filename = Path(filenames[0])
if not filename.is_file():
raise Exception(_('only a file is allowed'))
self.original_yaml = RougailUpgrade(rougailconfig).run(filename)
datas = RougailUpgrade(rougailconfig).run(filename)
self.rougail = RougailConvert(rougailconfig)
self.rougail.load_config()
self.rougail.init()
self.filename_str = str(filename)
if self.main_namespace is None:
self.rougail.namespace = None
else:
self.rougail.namespace = normalize_family(self.main_namespace)
self.rougail.create_namespace(self.main_namespace)
self.rougail.validate_file_version(
datas,
self.filename_str,
)
self.rougail.parse_root_file(
self.filename_str,
self.rougail.namespace,
"1.1",
datas,
)
self.yaml = YAML()
def run(self):
self.families_attributes = {attr: obj.get("default") for attr, obj in self.rougail.family.model_json_schema()["properties"].items()}
self.dynamics_attributes = {attr: obj.get("default") for attr, obj in self.rougail.dynamic.model_json_schema()["properties"].items()}
self.variables_attributes = {attr: obj.get("default") for attr, obj in self.rougail.variable.model_json_schema()["properties"].items()}
self.families = {None: CommentedMap()}
self.parse()
self.yaml.indent(mapping=2, sequence=4, offset=2)
self.yaml.explicit_start=True
self.default_flow_style = False
with BytesIO() as ymlfh:
self.yaml.dump(self.families[None], ymlfh)
ret = ymlfh.getvalue().decode("utf-8").strip() + '\n'
return ret
def print(self):
print(self.run())
def parse(self):
# FIXME path to relative !
if self.rougail.namespace:
version_path = f'{self.rougail.namespace}.version'
else:
version_path = 'version'
if version_path in self.rougail.paths._data:
version_name = '_version'
else:
version_name = 'version'
self.families[None][version_name] = None
self.families[None].yaml_value_comment_extend(version_name, [CommentToken('\n\n', CommentMark(0)), None])
version = None
for path, obj in self.rougail.paths._data.items():
if version is None or version == '':
version = obj.version
if path == self.rougail.namespace:
self.families[path] = self.families[None]
continue
if isinstance(obj, Family):
self.parse_family(path, obj)
if isinstance(obj, Variable):
self.parse_variable(path, obj)
if not version:
raise Exception(_(f'no variables in file {self.filename_str}'))
self.families[None][version_name] = float(version)
def parse_family(self, path, obj):
children = [p.rsplit('.', 1)[-1] for p in self.rougail.parents[path]]
parent, name = self.get_parent_name(path)
ret = self.families[parent]
family = CommentedMap()
yaml_data = self.parse_yaml(path)
force_keys = []
if isinstance(yaml_data, dict):
if yaml_data.get("redefine", False):
family["redefine"] = True
force_keys = list(yaml_data)
if yaml_data.get("exists") is not None:
family["exists"] = yaml_data["exists"]
force_keys = list(yaml_data)
type_ = obj.type
if type_ == "dynamic":
attributes = self.dynamics_attributes
else:
attributes = self.families_attributes
for attr, default_value in attributes.items():
if attr in ["name", "path", "namespace", "version", "path_prefix", "xmlfiles"]:
continue
try:
value = getattr(obj, attr)
except AttributeError:
continue
if attr != "type" and attr not in force_keys and value == default_value:
continue
if attr in children:
attr = f'_{attr}'
value = self.object_to_yaml(attr, type_, value, False, path)
family[attr] = value
if type_ == "dynamic" or (children and type_ == 'family'):
if "_type" in family:
del family["_type"]
else:
del family["type"]
if not set(family):
ret[name] = CommentedMap()
ret.yaml_value_comment_extend(name, [CommentToken('\n\n', CommentMark(0)), None])
elif not set(family) - {'description'}:
#
ret[name] = CommentedMap()
ret.yaml_add_eol_comment(family["description"] + '\n\n', name)
else:
self.add_space(family)
ret[name] = family
self.families[path] = ret[name]
def parse_variable(self, path, obj):
parent, name = self.get_parent_name(path)
ret = self.families[parent]
variable = CommentedMap()
yaml_data = self.parse_yaml(path)
force_keys = []
if isinstance(yaml_data, dict):
if yaml_data.get("redefine", False):
variable["redefine"] = True
force_keys = list(yaml_data)
if yaml_data.get("exists") is not None:
variable["exists"] = yaml_data["exists"]
force_keys = list(yaml_data)
multi = obj.multi or isinstance(obj.default, list)
type_ = obj.type
for attr, default_value in self.variables_attributes.items():
if attr in ["name", "path", "namespace", "version", "path_prefix", "xmlfiles"]:
continue
try:
value = getattr(obj, attr)
except AttributeError:
continue
if attr not in force_keys and value == default_value:
continue
value = self.object_to_yaml(attr, type_, value, multi, path)
variable[attr] = value
if variable.get("mandatory") is True and None not in variable.get("choices", []):
del variable["mandatory"]
if "default" in variable:
if "type" in variable and variable["type"] in ["string", "boolean", "number", "float"]:
if variable["default"] and isinstance(variable["default"], list):
tested_value = variable["default"][0]
else:
tested_value = variable["default"]
if variable["type"] == self.basic_types.get(type(tested_value), None):
del variable["type"]
if "multi" in variable and variable["multi"] is True 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"]
if set(variable) in [{"multi"}, {'multi', 'description'}]:
variable["default"] = []
variable.pop("multi")
elif variable.get("type") == "boolean" and not multi:
# if boolean, the default value is True
del variable["type"]
variable["default"] = True
if not isinstance(variable.get("default"), dict) and not set(variable) - {'default', 'description'}:
# shorthand notation
default = variable.get('default')
ret[name] = default
if isinstance(default, list):
ret[name] = CommentedSeq()
for d in default:
ret[name].append(d)
else:
ret[name] = default
if "description" in variable:
description = variable["description"]
if not multi or not default:
description += "\n\n"
ret.yaml_add_eol_comment(description, name)
if multi and default:
self.add_space(ret)
else:
self.add_space(ret)
else:
ret[name] = variable
self.add_space(variable)
def add_space(self, obj):
def _get_last_obj(o, parent, param, typ):
if isinstance(o, CommentedMap):
param = list(o)[-1]
return _get_last_obj(o[param], o, param, 'map')
if isinstance(o, CommentedSeq):
param = len(o) - 1
return _get_last_obj(o[param], o, param, 'seq')
return typ, parent, param
param = list(obj)[-1]
typ, parent, param = _get_last_obj(obj[param], obj, param, 'map')
if typ == 'seq':
func = parent.yaml_key_comment_extend
else:
func = parent.yaml_value_comment_extend
func(param, [CommentToken('\n\n', CommentMark(0)), None])
def object_to_yaml(self, key, type_, value, multi, object_path):
if isinstance(value, list):
if key == 'params':
new_values = CommentedMap()
else:
new_values = CommentedSeq()
for v in value:
new_value = self.object_to_yaml(key, type_, v, multi, object_path)
if key == 'params':
new_values.update(new_value)
else:
new_values.append(new_value)
return new_values
if isinstance(value, JinjaCalculation):
jinja = CommentedMap()
# replace \n to space a add index of \n (now a space) to fold_pos
jinja_values = value.jinja.strip()
if key == 'default' and not multi:
jinja["jinja"] = FoldedScalarString(jinja_values.replace('\n', ' '))
jinja["jinja"].fold_pos = [i for i, ltr in enumerate(jinja_values) if ltr == '\n']
else:
jinja["jinja"] = LiteralScalarString(jinja_values)
if value.return_type:
jinja["return_type"] = value.return_type
if value.description:
jinja["description"] = value.description
if value.params:
jinja["params"] = self.object_to_yaml("params", type_, value.params, multi, object_path)
return jinja
elif isinstance(value, Calculation):
variable_attributes = self.get_object_informations(value, ['path', 'inside_list', 'version', 'xmlfiles', 'attribute_name', 'namespace'])
variable = CommentedMap()
if isinstance(value, (IdentifierCalculation, IdentifierPropertyCalculation)):
variable["type"] = "identifier"
if isinstance(value, IndexCalculation):
variable["type"] = "index"
for key, default in variable_attributes.items():
val = getattr(value, key)
if val != default and val is not undefined:
variable[key] = val
if "variable" in variable:
variable["variable"] = self.calc_variable_path(object_path, variable["variable"])
if variable.get('type') == 'identifier' and 'identifier' in variable:
del variable["type"]
return variable
elif isinstance(value, Param):
param_attributes = self.get_object_informations(value, ["type", "key"])
if list(param_attributes) == ['value']:
variable = value.value
else:
variable = CommentedMap()
if isinstance(value, IdentifierParam):
variable["type"] = "identifier"
if isinstance(value, IndexParam):
variable["type"] = "index"
for key, default in param_attributes.items():
val = getattr(value, key)
if val != default and val is not undefined:
variable[key] = val
if variable.get('type') == 'identifier' and 'identifier' in variable:
del variable["type"]
if "variable" in variable:
variable["variable"] = self.calc_variable_path(object_path, variable["variable"])
return {value.key: variable}
elif type_ == 'port' and isinstance(value, str) and value.isnumeric():
return int(value)
return value
def calc_variable_path(self, object_path, variable_path):
if not variable_path.startswith("_"):
common_path = get_common_path(object_path, variable_path)
if not self.rougail.namespace or common_path:
if not common_path:
len_common_path = 0
else:
len_common_path = len(common_path) + 1
relative_object_path = object_path[len_common_path:]
final_path = "_" * (relative_object_path.count(".") + 1) + '.'
return "_" * (relative_object_path.count(".") + 1) + '.' + variable_path[len_common_path:]
return variable_path
def get_object_informations(self, value, excludes=[]):
return {attr: obj.get("default") for attr, obj in value.__class__.model_json_schema()["properties"].items() if attr not in excludes}
def get_parent_name(self, path):
if "." in path:
return path.rsplit(".", 1)
return None, path
def parse_yaml(self, path: str) -> dict:
def _yaml(y):
if not subpath:
return y
name = subpath.pop(0)
if name not in y and name.endswith('{{ identifier }}'):
name = name[:-16]
return _yaml(y[name])
if self.main_namespace:
subpath = path.split('.')[1:]
else:
subpath = path.split('.')
return _yaml(self.original_yaml)
RougailOutput = RougailOutputFormatter
__all__ = ("RougailOutputFormatter",)

View file

@ -0,0 +1,51 @@
"""
Silique (https://www.silique.fr)
Copyright (C) 2024
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from pathlib import Path
def get_rougail_config(
*,
backward_compatibility=True,
) -> dict:
options = """
load_unexist_redefine:
redefine: true
type: boolean
default:
jinja: >-
{% if step.output == 'formatter' %}
true
{% else %}
false
{% endif %}
hidden:
jinja: >-
{% if step.output == 'formatter' %}
load_unexist_redefine is always true with 'formatter' output
{% endif %}
"""
return {
"name": "formatter",
"process": "output",
"options": options,
"level": 90,
}
__all__ = ("get_rougail_config",)

View file

@ -0,0 +1,111 @@
"""Update Rougail structure file to new version
Cadoles (http://www.cadoles.com)
Copyright (C) 2021
Silique (https://www.silique.fr)
Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from ruamel.yaml import YAML, CommentedMap
from rougail import RougailConfig
VERSIONS = ["1.0", "1.1"]
def get_function_name(version):
version = version.replace(".", "_")
return f"update_{version}"
FUNCTION_VERSIONS = [(version, get_function_name(version)) for version in VERSIONS]
class RougailUpgrade:
def __init__(
self,
rougailconfig: RougailConfig = None,
) -> None:
self.rougailconfig = rougailconfig
def run(
self,
file,
):
with file.open() as file_fh:
root = YAML().load(file_fh)
search_function_name = get_function_name(str(root["version"]))
function_found = False
for version, function_version in FUNCTION_VERSIONS:
if function_found and hasattr(self, function_version):
root = getattr(self, function_version)(root)
if function_version == search_function_name:
function_found = True
if '_version' in root:
root["_version"] = float(version)
elif 'version' in root:
root["version"] = float(version)
return root
def update_1_1(
self,
root,
):
new_root = CommentedMap()
for key, value in root.items():
if not isinstance(value, dict):
if key == 'variable' and "{{ suffix }}" in value:
value = value.replace("{{ suffix }}", "{{ identifier }}")
new_root[key] = value
continue
# migrate dynamic family
if (
("variable" in value and isinstance(value["variable"], str))
or ("_variable" in value and isinstance(value["_variable"], str))
) and (
("_type" in value and value["_type"] == "dynamic")
or ("type" in value and value["type"] == "dynamic")
):
value["dynamic"] = {
"type": "variable",
"variable": value.pop("variable"),
"propertyerror": False,
}
if "{{ suffix }}" in key:
key = key.replace("{{ suffix }}", "{{ identifier }}")
elif "{{ identifier }}" not in key:
key = key + "{{ identifier }}"
value = self.update_1_1(value)
new_root[key] = value
for typ, obj in {
"boolean": bool,
"number": int,
"string": str,
"float": float,
}.items():
if value.get("type") == typ:
default = value.get("default")
if default is None or default == []:
continue
if isinstance(default, obj):
del value["type"]
elif isinstance(default, list) and isinstance(default[0], obj):
del value["type"]
if value.get("multi") and isinstance(value.get("default"), list):
del value["multi"]
return new_root

View file

@ -0,0 +1,4 @@
---
_version: 1.1
version: # a variable

View file

@ -0,0 +1,4 @@
---
version: 1.1
empty:

View file

@ -0,0 +1,12 @@
---
version: 1.1
var1: no # a first variable
var2:
description: a second variable
multi: true
default:
jinja: |-
{{ _.var1 }}
description: the value of var1

View file

@ -0,0 +1,17 @@
---
version: 1.1
var1: # a first variable
- no
- yes
- maybe
var2:
description: a second variable
multi: true
default:
jinja: |-
{% for val in _.var1 %}
{{ val }}
{% endfor %}
description: the value of _.var1

View file

@ -0,0 +1,14 @@
---
version: 1.1
var1:
description: a first variable
type: domainname
params:
allow_ip: true
multi: true
var2:
description: a second variable
default:
variable: _.var1

View file

@ -0,0 +1,4 @@
---
version: 1.1
var1: # a variable

View file

@ -0,0 +1,4 @@
---
version: 1.1
var2: # a variable

View file

@ -0,0 +1,4 @@
---
version: 1.1
without_type: non # a variable

View file

@ -0,0 +1,14 @@
---
version: 1.1
var1: true # the first variable
var2: true # the second variable
var3: true # the third variable
var4: false # the forth variable
var5: false # the fifth variable
var6: false # the sixth variable

View file

@ -0,0 +1,7 @@
---
version: 1.1
variable:
description: a variable
mandatory: false
default: true

View file

@ -0,0 +1,48 @@
---
version: 1.1
var1:
description: the first variable
choices:
- a
- b
- c
var2:
description: the second variable
choices:
- a
- b
- c
var3:
description: the third variable
choices:
- a
- b
- c
mandatory: false
var4:
description: the forth variable
choices:
-
- b
- c
mandatory: false
var5:
description: the fifth variable
choices:
- a
- b
- c
default: a
var6:
description: the sixth variable
choices:
- 1
- 2
- 3
default: 1

View file

@ -0,0 +1,13 @@
---
version: 1.1
var:
description: a variable
choices:
jinja: |-
{% for n in trange(0, 10) %}
{{ n }}
{% endfor %}
return_type: number
description: choices is 0 to 9
default: 9

View file

@ -0,0 +1,13 @@
---
version: 1.1
var1: # a second variable
- a
- b
- c
var2:
description: a first variable
choices:
variable: _.var1
default: a

View file

@ -0,0 +1,11 @@
---
version: 1.1
custom1:
description: the first variable
type: custom
custom2:
description: the seconf variable
type: custom
default: value

View file

@ -0,0 +1,7 @@
---
version: 1.1
variable:
description: a domain name variable
type: domainname
default: my.domain.name

View file

@ -0,0 +1,9 @@
---
version: 1.1
variable:
description: a domain name variable
type: domainname
params:
allow_ip: true
default: my.domain.name

View file

@ -0,0 +1,14 @@
---
version: 1.1
var1: 0.0 # the first variable
var2: 0.0 # the second variable
var3: 0.0 # the third variable
var4: 10.1 # the forth variable
var5: 10.1 # the fifth variable
var6: 10.1 # the sixth variable

View file

@ -0,0 +1,14 @@
---
version: 1.1
var1: 0 # the first variable
var2: 0 # the second variable
var3: 0 # the third variable
var4: 10 # this forth variable
var5: 10 # the fifth variable
var6: 10 # the sixth variable

View file

@ -0,0 +1,16 @@
---
version: 1.1
variable1:
description: a port variable
type: port
variable2:
description: a port variable with default value
type: port
default: 8080
variable3:
description: a port variable with integer default value
type: port
default: 8080

View file

@ -0,0 +1,10 @@
---
version: 1.1
var:
description: a first variable
test:
- '#b1b1b1'
- '#b2b2b2'
regexp: ^#(?:[0-9a-f]{3}){1,2}$
default: '#a1a1a1'

View file

@ -0,0 +1,14 @@
---
version: 1.1
var1: # the first variable
var2: # the second variable
var3: # the third variable
var4: value # the forth variable
var5: value # the fifth variable
var6: value # the sixth variable

View file

@ -0,0 +1,11 @@
---
version: 1.1
var:
description: A choice
type: choice
choices:
- quote'
- quote"
- quote"'
default: quote'

View file

@ -0,0 +1,10 @@
---
version: 1.1
var1:
description: the first variable
help: message with '
var2:
description: the second variable
help: message with "

View file

@ -0,0 +1,4 @@
---
version: 1.1
variable: quote" # a variable

View file

@ -0,0 +1,4 @@
---
version: 1.1
variable: quote'" # a variable

View file

@ -0,0 +1,4 @@
---
version: 1.1
variable: quote\"\' # a variable

View file

@ -0,0 +1,4 @@
---
version: 1.1
variable: quote' # a variable

View file

@ -0,0 +1,12 @@
---
version: 1.1
variable:
description: a variable
default:
jinja: >-
{{test_information }}
description: get information test_information
params:
test_information:
information: test_information

View file

@ -0,0 +1,40 @@
---
version: 1.1
var1:
description: the first variable
test:
- test
var2:
description: the second variable
test:
- test
default: value
var3:
description: the third variable
test:
- test1
- test2
var4:
description: the forth variable
test:
-
- test1
- test2
mandatory: false
var5:
description: the fifth variable
test:
- false
default: true
var6:
description: the sixth variable
test:
- test1
- test2
multi: true

View file

@ -0,0 +1,17 @@
---
version: 1.1
variable1:
description: a first variable
choices:
- val1
- val2
multi: true
variable2:
description: a second variable
choices:
- val1
- val2
multi: true
mandatory: false

View file

@ -0,0 +1,14 @@
---
version: 1.1
source_variable_1: val1 # the first source variable
source_variable_2: val2 # the second source variable
my_variable:
description: a variable
type: choice
choices:
- variable: _.source_variable_1
- variable: _.source_variable_2
default: val1

View file

@ -0,0 +1,14 @@
---
version: 1.1
variable:
description: a variable
default:
jinja: >-
{{ param1 }}_{{ param2 }}_{{ param3 }}_{{ param4 }}
description: concat all parameters
params:
param1: string
param2: 1
param3: true
param4:

View file

@ -0,0 +1,13 @@
---
version: 1.1
var:
description: a variable
default:
jinja: >-
{{ information }}
description: returns the information
params:
information:
information: test_information
variable: _.var

View file

@ -0,0 +1,14 @@
---
version: 1.1
var1: # a first variable
var2:
description: a second variable
default:
jinja: >-
{{ information }}
params:
information:
information: test_information
variable: _.var1

View file

@ -0,0 +1,10 @@
---
version: 1.1
my_variable: val1
my_calculated_variable:
- variable: _.my_variable
optional: true
- variable: _.my_variable_unexists
optional: true

View file

@ -0,0 +1,10 @@
---
version: 1.1
my_variable: val1
my_calculated_variable:
- variable: _.my_variable_unexists
optional: true
- variable: _.my_variable
optional: true

View file

@ -0,0 +1,8 @@
---
version: 1.1
my_calculated_variable:
multi: true
default:
variable: _.my_variable
optional: true

View file

@ -0,0 +1,12 @@
---
version: 1.1
my_variable:
- val1
- val2
my_calculated_variable:
multi: true
default:
variable: _.my_variable
optional: true

View file

@ -0,0 +1,23 @@
---
version: 1.1
var1:
description: a first variable
default:
jinja: >-
{% if var2 is defined %} {{ var2 }} {% elif var3 is defined %} {{ var3 }} {%
elif var4 is defined %} {{ var4 }} {% else %} {{ _.var2 }} {% endif %}
description: returns a value
params:
var2:
variable: _.var2
optional: true
var3:
variable: _.var3
optional: true
var4:
variable: _.unknown_family.var
optional: true
mandatory: false
var2: no # a second variable

View file

@ -0,0 +1,10 @@
---
version: 1.1
var1: # a first variable
var2:
description: a second variable
default:
information: test_information
variable: _.var1

View file

@ -0,0 +1,10 @@
---
version: 1.1
var1: # a first variable
var2:
description: a second variable
default:
information: test_information
variable: _.var1

View file

@ -0,0 +1,13 @@
---
version: 1.1
var:
description: a variable
choices:
jinja: |-
{% for item in trange(0, 10) %}
{{ item }}
{%- endfor %}
return_type: number
description: choice for 0 to 9
default: 9

View file

@ -0,0 +1,9 @@
---
version: 1.1
variable:
description: a variable
default:
jinja: >-
no
description: return no

View file

@ -0,0 +1,4 @@
---
version: 1.1
variable: rougail # a variable

View file

@ -0,0 +1,24 @@
---
version: 1.1
variable1:
description: a first variable
default:
variable: rougail.variable
variable2:
description: a second variable
default:
jinja: >-
{{ rougail.variable }}
description: copy the value of rougail.variable
variable3:
description: a third variable
default:
jinja: >-
{{ variable }}
description: copy the value of rougail.variable
params:
variable:
variable: rougail.variable

View file

@ -0,0 +1,4 @@
---
version: 1.1
variable: value # a variable

View file

@ -0,0 +1,4 @@
---
version: 1.1
variable: value in extra # a variable

View file

@ -0,0 +1,7 @@
---
version: 1.1
variable:
description: a variable
default:
variable: extra.variable

View file

@ -0,0 +1,26 @@
---
version: 1.1
var1: # the first variable
- true
var2: # the second variable
- true
var3: # the third variable
- true
var4: # the forth variable
- false
var5: # the fifth variable
- false
var6: # the sixth variable
- false
var7: # the seventh variable
- true
var8: # the eighth variable
- true

View file

@ -0,0 +1,13 @@
---
version: 1.1
custom1:
description: a first custom variable
type: custom
multi: true
custom2:
description: a second custom variable
type: custom
default:
- value

View file

@ -0,0 +1,26 @@
---
version: 1.1
var1: # the first variable
- 0.0
var2: # the second variable
- 0.0
var3: # the third variable
- 0.0
var4: # the forth variable
- 10.1
var5: # the fifth variable
- 10.1
var6: # the sixth variable
- 10.1
var7: # the seventh variable
- 0.0
var8: # the eighth variable
- 0.0

View file

@ -0,0 +1,26 @@
---
version: 1.1
var1: # the first variable
- 0
var2: # the second variable
- 0
var3: # the third variable
- 0
var4: # the forth variable
- 10
var5: # the fifth variable
- 10
var6: # the sixth variable
- 10
var7: # the seventh variable
- 0
var8: # the eighth variable
- 0

View file

@ -0,0 +1,9 @@
---
version: 1.1
var1:
description: the second variable
default:
- value
-
empty: false

View file

@ -0,0 +1,23 @@
---
version: 1.1
var1: [] # the first variable
var2: [] # the second variable
var3: [] # the third variable
var4: # the forth variable
- value
var5: # the fifth variable
- value
var6: # the sixth variable
- value
var7: # the seventh variable
- value
var8: # the eighth variable
- value

View file

@ -0,0 +1,5 @@
---
version: 1.1
variable: # a variable
- quote"

View file

@ -0,0 +1,5 @@
---
version: 1.1
variable: # a variable
- quote'"

View file

@ -0,0 +1,5 @@
---
version: 1.1
variable: # a variable
- quote'

View file

@ -0,0 +1,15 @@
---
version: 1.1
variable:
description: a variable
multi: true
default:
jinja: |-
{% for info in test_information %}
{{ info }}
{% endfor %}
description: get information test_information
params:
test_information:
information: test_information_list

View file

@ -0,0 +1,12 @@
---
version: 1.1
variable1: # a first variable
- a
- b
- c
variable2:
description: a second variable
choices:
variable: _.variable1

View file

@ -0,0 +1,9 @@
---
version: 1.1
int:
description: A limited number
params:
min_number: 0
max_number: 100
default: 10

View file

@ -0,0 +1,7 @@
---
version: 1.1
variable:
description: an auto save variable
default: no
auto_save: true

View file

@ -0,0 +1,10 @@
---
version: 1.1
var1: no # a first variable
var2:
description: a second variable
default:
variable: _.var1
auto_save: true

View file

@ -0,0 +1,18 @@
---
version: 1.1
var1: no # a first variable
var2:
description: a second variable
default:
jinja: >-
yes
description: the value is always yes
auto_save: true
hidden:
jinja: |-
{% if _.var1 == "yes" %}
_.var1 is yes
{% endif %}
description: only if the variable var1 has value "yes"

View file

@ -0,0 +1,9 @@
---
version: 1.1
var:
description: autosave variable
default: yes
auto_save: true
mandatory: false
hidden: true

View file

@ -0,0 +1,18 @@
---
version: 1.1
var1: value # a first variable
var2:
description: a second variable
disabled:
variable: _.var1
when: value
var3:
description: a third variable
default:
jinja: >-
{% if _.var1 == 'value' or _.var2 == 'blah' %}
value
{% endif %}

View file

@ -0,0 +1,18 @@
---
version: 1.1
var1: value # a first variable
var2:
description: a second variable
disabled:
variable: _.var1
when: value
var3:
description: a third variable
default:
jinja: >-
{% if _.var2 is propertyerror %}
value
{% endif %}

View file

@ -0,0 +1,22 @@
---
version: 1.1
condition: no # a conditional variable
variable1:
description: a first variable
disabled:
jinja: |-
{% if _.condition == "yes" %}
condition is yes
{% endif %}
description: if condition is egal to "yes"
variable2:
description: a second variable
disabled:
jinja: |-
{% if _.condition == "yes" %}
condition is yes
{% endif %}
description: if condition is egal to "yes"

View file

@ -0,0 +1,30 @@
---
version: 1.1
condition: no # a condition
var1:
description: a first variable
default:
jinja: >-
{{ _.condition }}
description: the value of condition
disabled:
jinja: |-
{% if _.condition == "yes" %}
condition is yes
{% endif %}
description: if condition is yes
var2:
description: a second variable
default:
jinja: >-
{{ rougail.condition }}
description: the value of condition
disabled:
jinja: |-
{% if rougail.condition == "yes" %}
condition is yes
{% endif %}
description: if condition is yes

View file

@ -0,0 +1,36 @@
---
version: 1.1
condition: no # a condition
var1:
description: a first variable
mandatory: false
hidden:
jinja: |-
{% if unknown is not defined %}
unknown is undefined
{% elif unknown == "no" %}
unknown is no
{% endif %}
description: calculation from an unknown variable
params:
unknown:
variable: _.unknown
optional: true
var2:
description: a second variable
mandatory: false
hidden:
jinja: |-
{% if condition is not defined %}
condition is undefined
{% elif condition == "no" %}
condition is no
{% endif %}
description: calculation from an condition variable
params:
condition:
variable: _.condition
optional: true

View file

@ -0,0 +1,9 @@
---
version: 1.1
condition: false # a condition
variable:
description: a variable
disabled:
variable: _.condition

View file

@ -0,0 +1,9 @@
---
version: 1.1
condition: true # a condition
variable:
description: a variable
disabled:
variable: _.condition

View file

@ -0,0 +1,10 @@
---
version: 1.1
condition: yes # a condition
variable:
description: a variable
disabled:
variable: _.condition
when: yes

View file

@ -0,0 +1,10 @@
---
version: 1.1
condition: yes # a condition
variable:
description: a variable
disabled:
variable: _.condition
when_not: yes

View file

@ -0,0 +1,24 @@
---
version: 1.1
condition: no # the condition
var1:
description: a first variable
default: no
hidden:
jinja: |-
{% if _.condition == "yes" %}
condition is yes
{% endif %}
description: if condition is yes
var2:
description: a second variable
default: no
hidden:
jinja: |-
{% if rougail.condition == "yes" %}
condition is yes
{% endif %}
description: if condition is yes

View file

@ -0,0 +1,30 @@
---
version: 1.1
condition: no # a condition
var1:
description: a first variable
default:
jinja: >-
{{ _.condition }}
description: the value of condition
hidden:
jinja: |-
{% if _.condition != "yes" %}
condition is yes
{% endif %}
description: if condition is yes
var2:
description: a second variable
default:
jinja: >-
{{ rougail.condition }}
description: the value of condition
hidden:
jinja: |-
{% if rougail.condition != "yes" %}
condition is yes
{% endif %}
description: if condition is yes

View file

@ -0,0 +1,30 @@
---
version: 1.1
condition: no # a condition
var1:
description: a first variable
default:
jinja: >-
{{ _.condition }}
description: returns the condition value
hidden:
jinja: |-
{% if _.condition == "yes" %}
condition is yes
{% endif %}
description: if condition is yes
var2:
description: a second variable
default:
jinja: >-
{{ rougail.condition }}
description: returns the condition value
hidden:
jinja: |-
{% if rougail.condition == "yes" %}
condition is yes
{% endif %}
description: if condition is yes

View file

@ -0,0 +1,12 @@
---
version: 1.1
int:
description: A number
type: number
validators:
- jinja: |-
{% if _.int > 100 %}
value is too high
{% endif %}
description: the max value is 100

View file

@ -0,0 +1,16 @@
---
version: 1.1
var1:
description: a first variable
test:
- another_value
validators:
- jinja: |-
{% if _.var1 == _.var2 %}
var1 must be different than var2
{% endif %}
description: var1 must be different than var2
default: oui
var2: no # A second variable

View file

@ -0,0 +1,14 @@
---
version: 1.1
var1:
description: a second variable
validators:
- jinja: |-
{% if _.var1 | length > 9 %}
length must be less than 10
{% endif %}
description: check length is less than 10
default:
- no
- yes

View file

@ -0,0 +1,21 @@
---
version: 1.1
var1:
description: a second variable
test:
- val1
- val2
validators:
- jinja: |-
{% if values | length > 2 %}
length must be less than 3
{% endif %}
description: check length is less than 3
params:
values:
variable: _.var1
whole: true
default:
- no
- yes

View file

@ -0,0 +1,8 @@
---
version: 1.1
var1:
description: a variable
default:
- non
unique: false

View file

@ -0,0 +1,8 @@
---
version: 1.1
variable:
description: a variable
default:
- non
unique: true

View file

@ -0,0 +1,8 @@
---
version: 1.1
var:
description: a variable
mode: advanced
default: no
auto_save: true

View file

@ -0,0 +1,4 @@
---
version: 1.1
var: # Redefine description

View file

@ -0,0 +1,6 @@
---
version: 1.1
var:
redefine: true
description: Redefined

View file

@ -0,0 +1,6 @@
---
version: 1.1
family:
var1:

View file

@ -0,0 +1,8 @@
---
version: 1.1
family:
redefine: true
disabled:
jinja: |-
true

View file

@ -0,0 +1,6 @@
---
version: 1.1
family:
var1:

View file

@ -0,0 +1,6 @@
---
version: 1.1
family:
redefine: true
disabled: true

View file

@ -0,0 +1,4 @@
---
version: 1.1
var1: no # a variable

View file

@ -0,0 +1,7 @@
---
version: 1.1
var2:
exists: false
description: a new variable
default: yes

View file

@ -0,0 +1,8 @@
---
version: 1.1
var1:
description: a first variable
default: no
mandatory: false
hidden: true

View file

@ -0,0 +1,13 @@
---
version: 1.1
var1:
redefine: true
exists: true
default: yes
var2:
redefine: true
exists: true
description: a second variable
default: yes

View file

@ -0,0 +1,9 @@
---
version: 1.1
variable:
description: a variable
default:
jinja: >-
no
description: returns no

View file

@ -0,0 +1,9 @@
---
version: 1.1
variable:
redefine: true
default:
jinja: >-
yes
description: returns yes

View file

@ -0,0 +1,9 @@
---
version: 1.1
variable:
description: a variable
choices:
- a
- b
- c

View file

@ -0,0 +1,8 @@
---
version: 1.1
variable:
redefine: true
choices:
- a
- b

Some files were not shown because too many files have changed in this diff Show more