Compare commits

..

No commits in common. "1858eeeb06c2d704b5cb0466466d133e55f6b7f9" and "18df35acfec2a0dc614d142db4eb6efdd526533a" have entirely different histories.

33 changed files with 31 additions and 303 deletions

View file

@ -47,7 +47,6 @@ class Annotator(Walk): # pylint: disable=R0903
self.objectspace = objectspace self.objectspace = objectspace
self.convert_value() self.convert_value()
self.valid_choices() self.valid_choices()
self.valid_regexp()
def convert_value(self) -> None: def convert_value(self) -> None:
"""convert value""" """convert value"""
@ -115,7 +114,7 @@ class Annotator(Walk): # pylint: disable=R0903
if isinstance(variable.choices, Calculation): if isinstance(variable.choices, Calculation):
continue continue
if variable.choices is None: if variable.choices is None:
msg = _(f'the variable "{variable.path}" is a "choice" variable but don\'t have any choice') msg = f'the variable "{variable.path}" is a "choice" variable but don\'t have any choice'
raise DictConsistencyError(msg, 19, variable.xmlfiles) raise DictConsistencyError(msg, 19, variable.xmlfiles)
if not variable.mandatory and not variable.multi: if not variable.mandatory and not variable.multi:
self.add_choice_nil(variable) self.add_choice_nil(variable)
@ -126,11 +125,3 @@ class Annotator(Walk): # pylint: disable=R0903
if choice is None: if choice is None:
return return
variable.choices.append(None) variable.choices.append(None)
def valid_regexp(self) -> None:
for variable in self.get_variables():
if variable.type != "regexp":
continue
if variable.regexp is None:
msg = _(f'the variable "{variable.path}" is a "regexp" variable but don\'t have any regexp')
raise DictConsistencyError(msg, 66, variable.xmlfiles)

View file

@ -154,10 +154,6 @@ class Annotator(Walk): # pylint: disable=R0903
variable.type = calculated_variable.type variable.type = calculated_variable.type
if variable.params is None and calculated_variable.params is not None: if variable.params is None and calculated_variable.params is not None:
variable.params = calculated_variable.params variable.params = calculated_variable.params
if variable.type == 'choice' and variable.choices is None:
variable.choices = calculated_variable.choices
if variable.type == 'regexp' and variable.regexp is None:
variable.regexp = calculated_variable.regexp
# copy multi attribut # copy multi attribut
if variable.multi is None: if variable.multi is None:
calculated_path = calculated_variable.path calculated_path = calculated_variable.path

View file

@ -657,10 +657,9 @@ class ParserVariable:
if comment: if comment:
obj["description"] = comment obj["description"] = comment
if extra_attrs: if extra_attrs:
raise DictConsistencyError( raise Exception(
f'"{path}" is not a valid variable, there are additional ' f'"{path}" is not a valid variable, there are additional '
f'attributes: "{", ".join(extra_attrs)}"', f'attributes: "{", ".join(extra_attrs)}"'
65, [filename]
) )
self.parse_parameters( self.parse_parameters(
path, path,

View file

@ -1,10 +0,0 @@
{
"rougail.var1": {
"owner": "default",
"value": null
},
"rougail.var2": {
"owner": "default",
"value": null
}
}

View file

@ -1,4 +0,0 @@
{
"rougail.var1": null,
"rougail.var2": null
}

View file

@ -1,10 +0,0 @@
{
"rougail.var1": {
"owner": "default",
"value": null
},
"rougail.var2": {
"owner": "default",
"value": null
}
}

View file

@ -1 +0,0 @@
["rougail.var1", "rougail.var2"]

View file

@ -1,16 +0,0 @@
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py')
try:
groups.namespace
except:
groups.addgroup('namespace')
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced")
option_2 = ChoiceOption(name="var1", doc="the first variable", values=("a", "b", "c"), properties=frozenset({"basic", "mandatory"}), informations={'type': 'choice'})
option_3 = ChoiceOption(name="var2", doc="the second variable", values=("a", "b", "c"), default=Calculation(func['calc_value'], Params((ParamOption(option_2)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'choice'})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3], properties=frozenset({"basic"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -1,11 +0,0 @@
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py')
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced")
option_1 = ChoiceOption(name="var1", doc="the first variable", values=("a", "b", "c"), properties=frozenset({"basic", "mandatory"}), informations={'type': 'choice'})
option_2 = ChoiceOption(name="var2", doc="the second variable", values=("a", "b", "c"), default=Calculation(func['calc_value'], Params((ParamOption(option_1)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'choice'})
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2])

View file

@ -1,18 +0,0 @@
{
"rougail.var1": {
"owner": "default",
"value": [
"a",
"b",
"c"
]
},
"rougail.var2": {
"owner": "default",
"value": "a"
},
"rougail.var3": {
"owner": "default",
"value": "a"
}
}

View file

@ -1,9 +0,0 @@
{
"rougail.var1": [
"a",
"b",
"c"
],
"rougail.var2": "a",
"rougail.var3": "a"
}

View file

@ -1,18 +0,0 @@
{
"rougail.var1": {
"owner": "default",
"value": [
"a",
"b",
"c"
]
},
"rougail.var2": {
"owner": "default",
"value": "a"
},
"rougail.var3": {
"owner": "default",
"value": "a"
}
}

View file

@ -1,17 +0,0 @@
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py')
try:
groups.namespace
except:
groups.addgroup('namespace')
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced")
option_2 = StrOption(name="var1", doc="a second variable", multi=True, default=["a", "b", "c"], default_multi="a", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_3 = ChoiceOption(name="var2", doc="a first variable", values=Calculation(func['calc_value'], Params((ParamOption(option_2)))), default="a", properties=frozenset({"mandatory", "standard"}), informations={'type': 'choice'})
option_4 = ChoiceOption(name="var3", doc="a third variable", values=Calculation(func['calc_value'], Params((ParamOption(option_2)))), default=Calculation(func['calc_value'], Params((ParamOption(option_3)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'choice'})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3, option_4], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -1,12 +0,0 @@
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py')
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced")
option_1 = StrOption(name="var1", doc="a second variable", multi=True, default=["a", "b", "c"], default_multi="a", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_2 = ChoiceOption(name="var2", doc="a first variable", values=Calculation(func['calc_value'], Params((ParamOption(option_1)))), default="a", properties=frozenset({"mandatory", "standard"}), informations={'type': 'choice'})
option_3 = ChoiceOption(name="var3", doc="a third variable", values=Calculation(func['calc_value'], Params((ParamOption(option_1)))), default=Calculation(func['calc_value'], Params((ParamOption(option_2)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'choice'})
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2, option_3])

View file

@ -1,18 +0,0 @@
{
"rougail.var1": {
"owner": "default",
"value": [
"a",
"b",
"c"
]
},
"rougail.var2": {
"owner": "default",
"value": "a"
},
"rougail.family.var3": {
"owner": "default",
"value": "a"
}
}

View file

@ -1,9 +0,0 @@
{
"rougail.var1": [
"a",
"b",
"c"
],
"rougail.var2": "a",
"rougail.family.var3": "a"
}

View file

@ -1,18 +0,0 @@
{
"rougail.var1": {
"owner": "default",
"value": [
"a",
"b",
"c"
]
},
"rougail.var2": {
"owner": "default",
"value": "a"
},
"rougail.family.var3": {
"owner": "default",
"value": "a"
}
}

View file

@ -1,18 +0,0 @@
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py')
try:
groups.namespace
except:
groups.addgroup('namespace')
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced")
option_2 = StrOption(name="var1", doc="a second variable", multi=True, default=["a", "b", "c"], default_multi="a", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_3 = ChoiceOption(name="var2", doc="a first variable", values=Calculation(func['calc_value'], Params((ParamOption(option_2)))), default="a", properties=frozenset({"mandatory", "standard"}), informations={'type': 'choice'})
option_5 = ChoiceOption(name="var3", doc="a third variable", values=Calculation(func['calc_value'], Params((ParamOption(option_2)))), default=Calculation(func['calc_value'], Params((ParamOption(option_3)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'choice'})
optiondescription_4 = OptionDescription(name="family", doc="family", children=[option_5], properties=frozenset({"standard"}))
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3, optiondescription_4], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -1,13 +0,0 @@
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py')
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced")
option_1 = StrOption(name="var1", doc="a second variable", multi=True, default=["a", "b", "c"], default_multi="a", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_2 = ChoiceOption(name="var2", doc="a first variable", values=Calculation(func['calc_value'], Params((ParamOption(option_1)))), default="a", properties=frozenset({"mandatory", "standard"}), informations={'type': 'choice'})
option_4 = ChoiceOption(name="var3", doc="a third variable", values=Calculation(func['calc_value'], Params((ParamOption(option_1)))), default=Calculation(func['calc_value'], Params((ParamOption(option_2)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'choice'})
optiondescription_3 = OptionDescription(name="family", doc="family", children=[option_4], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2, optiondescription_3])

View file

@ -1,26 +0,0 @@
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py')
try:
groups.namespace
except:
groups.addgroup('namespace')
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced")
class Regexp_option_2(RegexpOption):
__slots__ = tuple()
_type = 'value'
Regexp_option_2._regexp = re_compile(r"^#(?:[0-9a-f]{3}){1,2}$")
class Regexp_option_3(RegexpOption):
__slots__ = tuple()
_type = 'value'
Regexp_option_3._regexp = re_compile(r"^#(?:[0-9a-f]{3}){1,2}$")
option_2 = Regexp_option_2(name="var1", doc="a first variable", default="#a1a1a1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'regexp', 'test': ('#b1b1b1', '#b2b2b2')})
option_3 = Regexp_option_3(name="var2", doc="a second variable", default=Calculation(func['calc_value'], Params((ParamOption(option_2)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'regexp'})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -1,21 +0,0 @@
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py')
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced")
class Regexp_option_1(RegexpOption):
__slots__ = tuple()
_type = 'value'
Regexp_option_1._regexp = re_compile(r"^#(?:[0-9a-f]{3}){1,2}$")
class Regexp_option_2(RegexpOption):
__slots__ = tuple()
_type = 'value'
Regexp_option_2._regexp = re_compile(r"^#(?:[0-9a-f]{3}){1,2}$")
option_1 = Regexp_option_1(name="var1", doc="a first variable", default="#a1a1a1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'regexp', 'test': ('#b1b1b1', '#b2b2b2')})
option_2 = Regexp_option_2(name="var2", doc="a second variable", default=Calculation(func['calc_value'], Params((ParamOption(option_1)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'regexp'})
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2])

View file

@ -6,9 +6,5 @@
"rougail.secret2": { "rougail.secret2": {
"owner": "default", "owner": "default",
"value": "value" "value": "value"
},
"rougail.secret3": {
"owner": "default",
"value": "value"
} }
} }

View file

@ -1,5 +1,4 @@
{ {
"rougail.secret1": null, "rougail.secret1": null,
"rougail.secret2": "value", "rougail.secret2": "value"
"rougail.secret3": "value"
} }

View file

@ -6,9 +6,5 @@
"rougail.secret2": { "rougail.secret2": {
"owner": "default", "owner": "default",
"value": "value" "value": "value"
},
"rougail.secret3": {
"owner": "default",
"value": "value"
} }
} }

View file

@ -12,6 +12,5 @@ ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")
option_2 = PasswordOption(name="secret1", doc="the first variable", min_len=10, properties=frozenset({"basic", "mandatory"}), informations={'type': 'secret'}) option_2 = PasswordOption(name="secret1", doc="the first variable", min_len=10, properties=frozenset({"basic", "mandatory"}), informations={'type': 'secret'})
option_3 = PasswordOption(name="secret2", doc="the second variable", default="value", max_len=10, forbidden_char=['$', '^'], properties=frozenset({"mandatory", "standard"}), informations={'type': 'secret'}) option_3 = PasswordOption(name="secret2", doc="the second variable", default="value", max_len=10, forbidden_char=['$', '^'], properties=frozenset({"mandatory", "standard"}), informations={'type': 'secret'})
option_4 = PasswordOption(name="secret3", doc="the third variable", default="value", max_len=10, forbidden_char=['$'], properties=frozenset({"mandatory", "standard"}), informations={'type': 'secret'}) optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3], properties=frozenset({"basic"}))
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3, option_4], properties=frozenset({"basic"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -8,5 +8,4 @@ ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")
option_1 = PasswordOption(name="secret1", doc="the first variable", min_len=10, properties=frozenset({"basic", "mandatory"}), informations={'type': 'secret'}) option_1 = PasswordOption(name="secret1", doc="the first variable", min_len=10, properties=frozenset({"basic", "mandatory"}), informations={'type': 'secret'})
option_2 = PasswordOption(name="secret2", doc="the second variable", default="value", max_len=10, forbidden_char=['$', '^'], properties=frozenset({"mandatory", "standard"}), informations={'type': 'secret'}) option_2 = PasswordOption(name="secret2", doc="the second variable", default="value", max_len=10, forbidden_char=['$', '^'], properties=frozenset({"mandatory", "standard"}), informations={'type': 'secret'})
option_3 = PasswordOption(name="secret3", doc="the third variable", default="value", max_len=10, forbidden_char=['$'], properties=frozenset({"mandatory", "standard"}), informations={'type': 'secret'}) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2])
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2, option_3])

View file

@ -1,5 +0,0 @@
---
version: '1.1'
var:
description: a first variable
type: regexp

View file

@ -1,8 +0,0 @@
---
version: 1.1
variable:
description: a variable
disabled:
variable: _.unknown_variable
when: false

View file

@ -16,7 +16,6 @@ logger = logging.getLogger()
logger.setLevel(logging.INFO) logger.setLevel(logging.INFO)
dico_dirs = Path('../rougail-tests/structures') dico_dirs = Path('../rougail-tests/structures')
errors_dirs = Path('tests/errors')
rougail_test_dirs = Path('tests/dictionaries') rougail_test_dirs = Path('tests/dictionaries')
@ -36,10 +35,9 @@ def get_rougail_tests_dir(original_dir):
for test in dico_dirs.iterdir(): for test in dico_dirs.iterdir():
if test.is_dir(): if test.is_dir():
if rougail_test_dirs / 'test' / 'tiramisu':
test_ok.add(test.name) test_ok.add(test.name)
elif test != '__pycache__':
for test in errors_dirs.iterdir():
if test.is_dir():
test_raise.add(test.name) test_raise.add(test.name)
excludes = set([ excludes = set([
@ -126,7 +124,7 @@ def save(test_dir, eolobj, multi=False, namespace=False, error=False):
tiramisu_dir = dirname(tiramisu_file) tiramisu_dir = dirname(tiramisu_file)
if not error: if not error:
if not isdir(tiramisu_dir): if not isdir(tiramisu_dir):
makedirs(tiramisu_dir) raise Exception(f'please creates {tiramisu_dir}')
if not isfile(tiramisu_file) or debug: if not isfile(tiramisu_file) or debug:
copyfile(tiramisu_tmp, tiramisu_file) copyfile(tiramisu_tmp, tiramisu_file)
with open(tiramisu_tmp, 'r') as fh: with open(tiramisu_tmp, 'r') as fh:
@ -170,11 +168,30 @@ def test_dictionary_namespace(test_dir):
return return
save(test_dir_, eolobj, namespace=True) save(test_dir_, eolobj, namespace=True)
assert getcwd() == ORI_DIR assert getcwd() == ORI_DIR
#
#
#def test_dictionary_multi(test_dir):
# if not test_multi:
# print('MULTI!')
# return
# assert getcwd() == ORI_DIR
# test_dir_ = join(dico_dirs, test_dir)
# rougailconfig = RougailConfig.copy()
# rougailconfig['main_namespace'] = 'Rougail'
# if (dico_dirs / test_dir / 'force_no_namespace').is_file():
# return
# eolobj = load_rougail_object(test_dir_, rougailconfig, multi=True)
# if not eolobj:
# return
# eolobj.add_path_prefix('1')
# eolobj.add_path_prefix('2')
# save(test_dir_, eolobj, multi=True)
# assert getcwd() == ORI_DIR
def test_error_dictionary(test_dir_error): def test_error_dictionary(test_dir_error):
assert getcwd() == ORI_DIR assert getcwd() == ORI_DIR
test_dir_ = join(errors_dirs, test_dir_error) test_dir_ = join(dico_dirs, test_dir_error)
errno = [] errno = []
rougailconfig = RougailConfig.copy() rougailconfig = RougailConfig.copy()
rougailconfig['main_namespace'] = 'Rougail' rougailconfig['main_namespace'] = 'Rougail'