corrections in dict and todict
This commit is contained in:
parent
503d4b2cca
commit
52ddd76b1a
|
@ -1,12 +1,14 @@
|
||||||
from tiramisu.option import ChoiceOption, StrOption, OptionDescription
|
from tiramisu import ChoiceOption, StrOption, OptionDescription, Calculation, ParamValue, ParamOption, Params, calc_value
|
||||||
|
|
||||||
def get_description():
|
def get_description():
|
||||||
"""generate description for this test
|
"""generate description for this test
|
||||||
"""
|
"""
|
||||||
option1 = ChoiceOption('choice', "Choice description", ("hide", "show"), default='hide', properties=('mandatory',))
|
option1 = ChoiceOption('choice', "Choice description", ("hide", "show"), default='hide', properties=('mandatory',))
|
||||||
option2 = StrOption('unicode2', "Unicode 2", requires=[{'option': option1,
|
hidden_property = Calculation(calc_value,
|
||||||
'expected': 'hide',
|
Params(ParamValue('hidden'),
|
||||||
'action': 'hidden'}])
|
kwargs={'condition': ParamOption(option1, todict=True),
|
||||||
|
'expected': ParamValue('hide')}))
|
||||||
|
option2 = StrOption('unicode2', "Unicode 2", properties=(hidden_property,))
|
||||||
descr1 = OptionDescription("options", "Common configuration", [option1, option2])
|
descr1 = OptionDescription("options", "Common configuration", [option1, option2])
|
||||||
descr = OptionDescription("choice1_requires", "Choice with requirement", [descr1])
|
descr = OptionDescription("choice1_requires", "Choice with requirement", [descr1])
|
||||||
return descr
|
return descr
|
||||||
|
|
|
@ -35,7 +35,10 @@
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"options.unicode.unicode": {
|
"options.unicode.unicode": {
|
||||||
"required": true
|
"required": true,
|
||||||
|
"properties": [
|
||||||
|
"unique"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"global": {
|
"global": {
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
from tiramisu.option import StrOption, OptionDescription
|
from tiramisu import StrOption, OptionDescription, Leadership, Calculation, ParamValue, ParamOption, Params, calc_value
|
||||||
from tiramisu import Leadership
|
|
||||||
|
|
||||||
|
|
||||||
def get_description():
|
def get_description():
|
||||||
"""generate description for this test
|
"""generate description for this test
|
||||||
|
@ -8,11 +6,12 @@ def get_description():
|
||||||
option = StrOption('unicode', "Unicode leader", multi=True)
|
option = StrOption('unicode', "Unicode leader", multi=True)
|
||||||
option1 = StrOption('unicode1', "Unicode follower 1", multi=True)
|
option1 = StrOption('unicode1', "Unicode follower 1", multi=True)
|
||||||
option2 = StrOption('unicode2', "Values 'test' must show 'Unicode follower 3'", multi=True)
|
option2 = StrOption('unicode2', "Values 'test' must show 'Unicode follower 3'", multi=True)
|
||||||
option3 = StrOption('unicode3', "Unicode follower 3", requires=[{'option': option2,
|
hidden_property = Calculation(calc_value,
|
||||||
'expected': u'test',
|
Params(ParamValue('hidden'),
|
||||||
'action': 'hidden',
|
kwargs={'condition': ParamOption(option2, todict=True),
|
||||||
'inverse': True}],
|
'expected': ParamValue('test'),
|
||||||
multi=True)
|
'reverse_condition': ParamValue(True)}))
|
||||||
|
option3 = StrOption('unicode3', "Unicode follower 3", properties=(hidden_property,), multi=True)
|
||||||
descr1 = Leadership("unicode", "Common configuration 1",
|
descr1 = Leadership("unicode", "Common configuration 1",
|
||||||
[option, option1, option2, option3])
|
[option, option1, option2, option3])
|
||||||
descr = OptionDescription("options", "Common configuration 2", [descr1])
|
descr = OptionDescription("options", "Common configuration 2", [descr1])
|
||||||
|
|
|
@ -34,13 +34,15 @@
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"options.unicode1": {
|
"options.unicode1": {
|
||||||
"display": false,
|
|
||||||
"properties": [
|
"properties": [
|
||||||
"hidden"
|
"hidden"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"options.unicode1.unicode1": {
|
"options.unicode1.unicode1": {
|
||||||
"required": true,
|
"required": true,
|
||||||
|
"properties": [
|
||||||
|
"unique"
|
||||||
|
],
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"display": false
|
"display": false
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from tiramisu.option import StrOption, OptionDescription
|
from tiramisu import StrOption, OptionDescription, Leadership, Calculation, ParamValue, ParamOption, Params, calc_value
|
||||||
from tiramisu import Leadership
|
|
||||||
|
|
||||||
|
|
||||||
def get_description():
|
def get_description():
|
||||||
|
@ -9,11 +8,13 @@ def get_description():
|
||||||
option1 = StrOption('unicode1', "Unicode leader", multi=True)
|
option1 = StrOption('unicode1', "Unicode leader", multi=True)
|
||||||
option2 = StrOption('unicode2', "Unicode follower 1", multi=True)
|
option2 = StrOption('unicode2', "Unicode follower 1", multi=True)
|
||||||
option3 = StrOption('unicode3', "Unicode follower 2", multi=True)
|
option3 = StrOption('unicode3', "Unicode follower 2", multi=True)
|
||||||
|
hidden_property = Calculation(calc_value,
|
||||||
|
Params(ParamValue('hidden'),
|
||||||
|
kwargs={'condition': ParamOption(option, todict=True),
|
||||||
|
'expected': ParamValue('test'),
|
||||||
|
'reverse_condition': ParamValue(True)}))
|
||||||
descr1 = Leadership("unicode1", "Common configuration",
|
descr1 = Leadership("unicode1", "Common configuration",
|
||||||
[option1, option2, option3], requires=[{'option': option,
|
[option1, option2, option3], properties=(hidden_property,))
|
||||||
'expected': u'test',
|
|
||||||
'action': 'hidden',
|
|
||||||
'inverse': True}])
|
|
||||||
descr = OptionDescription("options", "Common configuration", [option, descr1])
|
descr = OptionDescription("options", "Common configuration", [option, descr1])
|
||||||
descr = OptionDescription("unicode1_leadership_requires_all", "Leader follower with requirement", [descr])
|
descr = OptionDescription("unicode1_leadership_requires_all", "Leader follower with requirement", [descr])
|
||||||
return descr
|
return descr
|
||||||
|
|
|
@ -3,46 +3,75 @@
|
||||||
"options": {
|
"options": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"options.unicode": {
|
"options.unicode": {
|
||||||
"type": "string",
|
|
||||||
"title": "Value 'test' must show leader"
|
|
||||||
},
|
|
||||||
"options.unicode1": {
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"options.unicode1.unicode1": {
|
"options.unicode.unicode": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"isMulti": true,
|
"isMulti": true,
|
||||||
"title": "Unicode leader"
|
"title": "Values 'test' must show 'Unicode follower 3'"
|
||||||
},
|
},
|
||||||
"options.unicode1.unicode2": {
|
"options.unicode.unicode1": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"isMulti": true,
|
"isMulti": true,
|
||||||
"title": "Unicode follower 1"
|
"title": "Unicode follower 1"
|
||||||
},
|
},
|
||||||
"options.unicode1.unicode3": {
|
"options.unicode.unicode2": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"isMulti": true,
|
"isMulti": true,
|
||||||
"title": "Unicode follower 2"
|
"title": "Unicode follower 2"
|
||||||
|
},
|
||||||
|
"options.unicode.unicode3": {
|
||||||
|
"type": "string",
|
||||||
|
"isMulti": true,
|
||||||
|
"title": "Unicode follower 3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"title": "Common configuration"
|
"title": "Common configuration 1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"title": "Common configuration"
|
"title": "Common configuration 2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"options.unicode1": {
|
"options.unicode.unicode": {
|
||||||
"display": false,
|
|
||||||
"properties": [
|
|
||||||
"hidden"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"options.unicode1.unicode1": {
|
|
||||||
"required": true,
|
"required": true,
|
||||||
|
"properties": [
|
||||||
|
"unique"
|
||||||
|
],
|
||||||
|
"value": [
|
||||||
|
"test",
|
||||||
|
"val2"
|
||||||
|
],
|
||||||
|
"owner": "user"
|
||||||
|
},
|
||||||
|
"options.unicode.unicode1": {
|
||||||
|
"0": {
|
||||||
|
"value": "super1",
|
||||||
|
"owner": "user"
|
||||||
|
},
|
||||||
|
"1": {
|
||||||
|
"value": "super2",
|
||||||
|
"owner": "user"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"options.unicode.unicode2": {
|
||||||
|
"0": {
|
||||||
|
"value": "pas test",
|
||||||
|
"owner": "user"
|
||||||
|
},
|
||||||
|
"1": {
|
||||||
|
"value": "test",
|
||||||
|
"owner": "user"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"options.unicode.unicode3": {
|
||||||
|
"1": {
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"display": false
|
"display": false,
|
||||||
|
"value": "super",
|
||||||
|
"owner": "user"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"global": {
|
"global": {
|
||||||
|
@ -62,33 +91,33 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"form": {
|
"form": {
|
||||||
"options.unicode": {
|
"options.unicode.unicode": {
|
||||||
"clearable": true,
|
"clearable": true,
|
||||||
"type": "input",
|
"type": "input",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"default": {
|
"default": {
|
||||||
"hide": [
|
"hide": [
|
||||||
"options.unicode1"
|
"options.unicode.unicode3"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"expected": {
|
"expected": {
|
||||||
"test": {
|
"test": {
|
||||||
"show": [
|
"show": [
|
||||||
"options.unicode1"
|
"options.unicode.unicode3"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"options.unicode1.unicode1": {
|
"options.unicode.unicode1": {
|
||||||
"clearable": true,
|
"clearable": true,
|
||||||
"type": "input"
|
"type": "input"
|
||||||
},
|
},
|
||||||
"options.unicode1.unicode2": {
|
"options.unicode.unicode2": {
|
||||||
"clearable": true,
|
"clearable": true,
|
||||||
"type": "input"
|
"type": "input"
|
||||||
},
|
},
|
||||||
"options.unicode1.unicode3": {
|
"options.unicode.unicode3": {
|
||||||
"clearable": true,
|
"clearable": true,
|
||||||
"type": "input"
|
"type": "input"
|
||||||
},
|
},
|
|
@ -0,0 +1,33 @@
|
||||||
|
from tiramisu import StrOption, OptionDescription, Leadership, Calculation, ParamValue, ParamOption, Params, calc_value
|
||||||
|
|
||||||
|
|
||||||
|
def get_description():
|
||||||
|
"""generate description for this test
|
||||||
|
"""
|
||||||
|
option = StrOption('unicode', "Values 'test' must show 'Unicode follower 3'", multi=True)
|
||||||
|
option1 = StrOption('unicode1', "Unicode follower 1", multi=True)
|
||||||
|
option2 = StrOption('unicode2', "Unicode follower 2", multi=True)
|
||||||
|
disabled_property = Calculation(calc_value,
|
||||||
|
Params(ParamValue('disabled'),
|
||||||
|
kwargs={'condition': ParamOption(option, todict=True),
|
||||||
|
'expected': ParamValue('test'),
|
||||||
|
'reverse_condition': ParamValue(True)}))
|
||||||
|
option3 = StrOption('unicode3', "Unicode follower 3", properties=(disabled_property,), multi=True)
|
||||||
|
descr1 = Leadership("unicode", "Common configuration 1",
|
||||||
|
[option, option1, option2, option3])
|
||||||
|
descr = OptionDescription("options", "Common configuration 2", [descr1])
|
||||||
|
descr = OptionDescription("unicode1_leadership_requires_disabled_value", "Leader followers with Unicode follower 3 disabled when Unicode follower 2 is test and modified value", [descr])
|
||||||
|
return descr
|
||||||
|
|
||||||
|
|
||||||
|
async def get_values(api, allpath=False):
|
||||||
|
if allpath:
|
||||||
|
root = 'unicode1_leadership_requires_disabled_value.'
|
||||||
|
else:
|
||||||
|
root = ''
|
||||||
|
await api.option(root + 'options.unicode.unicode').value.set([u'test', u'val2'])
|
||||||
|
await api.option(root + 'options.unicode.unicode1', 0).value.set(u'super1')
|
||||||
|
await api.option(root + 'options.unicode.unicode1', 1).value.set(u'super2')
|
||||||
|
await api.option(root + 'options.unicode.unicode2', 0).value.set(u'pas test')
|
||||||
|
await api.option(root + 'options.unicode.unicode2', 1).value.set(u'test')
|
||||||
|
await api.option(root + 'options.unicode.unicode3', 1).value.set(u'super')
|
|
@ -30,7 +30,10 @@
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"options.unicode1.unicode1": {
|
"options.unicode1.unicode1": {
|
||||||
"required": true
|
"required": true,
|
||||||
|
"properties": [
|
||||||
|
"unique"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"global": {
|
"global": {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from tiramisu.option import StrOption, OptionDescription
|
from tiramisu import StrOption, OptionDescription, Leadership, Calculation, ParamValue, ParamOption, Params, calc_value
|
||||||
from tiramisu import Leadership
|
|
||||||
|
|
||||||
|
|
||||||
def get_description():
|
def get_description():
|
||||||
|
@ -7,11 +6,12 @@ def get_description():
|
||||||
"""
|
"""
|
||||||
option1 = StrOption('unicode1', "Values 'test' must show 'Unicode follower 2'", multi=True)
|
option1 = StrOption('unicode1', "Values 'test' must show 'Unicode follower 2'", multi=True)
|
||||||
option2 = StrOption('unicode2', "Unicode follower 1", multi=True)
|
option2 = StrOption('unicode2', "Unicode follower 1", multi=True)
|
||||||
option3 = StrOption('unicode3', "Unicode follower 2", multi=True,
|
hidden_property = Calculation(calc_value,
|
||||||
requires=[{'option': option1,
|
Params(ParamValue('hidden'),
|
||||||
'expected': u'test',
|
kwargs={'condition': ParamOption(option1, todict=True),
|
||||||
'action': 'hidden',
|
'expected': ParamValue('test'),
|
||||||
'inverse': True}])
|
'reverse_condition': ParamValue(True)}))
|
||||||
|
option3 = StrOption('unicode3', "Unicode follower 2", multi=True, properties=(hidden_property,))
|
||||||
descr1 = Leadership("unicode1", "Common configuration",
|
descr1 = Leadership("unicode1", "Common configuration",
|
||||||
[option1, option2, option3])
|
[option1, option2, option3])
|
||||||
descr = OptionDescription("options", "Common configuration", [descr1])
|
descr = OptionDescription("options", "Common configuration", [descr1])
|
||||||
|
|
|
@ -31,6 +31,9 @@
|
||||||
"model": {
|
"model": {
|
||||||
"options.unicode1.unicode1": {
|
"options.unicode1.unicode1": {
|
||||||
"required": true,
|
"required": true,
|
||||||
|
"properties": [
|
||||||
|
"unique"
|
||||||
|
],
|
||||||
"value": [
|
"value": [
|
||||||
"test",
|
"test",
|
||||||
"pas test"
|
"pas test"
|
||||||
|
@ -49,8 +52,8 @@
|
||||||
"owner": "user"
|
"owner": "user"
|
||||||
},
|
},
|
||||||
"1": {
|
"1": {
|
||||||
"display": false,
|
"hidden": true,
|
||||||
"hidden": true
|
"display": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from tiramisu.option import StrOption, OptionDescription
|
from tiramisu import StrOption, OptionDescription, Leadership, Calculation, ParamValue, ParamOption, Params, calc_value
|
||||||
from tiramisu import Leadership
|
|
||||||
|
|
||||||
|
|
||||||
def get_description():
|
def get_description():
|
||||||
|
@ -7,15 +6,16 @@ def get_description():
|
||||||
"""
|
"""
|
||||||
option1 = StrOption('unicode1', "Values 'test' must show 'Unicode follower 2'", multi=True)
|
option1 = StrOption('unicode1', "Values 'test' must show 'Unicode follower 2'", multi=True)
|
||||||
option2 = StrOption('unicode2', "Unicode follower 1", multi=True)
|
option2 = StrOption('unicode2', "Unicode follower 1", multi=True)
|
||||||
option3 = StrOption('unicode3', "Unicode follower 2", multi=True,
|
hidden_property = Calculation(calc_value,
|
||||||
requires=[{'option': option1,
|
Params(ParamValue('hidden'),
|
||||||
'expected': u'test',
|
kwargs={'condition': ParamOption(option1, todict=True),
|
||||||
'action': 'hidden',
|
'expected': ParamValue('test'),
|
||||||
'inverse': True}])
|
'reverse_condition': ParamValue(True)}))
|
||||||
|
option3 = StrOption('unicode3', "Unicode follower 2", multi=True, properties=(hidden_property,))
|
||||||
descr1 = Leadership("unicode1", "Common configuration",
|
descr1 = Leadership("unicode1", "Common configuration",
|
||||||
[option1, option2, option3])
|
[option1, option2, option3])
|
||||||
descr = OptionDescription("options", "Common configuration", [descr1])
|
descr = OptionDescription("options", "Common configuration", [descr1])
|
||||||
descr = OptionDescription("unicode1_leadership_requires_follower_value", "Leader follower requires follower with leader value", [descr])
|
descr = OptionDescription("unicode1_leadership_requires_follower_value", "Leader follower requires follower with leader", [descr])
|
||||||
return descr
|
return descr
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,10 @@
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"options.unicode1.unicode1": {
|
"options.unicode1.unicode1": {
|
||||||
"required": true
|
"required": true,
|
||||||
|
"properties": [
|
||||||
|
"unique"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"global": {
|
"global": {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from tiramisu.option import StrOption, OptionDescription
|
from tiramisu import StrOption, OptionDescription, Leadership, Calculation, ParamValue, ParamOption, Params, calc_value
|
||||||
from tiramisu import Leadership
|
|
||||||
|
|
||||||
|
|
||||||
def get_description():
|
def get_description():
|
||||||
|
@ -7,11 +6,12 @@ def get_description():
|
||||||
"""
|
"""
|
||||||
option1 = StrOption('unicode1', "Unicode leader", multi=True)
|
option1 = StrOption('unicode1', "Unicode leader", multi=True)
|
||||||
option2 = StrOption('unicode2', "Values 'test' must show 'Unicode follower 2'", multi=True)
|
option2 = StrOption('unicode2', "Values 'test' must show 'Unicode follower 2'", multi=True)
|
||||||
option3 = StrOption('unicode3', "Unicode follower 2", multi=True,
|
hidden_property = Calculation(calc_value,
|
||||||
requires=[{'option': option2,
|
Params(ParamValue('hidden'),
|
||||||
'expected': u'test',
|
kwargs={'condition': ParamOption(option2, todict=True),
|
||||||
'action': 'hidden',
|
'expected': ParamValue('test'),
|
||||||
'inverse': True}])
|
'reverse_condition': ParamValue(True)}))
|
||||||
|
option3 = StrOption('unicode3', "Unicode follower 2", multi=True, properties=(hidden_property,))
|
||||||
descr1 = Leadership("unicode1", "Common configuration",
|
descr1 = Leadership("unicode1", "Common configuration",
|
||||||
[option1, option2, option3])
|
[option1, option2, option3])
|
||||||
descr = OptionDescription("options", "Common configuration", [descr1])
|
descr = OptionDescription("options", "Common configuration", [descr1])
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
from tiramisu.option import StrOption, OptionDescription
|
|
||||||
from tiramisu import Leadership
|
|
||||||
|
|
||||||
|
|
||||||
def get_description():
|
|
||||||
"""generate description for this test
|
|
||||||
"""
|
|
||||||
option = StrOption('unicode', "Value 'test' must show leader")
|
|
||||||
option1 = StrOption('unicode1', "Unicode leader", multi=True, requires=[{'option': option,
|
|
||||||
'expected': u'test',
|
|
||||||
'action': 'hidden',
|
|
||||||
'inverse': True}])
|
|
||||||
option2 = StrOption('unicode2', "Unicode follower 1", multi=True)
|
|
||||||
option3 = StrOption('unicode3', "Unicode follower 2", multi=True)
|
|
||||||
descr1 = Leadership("unicode1", "Common configuration",
|
|
||||||
[option1, option2, option3])
|
|
||||||
descr = OptionDescription("options", "Common configuration", [option, descr1])
|
|
||||||
descr = OptionDescription("unicode1_leadership_requires_leader", "Leader follower with requirement on leader", [descr])
|
|
||||||
return descr
|
|
|
@ -36,6 +36,9 @@
|
||||||
"model": {
|
"model": {
|
||||||
"options.unicode.unicode": {
|
"options.unicode.unicode": {
|
||||||
"required": true,
|
"required": true,
|
||||||
|
"properties": [
|
||||||
|
"unique"
|
||||||
|
],
|
||||||
"value": [
|
"value": [
|
||||||
"test",
|
"test",
|
||||||
"val2"
|
"val2"
|
||||||
|
@ -64,8 +67,8 @@
|
||||||
},
|
},
|
||||||
"options.unicode.unicode3": {
|
"options.unicode.unicode3": {
|
||||||
"1": {
|
"1": {
|
||||||
"display": false,
|
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
|
"display": false,
|
||||||
"value": "super",
|
"value": "super",
|
||||||
"owner": "user"
|
"owner": "user"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from tiramisu.option import StrOption, OptionDescription
|
from tiramisu import StrOption, OptionDescription, Leadership, Calculation, ParamValue, ParamOption, Params, calc_value
|
||||||
from tiramisu import Leadership
|
|
||||||
|
|
||||||
|
|
||||||
def get_description():
|
def get_description():
|
||||||
|
@ -8,11 +7,12 @@ def get_description():
|
||||||
option = StrOption('unicode', "Values 'test' must show 'Unicode follower 3'", multi=True)
|
option = StrOption('unicode', "Values 'test' must show 'Unicode follower 3'", multi=True)
|
||||||
option1 = StrOption('unicode1', "Unicode follower 1", multi=True)
|
option1 = StrOption('unicode1', "Unicode follower 1", multi=True)
|
||||||
option2 = StrOption('unicode2', "Unicode follower 2", multi=True)
|
option2 = StrOption('unicode2', "Unicode follower 2", multi=True)
|
||||||
option3 = StrOption('unicode3', "Unicode follower 3", requires=[{'option': option,
|
hidden_property = Calculation(calc_value,
|
||||||
'expected': u'test',
|
Params(ParamValue('hidden'),
|
||||||
'action': 'hidden',
|
kwargs={'condition': ParamOption(option, todict=True),
|
||||||
'inverse': True}],
|
'expected': ParamValue('test'),
|
||||||
multi=True)
|
'reverse_condition': ParamValue(True)}))
|
||||||
|
option3 = StrOption('unicode3', "Unicode follower 3", properties=(hidden_property,), multi=True)
|
||||||
descr1 = Leadership("unicode", "Common configuration 1",
|
descr1 = Leadership("unicode", "Common configuration 1",
|
||||||
[option, option1, option2, option3])
|
[option, option1, option2, option3])
|
||||||
descr = OptionDescription("options", "Common configuration 2", [descr1])
|
descr = OptionDescription("options", "Common configuration 2", [descr1])
|
||||||
|
|
|
@ -19,8 +19,11 @@
|
||||||
"model": {
|
"model": {
|
||||||
"options.unicode2": {
|
"options.unicode2": {
|
||||||
"required": true,
|
"required": true,
|
||||||
"display": false,
|
"properties": [
|
||||||
"hidden": true
|
"unique"
|
||||||
|
],
|
||||||
|
"hidden": true,
|
||||||
|
"display": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"global": {
|
"global": {
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
from tiramisu.option import StrOption, OptionDescription
|
from tiramisu import StrOption, OptionDescription, Calculation, ParamValue, ParamOption, Params, calc_value
|
||||||
|
|
||||||
|
|
||||||
def get_description():
|
def get_description():
|
||||||
"""generate description for this test
|
"""generate description for this test
|
||||||
"""
|
"""
|
||||||
option1 = StrOption('unicode1', "Value 'test' must show Unicode 2")
|
option1 = StrOption('unicode1', "Value 'test' must show Unicode 2")
|
||||||
option2 = StrOption('unicode2', "Unicode 2", requires=[{'option': option1,
|
hidden_property = Calculation(calc_value,
|
||||||
'expected': u'test',
|
Params(ParamValue('hidden'),
|
||||||
'action': 'hidden',
|
kwargs={'condition': ParamOption(option1, todict=True),
|
||||||
'inverse': True}],
|
'expected': ParamValue('test'),
|
||||||
multi=True)
|
'reverse_condition': ParamValue(True)}))
|
||||||
|
option2 = StrOption('unicode2', "Unicode 2", properties=(hidden_property,), multi=True)
|
||||||
descr1 = OptionDescription("options", "Common configuration", [option1, option2])
|
descr1 = OptionDescription("options", "Common configuration", [option1, option2])
|
||||||
descr = OptionDescription("unicode1_multi_requires", "Unicode multi with requirement", [descr1])
|
descr = OptionDescription("unicode1_multi_requires", "Unicode multi with requirement", [descr1])
|
||||||
return descr
|
return descr
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"unicode1": {
|
"unicode1": {
|
||||||
"display": false,
|
|
||||||
"properties": [
|
"properties": [
|
||||||
"hidden"
|
"hidden"
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from tiramisu.option import StrOption, OptionDescription
|
from tiramisu import StrOption, OptionDescription, Calculation, ParamValue, ParamOption, Params, calc_value
|
||||||
|
|
||||||
|
|
||||||
def get_description():
|
def get_description():
|
||||||
|
@ -8,10 +8,11 @@ def get_description():
|
||||||
descr1 = OptionDescription("options", "Common configuration", [option1])
|
descr1 = OptionDescription("options", "Common configuration", [option1])
|
||||||
option2 = StrOption('unicode2', "Unicode 2")
|
option2 = StrOption('unicode2', "Unicode 2")
|
||||||
option3 = StrOption('unicode3', "Unicode 3")
|
option3 = StrOption('unicode3', "Unicode 3")
|
||||||
descr2 = OptionDescription("unicode1", "OptionDescription with 2 options",
|
hidden_property = Calculation(calc_value,
|
||||||
[option2, option3], requires=[{'option': option1,
|
Params(ParamValue('hidden'),
|
||||||
'expected': u'test',
|
kwargs={'condition': ParamOption(option1, todict=True),
|
||||||
'action': 'hidden',
|
'expected': ParamValue('test'),
|
||||||
'inverse': True}])
|
'reverse_condition': ParamValue(True)}))
|
||||||
|
descr2 = OptionDescription("unicode1", "OptionDescription with 2 options", [option2, option3], properties=(hidden_property,))
|
||||||
descr = OptionDescription("unicode1_optiondescription_requires", "OptionDesciption with requirement", [descr1, descr2])
|
descr = OptionDescription("unicode1_optiondescription_requires", "OptionDesciption with requirement", [descr1, descr2])
|
||||||
return descr
|
return descr
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
from tiramisu.option import StrOption, OptionDescription
|
from tiramisu import StrOption, OptionDescription, Calculation, ParamValue, ParamOption, Params, calc_value
|
||||||
|
|
||||||
|
|
||||||
def get_description():
|
def get_description():
|
||||||
"""generate description for this test
|
"""generate description for this test
|
||||||
"""
|
"""
|
||||||
option1 = StrOption('unicode1', "Value 'test' must show Unicode 2")
|
option1 = StrOption('unicode1', "Value 'test' must show Unicode 2")
|
||||||
option2 = StrOption('unicode2', "Unicode 2", requires=[{'option': option1,
|
hidden_property = Calculation(calc_value,
|
||||||
'expected': u'test',
|
Params(ParamValue('hidden'),
|
||||||
'action': 'hidden',
|
kwargs={'condition': ParamOption(option1, todict=True),
|
||||||
'inverse': True}])
|
'expected': ParamValue('test'),
|
||||||
|
'reverse_condition': ParamValue(True)}))
|
||||||
|
option2 = StrOption('unicode2', "Unicode 2", properties=(hidden_property,))
|
||||||
descr1 = OptionDescription("options", "Common configuration", [option1, option2])
|
descr1 = OptionDescription("options", "Common configuration", [option1, option2])
|
||||||
descr = OptionDescription("unicode1_requires", "Unicode with requirement", [descr1])
|
descr = OptionDescription("unicode1_requires", "Unicode with requirement", [descr1])
|
||||||
return descr
|
return descr
|
||||||
|
|
|
@ -31,7 +31,7 @@ def list_data(ext='.py'):
|
||||||
ret = []
|
ret = []
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
# if filename.endswith(ext) and not filename.startswith('__'):
|
# if filename.endswith(ext) and not filename.startswith('__'):
|
||||||
if filename.endswith(ext) and not filename.startswith('__') and not 'require' in filename and not 'not_equal' in filename and not 'callback' in filename and not filename == 'unicode2_copy.py' and not filename == 'unicode2_multi_copy.py':
|
if filename.endswith(ext) and not filename.startswith('__') and not 'not_equal' in filename and not 'callback' in filename and not filename == 'unicode2_copy.py' and not filename == 'unicode2_multi_copy.py':
|
||||||
ret.append(filename)
|
ret.append(filename)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
|
@ -87,11 +87,7 @@ async def test_make_dict(config_type):
|
||||||
d2 = await cfg.value.dict(flatten=True)
|
d2 = await cfg.value.dict(flatten=True)
|
||||||
assert d2 == {'a': True, 'int': 43}
|
assert d2 == {'a': True, 'int': 43}
|
||||||
if config_type == 'tiramisu':
|
if config_type == 'tiramisu':
|
||||||
# FIXME
|
assert await cfg.forcepermissive.value.dict() == {"s1.a": True, "s1.b": False, "int": 43}
|
||||||
with pytest.raises(ValueError):
|
|
||||||
d2 = await cfg.value.dict(withvalue="3")
|
|
||||||
d = await cfg.forcepermissive.value.dict()
|
|
||||||
assert d == {"s1.a": True, "s1.b": False, "int": 43}
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
|
@ -113,23 +109,6 @@ async def test_make_dict_with_disabled(config_type):
|
||||||
assert await cfg.unrestraint.value.dict() == {"int": 42, "s1.a": False, "s1.b": False, "s2.a": False, "s2.b": False}
|
assert await cfg.unrestraint.value.dict() == {"int": 42, "s1.a": False, "s1.b": False, "s2.a": False, "s2.b": False}
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
|
||||||
async def test_make_dict_with_disabled_withoption():
|
|
||||||
descr = OptionDescription("opt", "", [
|
|
||||||
OptionDescription("s1", "", [
|
|
||||||
BoolOption("a", "", default=False),
|
|
||||||
BoolOption("b", "", default=False, properties=('disabled',))]),
|
|
||||||
OptionDescription("s2", "", [
|
|
||||||
BoolOption("a", "", default=False),
|
|
||||||
BoolOption("b", "", default=False)], properties=('disabled',)),
|
|
||||||
IntOption("int", "", default=42)])
|
|
||||||
cfg = await Config(descr)
|
|
||||||
await cfg.property.read_only()
|
|
||||||
assert await cfg.value.dict(withoption="a") == {"s1.a": False}
|
|
||||||
assert await cfg.forcepermissive.value.dict(withoption="a") == {"s1.a": False}
|
|
||||||
assert await cfg.unrestraint.value.dict(withoption="a") == {"s1.a": False, "s1.b": False, "s2.a": False, "s2.b": False}
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_make_dict_with_disabled_in_callback(config_type):
|
async def test_make_dict_with_disabled_in_callback(config_type):
|
||||||
descr = OptionDescription("opt", "", [
|
descr = OptionDescription("opt", "", [
|
||||||
|
|
|
@ -9,7 +9,7 @@ from tiramisu import BoolOption, StrOption, ChoiceOption, IPOption, \
|
||||||
StrOption, PortOption, BroadcastOption, DomainnameOption, \
|
StrOption, PortOption, BroadcastOption, DomainnameOption, \
|
||||||
EmailOption, URLOption, UsernameOption, FilenameOption, SymLinkOption, \
|
EmailOption, URLOption, UsernameOption, FilenameOption, SymLinkOption, \
|
||||||
OptionDescription, DynOptionDescription, SynDynOption, submulti, Leadership, \
|
OptionDescription, DynOptionDescription, SynDynOption, submulti, Leadership, \
|
||||||
Config, Params, ParamOption, ParamValue, ParamSuffix, ParamSelfOption, Calculation, calc_value
|
Config, Params, ParamOption, ParamValue, ParamSuffix, ParamSelfOption, ParamIndex, Calculation, calc_value
|
||||||
from tiramisu.error import PropertiesOptionError, ConfigError, ConflictError
|
from tiramisu.error import PropertiesOptionError, ConfigError, ConflictError
|
||||||
from tiramisu.storage import list_sessions
|
from tiramisu.storage import list_sessions
|
||||||
|
|
||||||
|
@ -761,9 +761,6 @@ async def test_makedict_dyndescription_context():
|
||||||
await cfg.option('od.dodval1.stval1').value.set('yes')
|
await cfg.option('od.dodval1.stval1').value.set('yes')
|
||||||
assert await cfg.value.dict() == {'od.val1': ['val1', 'val2'], 'od.dodval1.stval1': 'yes', 'od.dodval2.stval2': None}
|
assert await cfg.value.dict() == {'od.val1': ['val1', 'val2'], 'od.dodval1.stval1': 'yes', 'od.dodval2.stval2': None}
|
||||||
assert await cfg.value.dict(flatten=True) == {'val1': ['val1', 'val2'], 'stval1': 'yes', 'stval2': None}
|
assert await cfg.value.dict(flatten=True) == {'val1': ['val1', 'val2'], 'stval1': 'yes', 'stval2': None}
|
||||||
assert await cfg.value.dict(withoption='stval1') == {'od.dodval1.stval1': 'yes'}
|
|
||||||
assert await cfg.option('od').value.dict(withoption='stval1') == {'dodval1.stval1': 'yes'}
|
|
||||||
assert await cfg.option('od.dodval1').value.dict(withoption='stval1') == {'stval1': 'yes'}
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
|
@ -1549,3 +1546,89 @@ async def test_leadership_callback_samegroup_dyndescription_convert():
|
||||||
assert await cfg.option('od.stval1.st1val1.st2val1', 0).owner.get() == owner
|
assert await cfg.option('od.stval1.st1val1.st2val1', 0).owner.get() == owner
|
||||||
assert await cfg.option('od.stval1.st1val1.st3val1', 0).owner.isdefault()
|
assert await cfg.option('od.stval1.st1val1.st3val1', 0).owner.isdefault()
|
||||||
assert await cfg.option('od.stval2.st1val2.st1val2').owner.isdefault()
|
assert await cfg.option('od.stval2.st1val2.st1val2').owner.isdefault()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_dyn_with_leader_hidden_in_config():
|
||||||
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||||
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True, properties=('hidden',))
|
||||||
|
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0], properties=('hidden',))
|
||||||
|
dyn = DynOptionDescription('leader', '', [interface1], suffixes=Calculation(return_list))
|
||||||
|
od = OptionDescription('root', '', [dyn])
|
||||||
|
cfg = await Config(od)
|
||||||
|
await cfg.property.read_write()
|
||||||
|
await cfg.permissive.add('hidden')
|
||||||
|
assert await cfg.forcepermissive.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.get() == []
|
||||||
|
await cfg.forcepermissive.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.set(['192.168.1.1'])
|
||||||
|
assert await cfg.forcepermissive.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 0).value.get() is None
|
||||||
|
with pytest.raises(PropertiesOptionError):
|
||||||
|
await cfg.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.get()
|
||||||
|
with pytest.raises(PropertiesOptionError):
|
||||||
|
await cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 0).value.get()
|
||||||
|
await cfg.value.dict(leader_to_list=True) == {'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': [{'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': '192.168.1.1'}],
|
||||||
|
'leaderval2.ip_admin_eth0val2.ip_admin_eth0val2': [{'leaderval2.ip_admin_eth0val2.ip_admin_eth0val2': '192.168.1.1'}]}
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_dyn_leadership_requires():
|
||||||
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True, properties=('notunique',))
|
||||||
|
disabled_property = Calculation(calc_value,
|
||||||
|
Params(ParamValue('disabled'),
|
||||||
|
kwargs={'condition': ParamOption(ip_admin_eth0, notraisepropertyerror=True),
|
||||||
|
'expected': ParamValue('192.168.1.1'),
|
||||||
|
'no_condition_is_invalid': ParamValue(True),
|
||||||
|
'index': ParamIndex()}))
|
||||||
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True, properties=(disabled_property,))
|
||||||
|
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
dyn = DynOptionDescription('leader', '', [interface1], suffixes=Calculation(return_list))
|
||||||
|
od = OptionDescription('toto', '', [dyn])
|
||||||
|
cfg = await Config(od)
|
||||||
|
await cfg.property.read_write()
|
||||||
|
assert await cfg.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.get() == []
|
||||||
|
await cfg.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.set(['192.168.1.2'])
|
||||||
|
assert await cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 0).value.get() is None
|
||||||
|
assert await cfg.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.get() == ['192.168.1.2']
|
||||||
|
#
|
||||||
|
await cfg.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.set(['192.168.1.2', '192.168.1.1'])
|
||||||
|
assert await cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 0).value.get() is None
|
||||||
|
with pytest.raises(PropertiesOptionError):
|
||||||
|
await cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 1).value.get()
|
||||||
|
#
|
||||||
|
await cfg.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.set(['192.168.1.2', '192.168.1.2'])
|
||||||
|
assert await cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 0).value.get() is None
|
||||||
|
assert await cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 1).value.get() is None
|
||||||
|
await cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 1).value.set('255.255.255.255')
|
||||||
|
assert await cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 1).value.get() == '255.255.255.255'
|
||||||
|
assert await cfg.value.dict() == {'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': ['192.168.1.2', '192.168.1.2'],
|
||||||
|
'leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1': [None, '255.255.255.255'],
|
||||||
|
'leaderval2.ip_admin_eth0val2.ip_admin_eth0val2': [],
|
||||||
|
'leaderval2.ip_admin_eth0val2.netmask_admin_eth0val2': []}
|
||||||
|
|
||||||
|
ret = await cfg.value.dict(leader_to_list=True)
|
||||||
|
assert ret == {'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': [{'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': '192.168.1.2', 'leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1': None},
|
||||||
|
{'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': '192.168.1.2', 'leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1': '255.255.255.255'}],
|
||||||
|
'leaderval2.ip_admin_eth0val2.ip_admin_eth0val2': []}
|
||||||
|
|
||||||
|
#
|
||||||
|
await cfg.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.set(['192.168.1.2', '192.168.1.1'])
|
||||||
|
assert await cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 0).value.get() is None
|
||||||
|
with pytest.raises(PropertiesOptionError):
|
||||||
|
await cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 1).value.get()
|
||||||
|
ret = await cfg.value.dict()
|
||||||
|
assert set(ret.keys()) == set(['leaderval1.ip_admin_eth0val1.ip_admin_eth0val1', 'leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 'leaderval2.ip_admin_eth0val2.ip_admin_eth0val2', 'leaderval2.ip_admin_eth0val2.netmask_admin_eth0val2'])
|
||||||
|
assert ret['leaderval1.ip_admin_eth0val1.ip_admin_eth0val1'] == ['192.168.1.2', '192.168.1.1']
|
||||||
|
assert len(ret['leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1']) == 2
|
||||||
|
assert ret['leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1'][0] is None
|
||||||
|
assert isinstance(ret['leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1'][1], PropertiesOptionError)
|
||||||
|
del ret['leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1'][1]
|
||||||
|
del ret['leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1'][0]
|
||||||
|
del ret['leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1']
|
||||||
|
assert await cfg.value.dict(leader_to_list=True) == {'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': [{'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': '192.168.1.2',
|
||||||
|
'leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1': None},
|
||||||
|
{'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': '192.168.1.1'}],
|
||||||
|
'leaderval2.ip_admin_eth0val2.ip_admin_eth0val2': []}
|
||||||
|
#
|
||||||
|
assert await cfg.value.dict(leader_to_list=True) == {'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': [{'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': '192.168.1.2',
|
||||||
|
'leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1': None},
|
||||||
|
{'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': '192.168.1.1'}],
|
||||||
|
'leaderval2.ip_admin_eth0val2.ip_admin_eth0val2': []}
|
||||||
|
|
|
@ -91,25 +91,6 @@ async def test_base_config(config_type):
|
||||||
await cfg.send()
|
await cfg.send()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
|
||||||
async def test_make_dict_filter():
|
|
||||||
descr = make_description()
|
|
||||||
cfg = await Config(descr)
|
|
||||||
await cfg.property.read_write()
|
|
||||||
subresult = {'numero_etab': None, 'nombre_interfaces': 1,
|
|
||||||
'serveur_ntp': [], 'mode_conteneur_actif': False,
|
|
||||||
'time_zone': 'Paris', 'nom_machine': 'eoleng',
|
|
||||||
'activer_proxy_client': False}
|
|
||||||
result = {}
|
|
||||||
for key, value in subresult.items():
|
|
||||||
result['general.' + key] = value
|
|
||||||
assert await cfg.option('creole').value.dict(withoption='numero_etab') == result
|
|
||||||
with pytest.raises(AttributeError):
|
|
||||||
await cfg.option('creole').value.dict(withoption='numero_etab', withvalue='toto')
|
|
||||||
assert await cfg.option('creole').value.dict(withoption='numero_etab', withvalue=None) == result
|
|
||||||
assert await cfg.option('creole.general').value.dict(withoption='numero_etab') == subresult
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_get_group_type():
|
async def test_get_group_type():
|
||||||
descr = make_description()
|
descr = make_description()
|
||||||
|
@ -289,6 +270,7 @@ async def test_groups_with_leader_make_dict(config_type):
|
||||||
cfg = await Config(od)
|
cfg = await Config(od)
|
||||||
cfg = await get_config(cfg, config_type)
|
cfg = await get_config(cfg, config_type)
|
||||||
assert await cfg.value.dict() == {'ip_admin_eth0.ip_admin_eth0': [], 'ip_admin_eth0.netmask_admin_eth0': []}
|
assert await cfg.value.dict() == {'ip_admin_eth0.ip_admin_eth0': [], 'ip_admin_eth0.netmask_admin_eth0': []}
|
||||||
|
assert await cfg.value.dict(leader_to_list=True) == {'ip_admin_eth0.ip_admin_eth0': []}
|
||||||
if config_type != 'tiramisu-api':
|
if config_type != 'tiramisu-api':
|
||||||
# FIXME useful? already in leadership
|
# FIXME useful? already in leadership
|
||||||
assert await cfg.option('ip_admin_eth0.ip_admin_eth0').value.len() == 0
|
assert await cfg.option('ip_admin_eth0.ip_admin_eth0').value.len() == 0
|
||||||
|
@ -299,6 +281,7 @@ async def test_groups_with_leader_make_dict(config_type):
|
||||||
assert await cfg.option('ip_admin_eth0.ip_admin_eth0').value.len() == 2
|
assert await cfg.option('ip_admin_eth0.ip_admin_eth0').value.len() == 2
|
||||||
assert await cfg.option('ip_admin_eth0.netmask_admin_eth0').value.len() == 2
|
assert await cfg.option('ip_admin_eth0.netmask_admin_eth0').value.len() == 2
|
||||||
assert await cfg.value.dict() == {'ip_admin_eth0.ip_admin_eth0': ['ip1', 'ip2'], 'ip_admin_eth0.netmask_admin_eth0': [None, None]}
|
assert await cfg.value.dict() == {'ip_admin_eth0.ip_admin_eth0': ['ip1', 'ip2'], 'ip_admin_eth0.netmask_admin_eth0': [None, None]}
|
||||||
|
assert await cfg.value.dict(leader_to_list=True) == {'ip_admin_eth0.ip_admin_eth0': [{'ip_admin_eth0.ip_admin_eth0': 'ip1', 'ip_admin_eth0.netmask_admin_eth0': None}, {'ip_admin_eth0.ip_admin_eth0': 'ip2', 'ip_admin_eth0.netmask_admin_eth0': None}]}
|
||||||
if config_type == 'tiramisu-api':
|
if config_type == 'tiramisu-api':
|
||||||
await cfg.send()
|
await cfg.send()
|
||||||
|
|
||||||
|
@ -365,6 +348,7 @@ async def test_groups_with_leader_hidden_in_config():
|
||||||
await cfg.option('ip_admin_eth0.ip_admin_eth0').value.get()
|
await cfg.option('ip_admin_eth0.ip_admin_eth0').value.get()
|
||||||
with pytest.raises(PropertiesOptionError):
|
with pytest.raises(PropertiesOptionError):
|
||||||
await cfg.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get()
|
await cfg.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get()
|
||||||
|
await cfg.value.dict(leader_to_list=True) == {'ip_admin_eth0.ip_admin_eth0': [{'ip_admin_eth0.ip_admin_eth0': '192.168.1.1'}]}
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
|
|
|
@ -1086,6 +1086,8 @@ async def test_leadership_requires(config_type):
|
||||||
assert await cfg.option('ip_admin_eth0.netmask_admin_eth0', 1).value.get() == '255.255.255.255'
|
assert await cfg.option('ip_admin_eth0.netmask_admin_eth0', 1).value.get() == '255.255.255.255'
|
||||||
assert await cfg.value.dict() == {'ip_admin_eth0.ip_admin_eth0': ['192.168.1.2', '192.168.1.2'],
|
assert await cfg.value.dict() == {'ip_admin_eth0.ip_admin_eth0': ['192.168.1.2', '192.168.1.2'],
|
||||||
'ip_admin_eth0.netmask_admin_eth0': [None, '255.255.255.255']}
|
'ip_admin_eth0.netmask_admin_eth0': [None, '255.255.255.255']}
|
||||||
|
assert await cfg.value.dict(leader_to_list=True) == {'ip_admin_eth0.ip_admin_eth0': [{'ip_admin_eth0.ip_admin_eth0': '192.168.1.2', 'ip_admin_eth0.netmask_admin_eth0': None},
|
||||||
|
{'ip_admin_eth0.ip_admin_eth0': '192.168.1.2', 'ip_admin_eth0.netmask_admin_eth0': '255.255.255.255'}]}
|
||||||
#
|
#
|
||||||
await cfg.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2', '192.168.1.1'])
|
await cfg.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2', '192.168.1.1'])
|
||||||
assert await cfg.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() is None
|
assert await cfg.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() is None
|
||||||
|
@ -1100,6 +1102,9 @@ async def test_leadership_requires(config_type):
|
||||||
del ret['ip_admin_eth0.netmask_admin_eth0'][1]
|
del ret['ip_admin_eth0.netmask_admin_eth0'][1]
|
||||||
del ret['ip_admin_eth0.netmask_admin_eth0'][0]
|
del ret['ip_admin_eth0.netmask_admin_eth0'][0]
|
||||||
del ret['ip_admin_eth0.netmask_admin_eth0']
|
del ret['ip_admin_eth0.netmask_admin_eth0']
|
||||||
|
assert await cfg.value.dict(leader_to_list=True) == {'ip_admin_eth0.ip_admin_eth0': [{'ip_admin_eth0.ip_admin_eth0': '192.168.1.2',
|
||||||
|
'ip_admin_eth0.netmask_admin_eth0': None},
|
||||||
|
{'ip_admin_eth0.ip_admin_eth0': '192.168.1.1'}]}
|
||||||
#
|
#
|
||||||
await cfg.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.255')
|
await cfg.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.255')
|
||||||
ret = await cfg.value.dict()
|
ret = await cfg.value.dict()
|
||||||
|
@ -1111,6 +1116,9 @@ async def test_leadership_requires(config_type):
|
||||||
del ret['ip_admin_eth0.netmask_admin_eth0'][1]
|
del ret['ip_admin_eth0.netmask_admin_eth0'][1]
|
||||||
del ret['ip_admin_eth0.netmask_admin_eth0'][0]
|
del ret['ip_admin_eth0.netmask_admin_eth0'][0]
|
||||||
del ret['ip_admin_eth0.netmask_admin_eth0']
|
del ret['ip_admin_eth0.netmask_admin_eth0']
|
||||||
|
assert await cfg.value.dict(leader_to_list=True) == {'ip_admin_eth0.ip_admin_eth0': [{'ip_admin_eth0.ip_admin_eth0': '192.168.1.2',
|
||||||
|
'ip_admin_eth0.netmask_admin_eth0': '255.255.255.255'},
|
||||||
|
{'ip_admin_eth0.ip_admin_eth0': '192.168.1.1'}]}
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
|
|
|
@ -144,7 +144,6 @@ async def test_slots_config():
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(od2,
|
option_bag.set_option(od2,
|
||||||
'a',
|
'a',
|
||||||
None,
|
|
||||||
ConfigBag(c._config_bag.context, None, None))
|
ConfigBag(c._config_bag.context, None, None))
|
||||||
sc = await c._config_bag.context.get_subconfig(option_bag)
|
sc = await c._config_bag.context.get_subconfig(option_bag)
|
||||||
assert isinstance(sc, SubConfig)
|
assert isinstance(sc, SubConfig)
|
||||||
|
|
|
@ -214,7 +214,8 @@ class _TiramisuOptionOptionDescription(CommonTiramisuOption):
|
||||||
apply_requires=False)
|
apply_requires=False)
|
||||||
# do not check cache properties/permissives which are not save (unrestraint, ...)
|
# do not check cache properties/permissives which are not save (unrestraint, ...)
|
||||||
return await settings.calc_raises_properties(self._option_bag,
|
return await settings.calc_raises_properties(self._option_bag,
|
||||||
apply_requires=False)
|
apply_requires=False,
|
||||||
|
uncalculated=uncalculated)
|
||||||
|
|
||||||
def __call__(self,
|
def __call__(self,
|
||||||
name: str,
|
name: str,
|
||||||
|
@ -347,13 +348,15 @@ class TiramisuOptionProperty(CommonTiramisuOption):
|
||||||
self._settings = option_bag.config_bag.context.cfgimpl_get_settings()
|
self._settings = option_bag.config_bag.context.cfgimpl_get_settings()
|
||||||
|
|
||||||
async def get(self,
|
async def get(self,
|
||||||
only_raises=False):
|
only_raises=False,
|
||||||
|
uncalculated=False):
|
||||||
"""Get properties for an option"""
|
"""Get properties for an option"""
|
||||||
await self._get_option()
|
await self._get_option()
|
||||||
if not only_raises:
|
if not only_raises:
|
||||||
return self._option_bag.properties
|
return self._option_bag.properties
|
||||||
# do not check cache properties/permissives which are not save (unrestraint, ...)
|
# do not check cache properties/permissives which are not save (unrestraint, ...)
|
||||||
return await self._settings.calc_raises_properties(self._option_bag)
|
return await self._settings.calc_raises_properties(self._option_bag,
|
||||||
|
uncalculated=uncalculated)
|
||||||
|
|
||||||
async def add(self, prop):
|
async def add(self, prop):
|
||||||
"""Add new property for an option"""
|
"""Add new property for an option"""
|
||||||
|
@ -510,8 +513,6 @@ class TiramisuOptionValue(CommonTiramisuOption):
|
||||||
@option_type('optiondescription')
|
@option_type('optiondescription')
|
||||||
async def dict(self,
|
async def dict(self,
|
||||||
flatten=False,
|
flatten=False,
|
||||||
withvalue=undefined,
|
|
||||||
withoption=None,
|
|
||||||
withwarning: bool=False,
|
withwarning: bool=False,
|
||||||
fullpath=False):
|
fullpath=False):
|
||||||
"""Dict with path as key and value"""
|
"""Dict with path as key and value"""
|
||||||
|
@ -523,9 +524,7 @@ class TiramisuOptionValue(CommonTiramisuOption):
|
||||||
config_bag.remove_warnings()
|
config_bag.remove_warnings()
|
||||||
return await subconfig.make_dict(config_bag=config_bag,
|
return await subconfig.make_dict(config_bag=config_bag,
|
||||||
flatten=flatten,
|
flatten=flatten,
|
||||||
fullpath=fullpath,
|
fullpath=fullpath)
|
||||||
withoption=withoption,
|
|
||||||
withvalue=withvalue)
|
|
||||||
|
|
||||||
@option_type('option')
|
@option_type('option')
|
||||||
async def get(self):
|
async def get(self):
|
||||||
|
@ -576,7 +575,6 @@ class TiramisuOptionValue(CommonTiramisuOption):
|
||||||
for idx in range(length):
|
for idx in range(length):
|
||||||
soption_bag = OptionBag()
|
soption_bag = OptionBag()
|
||||||
soption_bag.set_option(option,
|
soption_bag.set_option(option,
|
||||||
self._option_bag.path,
|
|
||||||
idx,
|
idx,
|
||||||
self._option_bag.config_bag)
|
self._option_bag.config_bag)
|
||||||
soption_bag.properties = await settings.getproperties(soption_bag)
|
soption_bag.properties = await settings.getproperties(soption_bag)
|
||||||
|
@ -706,7 +704,6 @@ class TiramisuOption(CommonTiramisu, TiramisuConfig):
|
||||||
path = self._subconfig._get_subpath(oname)
|
path = self._subconfig._get_subpath(oname)
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(option,
|
option_bag.set_option(option,
|
||||||
path,
|
|
||||||
None,
|
None,
|
||||||
config_bag)
|
config_bag)
|
||||||
subconfig = await self._subconfig.get_subconfig(option_bag)
|
subconfig = await self._subconfig.get_subconfig(option_bag)
|
||||||
|
@ -736,7 +733,6 @@ class TiramisuOption(CommonTiramisu, TiramisuConfig):
|
||||||
settings = config_bag.context.cfgimpl_get_settings()
|
settings = config_bag.context.cfgimpl_get_settings()
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(opt,
|
option_bag.set_option(opt,
|
||||||
opt.impl_getpath(),
|
|
||||||
None,
|
None,
|
||||||
config_bag)
|
config_bag)
|
||||||
option_bag.properties = await settings.getproperties(option_bag)
|
option_bag.properties = await settings.getproperties(option_bag)
|
||||||
|
@ -761,7 +757,6 @@ class TiramisuOption(CommonTiramisu, TiramisuConfig):
|
||||||
option = await self._get_option()
|
option = await self._get_option()
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(option,
|
option_bag.set_option(option,
|
||||||
option.impl_getpath(),
|
|
||||||
None,
|
None,
|
||||||
config_bag)
|
config_bag)
|
||||||
subconfig = await self._subconfig.get_subconfig(option_bag)
|
subconfig = await self._subconfig.get_subconfig(option_bag)
|
||||||
|
@ -878,10 +873,9 @@ class TiramisuContextValue(TiramisuConfig):
|
||||||
|
|
||||||
async def dict(self,
|
async def dict(self,
|
||||||
flatten=False,
|
flatten=False,
|
||||||
withvalue=undefined,
|
|
||||||
withoption=None,
|
|
||||||
withwarning: bool=False,
|
withwarning: bool=False,
|
||||||
fullpath=False):
|
fullpath=False,
|
||||||
|
leader_to_list=False):
|
||||||
"""Dict with path as key and value"""
|
"""Dict with path as key and value"""
|
||||||
config_bag = self._config_bag
|
config_bag = self._config_bag
|
||||||
if not withwarning and 'warnings' in config_bag.properties:
|
if not withwarning and 'warnings' in config_bag.properties:
|
||||||
|
@ -890,8 +884,7 @@ class TiramisuContextValue(TiramisuConfig):
|
||||||
return await config_bag.context.make_dict(config_bag,
|
return await config_bag.context.make_dict(config_bag,
|
||||||
flatten=flatten,
|
flatten=flatten,
|
||||||
fullpath=fullpath,
|
fullpath=fullpath,
|
||||||
withoption=withoption,
|
leader_to_list=leader_to_list)
|
||||||
withvalue=withvalue)
|
|
||||||
|
|
||||||
async def exportation(self,
|
async def exportation(self,
|
||||||
with_default_owner: bool=False):
|
with_default_owner: bool=False):
|
||||||
|
@ -1146,7 +1139,6 @@ class TiramisuContextOption(TiramisuConfig):
|
||||||
config_bag):
|
config_bag):
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(opt,
|
option_bag.set_option(opt,
|
||||||
opt.impl_getpath(),
|
|
||||||
None,
|
None,
|
||||||
config_bag)
|
config_bag)
|
||||||
settings = config_bag.context.cfgimpl_get_settings()
|
settings = config_bag.context.cfgimpl_get_settings()
|
||||||
|
|
|
@ -202,7 +202,9 @@ async def manager_callback(callbk: Union[ParamOption, ParamValue],
|
||||||
if config_bag is undefined:
|
if config_bag is undefined:
|
||||||
return undefined
|
return undefined
|
||||||
path = option.impl_getpath()
|
path = option.impl_getpath()
|
||||||
option_bag = await get_option_bag(config_bag, option, path, apply_index)
|
option_bag = await get_option_bag(config_bag,
|
||||||
|
option,
|
||||||
|
apply_index)
|
||||||
option_bag.config_bag.unrestraint()
|
option_bag.config_bag.unrestraint()
|
||||||
option_bag.config_bag.remove_validation()
|
option_bag.config_bag.remove_validation()
|
||||||
# if we are in properties calculation, cannot calculated properties
|
# if we are in properties calculation, cannot calculated properties
|
||||||
|
@ -233,7 +235,6 @@ async def manager_callback(callbk: Union[ParamOption, ParamValue],
|
||||||
|
|
||||||
async def get_option_bag(config_bag,
|
async def get_option_bag(config_bag,
|
||||||
opt,
|
opt,
|
||||||
path,
|
|
||||||
index_):
|
index_):
|
||||||
# don't validate if option is option that we tried to validate
|
# don't validate if option is option that we tried to validate
|
||||||
config_bag = config_bag.copy()
|
config_bag = config_bag.copy()
|
||||||
|
@ -242,7 +243,6 @@ async def manager_callback(callbk: Union[ParamOption, ParamValue],
|
||||||
#config_bag.properties -= {'warnings'}
|
#config_bag.properties -= {'warnings'}
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(opt,
|
option_bag.set_option(opt,
|
||||||
path,
|
|
||||||
index_,
|
index_,
|
||||||
config_bag)
|
config_bag)
|
||||||
option_bag.properties = await config_bag.context.cfgimpl_get_settings().getproperties(option_bag)
|
option_bag.properties = await config_bag.context.cfgimpl_get_settings().getproperties(option_bag)
|
||||||
|
@ -292,7 +292,9 @@ async def manager_callback(callbk: Union[ParamOption, ParamValue],
|
||||||
index_ = None
|
index_ = None
|
||||||
with_index = False
|
with_index = False
|
||||||
path = callbk_option.impl_getpath()
|
path = callbk_option.impl_getpath()
|
||||||
option_bag = await get_option_bag(config_bag, callbk_option, path, index_)
|
option_bag = await get_option_bag(config_bag,
|
||||||
|
callbk_option,
|
||||||
|
index_)
|
||||||
value = await get_value(callbk, option_bag, path)
|
value = await get_value(callbk, option_bag, path)
|
||||||
if with_index:
|
if with_index:
|
||||||
value = value[index]
|
value = value[index]
|
||||||
|
|
|
@ -75,12 +75,10 @@ class SubConfig:
|
||||||
if descr is not None and descr.impl_is_leadership():
|
if descr is not None and descr.impl_is_leadership():
|
||||||
leader = descr.get_leader()
|
leader = descr.get_leader()
|
||||||
leaderpath = leader.impl_getname()
|
leaderpath = leader.impl_getname()
|
||||||
full_leaderpath = self._get_subpath(leaderpath)
|
|
||||||
cconfig_bag = config_bag.copy()
|
cconfig_bag = config_bag.copy()
|
||||||
cconfig_bag.remove_validation()
|
cconfig_bag.remove_validation()
|
||||||
moption_bag = OptionBag()
|
moption_bag = OptionBag()
|
||||||
moption_bag.set_option(leader,
|
moption_bag.set_option(leader,
|
||||||
full_leaderpath,
|
|
||||||
None,
|
None,
|
||||||
cconfig_bag)
|
cconfig_bag)
|
||||||
moption_bag.properties = await self.cfgimpl_get_settings().getproperties(moption_bag)
|
moption_bag.properties = await self.cfgimpl_get_settings().getproperties(moption_bag)
|
||||||
|
@ -118,10 +116,8 @@ class SubConfig:
|
||||||
doption = option.to_dynoption(subpath,
|
doption = option.to_dynoption(subpath,
|
||||||
suffix,
|
suffix,
|
||||||
option)
|
option)
|
||||||
doption_path = doption.impl_getpath()
|
|
||||||
doption_bag = OptionBag()
|
doption_bag = OptionBag()
|
||||||
doption_bag.set_option(doption,
|
doption_bag.set_option(doption,
|
||||||
doption_path,
|
|
||||||
option_bag.index,
|
option_bag.index,
|
||||||
option_bag.config_bag)
|
option_bag.config_bag)
|
||||||
doption_bag.properties = await self.cfgimpl_get_settings().getproperties(doption_bag)
|
doption_bag.properties = await self.cfgimpl_get_settings().getproperties(doption_bag)
|
||||||
|
@ -139,10 +135,8 @@ class SubConfig:
|
||||||
doption = option.to_dynoption(subpath,
|
doption = option.to_dynoption(subpath,
|
||||||
suffix,
|
suffix,
|
||||||
dynopt)
|
dynopt)
|
||||||
doption_path = doption.impl_getpath()
|
|
||||||
doption_bag = OptionBag()
|
doption_bag = OptionBag()
|
||||||
doption_bag.set_option(doption,
|
doption_bag.set_option(doption,
|
||||||
doption_path,
|
|
||||||
option_bag.index,
|
option_bag.index,
|
||||||
option_bag.config_bag)
|
option_bag.config_bag)
|
||||||
doption_bag.properties = await self.cfgimpl_get_settings().getproperties(doption_bag)
|
doption_bag.properties = await self.cfgimpl_get_settings().getproperties(doption_bag)
|
||||||
|
@ -150,10 +144,8 @@ class SubConfig:
|
||||||
resetted_opts,
|
resetted_opts,
|
||||||
doption_bag)
|
doption_bag)
|
||||||
else:
|
else:
|
||||||
option_path = option.impl_getpath()
|
|
||||||
doption_bag = OptionBag()
|
doption_bag = OptionBag()
|
||||||
doption_bag.set_option(option,
|
doption_bag.set_option(option,
|
||||||
option_path,
|
|
||||||
option_bag.index,
|
option_bag.index,
|
||||||
option_bag.config_bag)
|
option_bag.config_bag)
|
||||||
doption_bag.properties = await self.cfgimpl_get_settings().getproperties(doption_bag)
|
doption_bag.properties = await self.cfgimpl_get_settings().getproperties(doption_bag)
|
||||||
|
@ -194,9 +186,7 @@ class SubConfig:
|
||||||
option = await self.cfgimpl_get_description().get_child(step,
|
option = await self.cfgimpl_get_description().get_child(step,
|
||||||
config_bag,
|
config_bag,
|
||||||
self.cfgimpl_get_path())
|
self.cfgimpl_get_path())
|
||||||
subpath = self._get_subpath(step)
|
|
||||||
option_bag.set_option(option,
|
option_bag.set_option(option,
|
||||||
subpath,
|
|
||||||
None,
|
None,
|
||||||
config_bag)
|
config_bag)
|
||||||
option_bag.properties = await self.cfgimpl_get_settings().getproperties(option_bag)
|
option_bag.properties = await self.cfgimpl_get_settings().getproperties(option_bag)
|
||||||
|
@ -285,7 +275,6 @@ class SubConfig:
|
||||||
if option.impl_is_symlinkoption():
|
if option.impl_is_symlinkoption():
|
||||||
soption_bag = OptionBag()
|
soption_bag = OptionBag()
|
||||||
soption_bag.set_option(option.impl_getopt(),
|
soption_bag.set_option(option.impl_getopt(),
|
||||||
None,
|
|
||||||
option_bag.index,
|
option_bag.index,
|
||||||
config_bag)
|
config_bag)
|
||||||
soption_bag.properties = await self.cfgimpl_get_settings().getproperties(soption_bag)
|
soption_bag.properties = await self.cfgimpl_get_settings().getproperties(soption_bag)
|
||||||
|
@ -316,7 +305,6 @@ class SubConfig:
|
||||||
for idx in range(length):
|
for idx in range(length):
|
||||||
soption_bag = OptionBag()
|
soption_bag = OptionBag()
|
||||||
soption_bag.set_option(option,
|
soption_bag.set_option(option,
|
||||||
option_bag.path,
|
|
||||||
idx,
|
idx,
|
||||||
config_bag)
|
config_bag)
|
||||||
soption_bag.properties = await self.cfgimpl_get_settings().getproperties(soption_bag)
|
soption_bag.properties = await self.cfgimpl_get_settings().getproperties(soption_bag)
|
||||||
|
@ -374,7 +362,6 @@ class SubConfig:
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
path = option.impl_getpath()
|
path = option.impl_getpath()
|
||||||
option_bag.set_option(option,
|
option_bag.set_option(option,
|
||||||
path,
|
|
||||||
None,
|
None,
|
||||||
config_bag)
|
config_bag)
|
||||||
option_bag.properties = await self.cfgimpl_get_settings().getproperties(option_bag)
|
option_bag.properties = await self.cfgimpl_get_settings().getproperties(option_bag)
|
||||||
|
@ -413,116 +400,90 @@ class SubConfig:
|
||||||
async def make_dict(self,
|
async def make_dict(self,
|
||||||
config_bag,
|
config_bag,
|
||||||
flatten=False,
|
flatten=False,
|
||||||
_currpath=None,
|
fullpath=False,
|
||||||
withoption=None,
|
leader_to_list=False):
|
||||||
withvalue=undefined,
|
|
||||||
fullpath=False):
|
|
||||||
"""exports the whole config into a `dict`
|
"""exports the whole config into a `dict`
|
||||||
:returns: dict of Option's name (or path) and values
|
:returns: dict of Option's name (or path) and values
|
||||||
"""
|
"""
|
||||||
pathsvalues = {}
|
pathsvalues = {}
|
||||||
if _currpath is None:
|
await self._make_dict(config_bag,
|
||||||
_currpath = []
|
[],
|
||||||
if withoption is None and withvalue is not undefined:
|
|
||||||
raise ValueError(_("make_dict can't filtering with value without "
|
|
||||||
"option"))
|
|
||||||
context = self.cfgimpl_get_context()
|
|
||||||
await self._make_dict(context,
|
|
||||||
config_bag,
|
|
||||||
flatten,
|
flatten,
|
||||||
_currpath,
|
|
||||||
withoption,
|
|
||||||
withvalue,
|
|
||||||
fullpath,
|
fullpath,
|
||||||
pathsvalues)
|
pathsvalues,
|
||||||
|
leader_to_list)
|
||||||
return pathsvalues
|
return pathsvalues
|
||||||
|
|
||||||
async def _make_dict(self,
|
async def _make_dict(self,
|
||||||
context,
|
|
||||||
config_bag,
|
config_bag,
|
||||||
flatten,
|
|
||||||
_currpath,
|
_currpath,
|
||||||
withoption,
|
flatten,
|
||||||
withvalue,
|
|
||||||
fullpath,
|
fullpath,
|
||||||
pathsvalues):
|
pathsvalues,
|
||||||
if withoption is not None:
|
leader_to_list):
|
||||||
# Find all option with criteria
|
for opt in await self.cfgimpl_get_description().get_children(config_bag):
|
||||||
# retrieve OptionDescription and make_dict on it
|
if opt.impl_is_optiondescription() and leader_to_list and opt.impl_is_leadership():
|
||||||
mypath = self.cfgimpl_get_path()
|
children = await opt.get_children(config_bag)
|
||||||
async for path in context.find(bytype=None,
|
leader = children[0]
|
||||||
byname=withoption,
|
loption_bag = OptionBag()
|
||||||
byvalue=withvalue,
|
loption_bag.set_option(leader,
|
||||||
_subpath=self.cfgimpl_get_path(False),
|
None,
|
||||||
config_bag=config_bag):
|
|
||||||
path = '.'.join(path.split('.')[:-1])
|
|
||||||
if '.' in path:
|
|
||||||
subconfig, subpath = await context.cfgimpl_get_home_by_path(path,
|
|
||||||
config_bag)
|
config_bag)
|
||||||
else:
|
loption_bag.properties = await self.cfgimpl_get_settings().getproperties(loption_bag)
|
||||||
subconfig = context
|
leader_pathsvalues = {}
|
||||||
subpath = path
|
leader_currpath = _currpath + [leader.impl_getname()]
|
||||||
opt = await subconfig.cfgimpl_get_description().get_child(subpath,
|
await self._make_sub_dict(leader_pathsvalues,
|
||||||
|
leader_currpath,
|
||||||
|
loption_bag,
|
||||||
|
flatten,
|
||||||
|
fullpath,
|
||||||
|
leader_to_list)
|
||||||
|
if not leader_pathsvalues:
|
||||||
|
continue
|
||||||
|
leader_name = list(leader_pathsvalues.keys())[0]
|
||||||
|
pathsvalues[leader_name] = []
|
||||||
|
subconfig = await SubConfig(opt,
|
||||||
|
self._impl_context,
|
||||||
config_bag,
|
config_bag,
|
||||||
subconfig.cfgimpl_get_path())
|
opt.impl_getpath())
|
||||||
|
for idx, value in enumerate(leader_pathsvalues[leader_name]):
|
||||||
|
leadership_pathsvalues = {leader_name: value}
|
||||||
|
for follower_opt in children[1:]:
|
||||||
|
foption_bag = OptionBag()
|
||||||
|
foption_bag.set_option(follower_opt,
|
||||||
|
idx,
|
||||||
|
config_bag)
|
||||||
|
foption_bag.properties = await self.cfgimpl_get_settings().getproperties(foption_bag)
|
||||||
|
await subconfig._make_sub_dict(leadership_pathsvalues,
|
||||||
|
leader_currpath,
|
||||||
|
foption_bag,
|
||||||
|
flatten,
|
||||||
|
fullpath,
|
||||||
|
leader_to_list)
|
||||||
|
pathsvalues[leader_name].append(leadership_pathsvalues)
|
||||||
|
else:
|
||||||
soption_bag = OptionBag()
|
soption_bag = OptionBag()
|
||||||
soption_bag.set_option(opt,
|
soption_bag.set_option(opt,
|
||||||
path,
|
|
||||||
None,
|
None,
|
||||||
config_bag)
|
config_bag)
|
||||||
soption_bag.properties = await self.cfgimpl_get_settings().getproperties(soption_bag)
|
soption_bag.properties = await self.cfgimpl_get_settings().getproperties(soption_bag)
|
||||||
if mypath is not None:
|
await self._make_sub_dict(pathsvalues,
|
||||||
if mypath == path:
|
|
||||||
withoption = None
|
|
||||||
withvalue = undefined
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
tmypath = mypath + '.'
|
|
||||||
assert path.startswith(tmypath), _('unexpected path "{0}", '
|
|
||||||
'should start with "{1}"'
|
|
||||||
'').format(path, mypath)
|
|
||||||
path = path[len(tmypath):]
|
|
||||||
await self._make_sub_dict(path,
|
|
||||||
pathsvalues,
|
|
||||||
_currpath,
|
_currpath,
|
||||||
flatten,
|
|
||||||
soption_bag,
|
soption_bag,
|
||||||
fullpath,
|
|
||||||
context,
|
|
||||||
withvalue)
|
|
||||||
|
|
||||||
#withoption can be set to None below !
|
|
||||||
if withoption is None:
|
|
||||||
children = await self.cfgimpl_get_description().get_children(config_bag)
|
|
||||||
for opt in children:
|
|
||||||
name = opt.impl_getname()
|
|
||||||
path = self._get_subpath(name)
|
|
||||||
soption_bag = OptionBag()
|
|
||||||
soption_bag.set_option(opt,
|
|
||||||
path,
|
|
||||||
None,
|
|
||||||
config_bag)
|
|
||||||
soption_bag.properties = await self.cfgimpl_get_settings().getproperties(soption_bag)
|
|
||||||
await self._make_sub_dict(name,
|
|
||||||
pathsvalues,
|
|
||||||
_currpath,
|
|
||||||
flatten,
|
flatten,
|
||||||
soption_bag,
|
|
||||||
fullpath,
|
fullpath,
|
||||||
context,
|
leader_to_list)
|
||||||
withvalue)
|
|
||||||
return pathsvalues
|
return pathsvalues
|
||||||
|
|
||||||
async def _make_sub_dict(self,
|
async def _make_sub_dict(self,
|
||||||
name,
|
|
||||||
pathsvalues,
|
pathsvalues,
|
||||||
_currpath,
|
_currpath,
|
||||||
flatten,
|
|
||||||
option_bag,
|
option_bag,
|
||||||
|
flatten,
|
||||||
fullpath,
|
fullpath,
|
||||||
context,
|
leader_to_list):
|
||||||
withvalue):
|
|
||||||
option = option_bag.option
|
option = option_bag.option
|
||||||
|
name = option.impl_getname()
|
||||||
if option.impl_is_optiondescription():
|
if option.impl_is_optiondescription():
|
||||||
try:
|
try:
|
||||||
await self.cfgimpl_get_settings().validate_properties(option_bag)
|
await self.cfgimpl_get_settings().validate_properties(option_bag)
|
||||||
|
@ -530,14 +491,12 @@ class SubConfig:
|
||||||
self._impl_context,
|
self._impl_context,
|
||||||
option_bag.config_bag,
|
option_bag.config_bag,
|
||||||
option_bag.path)
|
option_bag.path)
|
||||||
await subconfig._make_dict(context,
|
await subconfig._make_dict(option_bag.config_bag,
|
||||||
option_bag.config_bag,
|
|
||||||
flatten,
|
|
||||||
_currpath + [name],
|
_currpath + [name],
|
||||||
None,
|
flatten,
|
||||||
withvalue,
|
|
||||||
fullpath,
|
fullpath,
|
||||||
pathsvalues)
|
pathsvalues,
|
||||||
|
leader_to_list)
|
||||||
except PropertiesOptionError as err:
|
except PropertiesOptionError as err:
|
||||||
if err.proptype in (['mandatory'], ['empty']):
|
if err.proptype in (['mandatory'], ['empty']):
|
||||||
raise err
|
raise err
|
||||||
|
@ -554,7 +513,7 @@ class SubConfig:
|
||||||
if flatten:
|
if flatten:
|
||||||
name_ = option.impl_getname()
|
name_ = option.impl_getname()
|
||||||
elif fullpath:
|
elif fullpath:
|
||||||
name_ = self._get_subpath(name)
|
name_ = option.impl_getpath()
|
||||||
else:
|
else:
|
||||||
name_ = '.'.join(_currpath + [name])
|
name_ = '.'.join(_currpath + [name])
|
||||||
pathsvalues[name_] = ret
|
pathsvalues[name_] = ret
|
||||||
|
@ -879,7 +838,6 @@ class KernelGroupConfig(_CommonConfig):
|
||||||
child.cfgimpl_get_path())
|
child.cfgimpl_get_path())
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(option,
|
option_bag.set_option(option,
|
||||||
path,
|
|
||||||
index,
|
index,
|
||||||
cconfig_bag)
|
cconfig_bag)
|
||||||
option_bag.properties = await settings.getproperties(option_bag)
|
option_bag.properties = await settings.getproperties(option_bag)
|
||||||
|
@ -977,7 +935,6 @@ class KernelGroupConfig(_CommonConfig):
|
||||||
subconfig.cfgimpl_get_path())
|
subconfig.cfgimpl_get_path())
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(option,
|
option_bag.set_option(option,
|
||||||
path,
|
|
||||||
None,
|
None,
|
||||||
config_bag)
|
config_bag)
|
||||||
option_bag.properties = await child.cfgimpl_get_settings().getproperties(option_bag)
|
option_bag.properties = await child.cfgimpl_get_settings().getproperties(option_bag)
|
||||||
|
@ -1061,7 +1018,6 @@ class KernelMixConfig(KernelGroupConfig):
|
||||||
self.cfgimpl_get_path())
|
self.cfgimpl_get_path())
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(option,
|
option_bag.set_option(option,
|
||||||
path,
|
|
||||||
index,
|
index,
|
||||||
config_bag)
|
config_bag)
|
||||||
option_bag.properties = await self.cfgimpl_get_settings().getproperties(option_bag)
|
option_bag.properties = await self.cfgimpl_get_settings().getproperties(option_bag)
|
||||||
|
@ -1093,7 +1049,6 @@ class KernelMixConfig(KernelGroupConfig):
|
||||||
child.cfgimpl_get_path())
|
child.cfgimpl_get_path())
|
||||||
moption_bag = OptionBag()
|
moption_bag = OptionBag()
|
||||||
moption_bag.set_option(option,
|
moption_bag.set_option(option,
|
||||||
path,
|
|
||||||
index,
|
index,
|
||||||
cconfig_bag)
|
cconfig_bag)
|
||||||
moption_bag.properties = await settings.getproperties(moption_bag)
|
moption_bag.properties = await settings.getproperties(moption_bag)
|
||||||
|
@ -1155,7 +1110,6 @@ class KernelMixConfig(KernelGroupConfig):
|
||||||
subconfig.cfgimpl_get_path())
|
subconfig.cfgimpl_get_path())
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(option,
|
option_bag.set_option(option,
|
||||||
path,
|
|
||||||
None,
|
None,
|
||||||
rconfig_bag)
|
rconfig_bag)
|
||||||
option_bag.properties = await self.cfgimpl_get_settings().getproperties(option_bag)
|
option_bag.properties = await self.cfgimpl_get_settings().getproperties(option_bag)
|
||||||
|
@ -1168,7 +1122,6 @@ class KernelMixConfig(KernelGroupConfig):
|
||||||
subconfig.cfgimpl_get_path())
|
subconfig.cfgimpl_get_path())
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(option,
|
option_bag.set_option(option,
|
||||||
path,
|
|
||||||
None,
|
None,
|
||||||
rconfig_bag)
|
rconfig_bag)
|
||||||
option_bag.properties = await self.cfgimpl_get_settings().getproperties(option_bag)
|
option_bag.properties = await self.cfgimpl_get_settings().getproperties(option_bag)
|
||||||
|
@ -1188,7 +1141,6 @@ class KernelMixConfig(KernelGroupConfig):
|
||||||
child.cfgimpl_get_path())
|
child.cfgimpl_get_path())
|
||||||
moption_bag = OptionBag()
|
moption_bag = OptionBag()
|
||||||
moption_bag.set_option(option,
|
moption_bag.set_option(option,
|
||||||
path,
|
|
||||||
None,
|
None,
|
||||||
rconfig_bag)
|
rconfig_bag)
|
||||||
moption_bag.properties = await self.cfgimpl_get_settings().getproperties(moption_bag)
|
moption_bag.properties = await self.cfgimpl_get_settings().getproperties(moption_bag)
|
||||||
|
|
|
@ -71,7 +71,6 @@ class DynOptionDescription(OptionDescription):
|
||||||
config_bag: ConfigBag) -> List[str]:
|
config_bag: ConfigBag) -> List[str]:
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(self,
|
option_bag.set_option(self,
|
||||||
self.impl_getpath(),
|
|
||||||
None,
|
None,
|
||||||
config_bag)
|
config_bag)
|
||||||
values = await self._suffixes.execute(option_bag)
|
values = await self._suffixes.execute(option_bag)
|
||||||
|
|
|
@ -118,10 +118,8 @@ class Leadership(OptionDescription):
|
||||||
config_bag = option_bag.config_bag.copy()
|
config_bag = option_bag.config_bag.copy()
|
||||||
config_bag.remove_validation()
|
config_bag.remove_validation()
|
||||||
for follower in self.get_followers():
|
for follower in self.get_followers():
|
||||||
follower_path = follower.impl_getpath()
|
|
||||||
soption_bag = OptionBag()
|
soption_bag = OptionBag()
|
||||||
soption_bag.set_option(follower,
|
soption_bag.set_option(follower,
|
||||||
follower_path,
|
|
||||||
None,
|
None,
|
||||||
config_bag)
|
config_bag)
|
||||||
soption_bag.properties = await config_bag.context.cfgimpl_get_settings().getproperties(soption_bag)
|
soption_bag.properties = await config_bag.context.cfgimpl_get_settings().getproperties(soption_bag)
|
||||||
|
@ -133,21 +131,22 @@ class Leadership(OptionDescription):
|
||||||
value,
|
value,
|
||||||
option_bag,
|
option_bag,
|
||||||
owner,
|
owner,
|
||||||
_commit) -> None:
|
_commit,
|
||||||
|
dyn=None) -> None:
|
||||||
settings = option_bag.config_bag.context.cfgimpl_get_settings()
|
settings = option_bag.config_bag.context.cfgimpl_get_settings()
|
||||||
if value:
|
if value:
|
||||||
rgevalue = range(len(value))
|
rgevalue = range(len(value))
|
||||||
for follower in await self.get_children(option_bag.config_bag):
|
if dyn is None:
|
||||||
|
dyn = self
|
||||||
|
for follower in await dyn.get_children(option_bag.config_bag):
|
||||||
foption_bag = OptionBag()
|
foption_bag = OptionBag()
|
||||||
foption_bag.set_option(follower,
|
foption_bag.set_option(follower,
|
||||||
follower.impl_getpath(),
|
|
||||||
None,
|
None,
|
||||||
option_bag.config_bag)
|
option_bag.config_bag)
|
||||||
if 'force_store_value' in await settings.getproperties(foption_bag):
|
if 'force_store_value' in await settings.getproperties(foption_bag):
|
||||||
for index in rgevalue:
|
for index in rgevalue:
|
||||||
foption_bag = OptionBag()
|
foption_bag = OptionBag()
|
||||||
foption_bag.set_option(follower,
|
foption_bag.set_option(follower,
|
||||||
follower.impl_getpath(),
|
|
||||||
index,
|
index,
|
||||||
option_bag.config_bag)
|
option_bag.config_bag)
|
||||||
foption_bag.properties = await settings.getproperties(foption_bag)
|
foption_bag.properties = await settings.getproperties(foption_bag)
|
||||||
|
@ -171,7 +170,6 @@ class Leadership(OptionDescription):
|
||||||
followerlen = await values._p_.get_max_length(follower_path)
|
followerlen = await values._p_.get_max_length(follower_path)
|
||||||
soption_bag = OptionBag()
|
soption_bag = OptionBag()
|
||||||
soption_bag.set_option(follower,
|
soption_bag.set_option(follower,
|
||||||
follower_path,
|
|
||||||
index,
|
index,
|
||||||
config_bag)
|
config_bag)
|
||||||
# do not check force_default_on_freeze or force_metaconfig_on_freeze
|
# do not check force_default_on_freeze or force_metaconfig_on_freeze
|
||||||
|
|
|
@ -116,7 +116,6 @@ class Option(BaseOption):
|
||||||
return
|
return
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(self,
|
option_bag.set_option(self,
|
||||||
undefined,
|
|
||||||
None,
|
None,
|
||||||
undefined)
|
undefined)
|
||||||
try:
|
try:
|
||||||
|
@ -148,7 +147,6 @@ class Option(BaseOption):
|
||||||
_setattr(self, '_default_multi', default_multi)
|
_setattr(self, '_default_multi', default_multi)
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(self,
|
option_bag.set_option(self,
|
||||||
undefined,
|
|
||||||
None,
|
None,
|
||||||
undefined)
|
undefined)
|
||||||
self.sync_impl_validate(default,
|
self.sync_impl_validate(default,
|
||||||
|
|
|
@ -117,7 +117,6 @@ class CacheOptionDescription(BaseOption):
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
leader = option.impl_get_leadership().get_leader()
|
leader = option.impl_get_leadership().get_leader()
|
||||||
option_bag.set_option(leader,
|
option_bag.set_option(leader,
|
||||||
leader.impl_getpath(),
|
|
||||||
None,
|
None,
|
||||||
config_bag)
|
config_bag)
|
||||||
option_bag.properties = frozenset()
|
option_bag.properties = frozenset()
|
||||||
|
@ -125,7 +124,6 @@ class CacheOptionDescription(BaseOption):
|
||||||
for index in range(follower_len):
|
for index in range(follower_len):
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(option,
|
option_bag.set_option(option,
|
||||||
subpath,
|
|
||||||
index,
|
index,
|
||||||
config_bag)
|
config_bag)
|
||||||
option_bag.properties = frozenset()
|
option_bag.properties = frozenset()
|
||||||
|
@ -137,7 +135,6 @@ class CacheOptionDescription(BaseOption):
|
||||||
else:
|
else:
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(option,
|
option_bag.set_option(option,
|
||||||
subpath,
|
|
||||||
None,
|
None,
|
||||||
config_bag)
|
config_bag)
|
||||||
option_bag.properties = frozenset()
|
option_bag.properties = frozenset()
|
||||||
|
@ -183,7 +180,7 @@ class OptionDescriptionWalk(CacheOptionDescription):
|
||||||
|
|
||||||
async def get_children(self,
|
async def get_children(self,
|
||||||
config_bag: Union[ConfigBag, Undefined],
|
config_bag: Union[ConfigBag, Undefined],
|
||||||
dyn: bool=True) -> Iterator[Union[BaseOption, SynDynOptionDescription]]:
|
dyn: bool=True) -> Union[BaseOption, SynDynOptionDescription]:
|
||||||
if not dyn or config_bag is undefined or \
|
if not dyn or config_bag is undefined or \
|
||||||
config_bag.context.cfgimpl_get_description() == self:
|
config_bag.context.cfgimpl_get_description() == self:
|
||||||
subpath = ''
|
subpath = ''
|
||||||
|
|
|
@ -145,3 +145,16 @@ class SynDynLeadership(SynDynOptionDescription):
|
||||||
await self._opt.pop(*args,
|
await self._opt.pop(*args,
|
||||||
followers=self.get_followers(),
|
followers=self.get_followers(),
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
|
||||||
|
async def follower_force_store_value(self,
|
||||||
|
values,
|
||||||
|
value,
|
||||||
|
option_bag,
|
||||||
|
owner,
|
||||||
|
_commit) -> None:
|
||||||
|
await self._opt.follower_force_store_value(values,
|
||||||
|
value,
|
||||||
|
option_bag,
|
||||||
|
owner,
|
||||||
|
_commit,
|
||||||
|
dyn=self)
|
||||||
|
|
|
@ -143,12 +143,12 @@ class OptionBag:
|
||||||
|
|
||||||
def set_option(self,
|
def set_option(self,
|
||||||
option,
|
option,
|
||||||
path,
|
|
||||||
index,
|
index,
|
||||||
config_bag):
|
config_bag):
|
||||||
if path is None:
|
if config_bag is undefined:
|
||||||
path = option.impl_getpath()
|
self.path = None
|
||||||
self.path = path
|
else:
|
||||||
|
self.path = option.impl_getpath()
|
||||||
self.index = index
|
self.index = index
|
||||||
self.option = option
|
self.option = option
|
||||||
self.config_bag = config_bag
|
self.config_bag = config_bag
|
||||||
|
@ -646,12 +646,14 @@ class Settings(object):
|
||||||
# validate properties
|
# validate properties
|
||||||
async def calc_raises_properties(self,
|
async def calc_raises_properties(self,
|
||||||
option_bag,
|
option_bag,
|
||||||
apply_requires=True):
|
apply_requires=True,
|
||||||
if apply_requires and option_bag.properties_setted:
|
uncalculated=False):
|
||||||
|
if not uncalculated and apply_requires and option_bag.properties_setted:
|
||||||
option_properties = option_bag.properties
|
option_properties = option_bag.properties
|
||||||
else:
|
else:
|
||||||
option_properties = await self.getproperties(option_bag,
|
option_properties = await self.getproperties(option_bag,
|
||||||
apply_requires=apply_requires)
|
apply_requires=apply_requires,
|
||||||
|
uncalculated=uncalculated)
|
||||||
return self._calc_raises_properties(option_bag.config_bag.properties,
|
return self._calc_raises_properties(option_bag.config_bag.properties,
|
||||||
option_bag.config_bag.permissives,
|
option_bag.config_bag.permissives,
|
||||||
option_properties)
|
option_properties)
|
||||||
|
|
|
@ -206,7 +206,7 @@ class Requires(object):
|
||||||
else:
|
else:
|
||||||
act = 'hide'
|
act = 'hide'
|
||||||
inv_act = 'show'
|
inv_act = 'show'
|
||||||
if isinstance(option, ChoiceOption):
|
if option.get_type() == 'choice':
|
||||||
require_option = self.tiramisu_web.config.unrestraint.option(option_path)
|
require_option = self.tiramisu_web.config.unrestraint.option(option_path)
|
||||||
values = await self.tiramisu_web.get_enum(require_option,
|
values = await self.tiramisu_web.get_enum(require_option,
|
||||||
await require_option.option.ismulti(),
|
await require_option.option.ismulti(),
|
||||||
|
@ -239,7 +239,7 @@ class Requires(object):
|
||||||
#collect id of all options
|
#collect id of all options
|
||||||
child = await childapi.option.get()
|
child = await childapi.option.get()
|
||||||
if isinstance(child, SynDynOption):
|
if isinstance(child, SynDynOption):
|
||||||
child = child._impl_getopt()
|
child = child.opt
|
||||||
self.options[child] = path
|
self.options[child] = path
|
||||||
current_action = None
|
current_action = None
|
||||||
|
|
||||||
|
@ -439,7 +439,7 @@ class TiramisuDict:
|
||||||
child = await childapi_option.get()
|
child = await childapi_option.get()
|
||||||
childtype = child.__class__.__name__
|
childtype = child.__class__.__name__
|
||||||
if childtype == 'SynDynOption':
|
if childtype == 'SynDynOption':
|
||||||
childtype = child._impl_getopt().__class__.__name__
|
childtype = child.opt.__class__.__name__
|
||||||
if await childapi_option.issymlinkoption():
|
if await childapi_option.issymlinkoption():
|
||||||
web_type = 'symlink'
|
web_type = 'symlink'
|
||||||
value = None
|
value = None
|
||||||
|
@ -608,7 +608,8 @@ class TiramisuDict:
|
||||||
settings = config.cfgimpl_get_settings()
|
settings = config.cfgimpl_get_settings()
|
||||||
childapi._option_bag.config_bag.properties = await settings.get_context_properties(config._impl_properties_cache)
|
childapi._option_bag.config_bag.properties = await settings.get_context_properties(config._impl_properties_cache)
|
||||||
childapi._option_bag.config_bag.properties -= {'permissive'}
|
childapi._option_bag.config_bag.properties -= {'permissive'}
|
||||||
properties = await childapi.property.get(only_raises=True)
|
properties = await childapi.property.get(only_raises=True,
|
||||||
|
uncalculated=True)
|
||||||
properties -= await childapi.permissive.get()
|
properties -= await childapi.permissive.get()
|
||||||
# 'hidden=True' means cannot access with or without permissive option
|
# 'hidden=True' means cannot access with or without permissive option
|
||||||
# 'display=False' means cannot access only without permissive option
|
# 'display=False' means cannot access only without permissive option
|
||||||
|
|
|
@ -616,13 +616,10 @@ class Values:
|
||||||
settings = context.cfgimpl_get_settings()
|
settings = context.cfgimpl_get_settings()
|
||||||
for option in await description.get_children(config_bag):
|
for option in await description.get_children(config_bag):
|
||||||
name = option.impl_getname()
|
name = option.impl_getname()
|
||||||
path = '.'.join(currpath + [name])
|
|
||||||
|
|
||||||
if option.impl_is_optiondescription():
|
if option.impl_is_optiondescription():
|
||||||
try:
|
try:
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(option,
|
option_bag.set_option(option,
|
||||||
path,
|
|
||||||
None,
|
None,
|
||||||
od_config_bag)
|
od_config_bag)
|
||||||
option_bag.properties = await settings.getproperties(option_bag)
|
option_bag.properties = await settings.getproperties(option_bag)
|
||||||
|
@ -644,7 +641,6 @@ class Values:
|
||||||
if not option.impl_is_follower():
|
if not option.impl_is_follower():
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(option,
|
option_bag.set_option(option,
|
||||||
path,
|
|
||||||
None,
|
None,
|
||||||
config_bag)
|
config_bag)
|
||||||
option_bag.properties = await settings.getproperties(option_bag)
|
option_bag.properties = await settings.getproperties(option_bag)
|
||||||
|
@ -655,7 +651,6 @@ class Values:
|
||||||
for index in range(subconfig.cfgimpl_get_length()):
|
for index in range(subconfig.cfgimpl_get_length()):
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(option,
|
option_bag.set_option(option,
|
||||||
path,
|
|
||||||
index,
|
index,
|
||||||
config_bag)
|
config_bag)
|
||||||
option_bag.properties = await settings.getproperties(option_bag)
|
option_bag.properties = await settings.getproperties(option_bag)
|
||||||
|
@ -664,7 +659,7 @@ class Values:
|
||||||
option_bag)
|
option_bag)
|
||||||
except PropertiesOptionError as err:
|
except PropertiesOptionError as err:
|
||||||
if err.proptype in (['mandatory'], ['empty']):
|
if err.proptype in (['mandatory'], ['empty']):
|
||||||
yield path
|
yield option.impl_getpath()
|
||||||
except ConfigError:
|
except ConfigError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue