support submulti with follower
This commit is contained in:
parent
308e980bfd
commit
d47d1fde62
@ -385,18 +385,21 @@ class Variable(Common):
|
||||
if 'default' not in self.attrib:
|
||||
self.attrib['default'] = []
|
||||
value = convert_tiramisu_value(child.text, type_)
|
||||
if not isinstance(value, list) and not is_follower:
|
||||
value = [value]
|
||||
self.attrib['default'].append(value)
|
||||
if 'default_multi' not in self.attrib and not is_leader:
|
||||
self.attrib['default_multi'] = value
|
||||
if not is_follower:
|
||||
if not isinstance(value, list):
|
||||
dvalue = [value]
|
||||
else:
|
||||
dvalue = value
|
||||
self.attrib['default'].append(dvalue)
|
||||
if value and 'default_multi' not in self.attrib and not is_leader:
|
||||
self.attrib['default_multi'] = []
|
||||
if not is_leader:
|
||||
self.attrib['default_multi'].append(value)
|
||||
else:
|
||||
if 'default' in self.attrib:
|
||||
raise CreoleLoaderError(_('default value already set for {}'
|
||||
'').format(self.attrib['path']))
|
||||
value = convert_tiramisu_value(child.text, type_)
|
||||
if value is None: # and (elt.attrib['type'] != 'choice' or value not in self.attrib['values']):
|
||||
value = u''
|
||||
if is_follower:
|
||||
self.attrib['default_multi'] = value
|
||||
else:
|
||||
|
@ -0,0 +1,33 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<rougail>
|
||||
|
||||
<services/>
|
||||
|
||||
<variables>
|
||||
<family name="general">
|
||||
<variable name="mode_conteneur_actif" type="oui/non" description="leader" multi="True">
|
||||
<value>non</value>
|
||||
</variable>
|
||||
<variable name="leader" type="string" description="leader" multi="True">
|
||||
<value>leader</value>
|
||||
</variable>
|
||||
<variable name="follower1" type="string" description="follower1" submulti="True">
|
||||
<value>value</value>
|
||||
</variable>
|
||||
<variable name="follower2" type="string" description="follower2" submulti="True">
|
||||
<value>value1</value>
|
||||
<value>value2</value>
|
||||
</variable>
|
||||
</family>
|
||||
</variables>
|
||||
|
||||
<constraints>
|
||||
<group leader="leader">
|
||||
<follower>follower1</follower>
|
||||
<follower>follower2</follower>
|
||||
</group>
|
||||
</constraints>
|
||||
|
||||
<help/>
|
||||
|
||||
</rougail>
|
@ -0,0 +1 @@
|
||||
{"creole.general.mode_conteneur_actif": ["non"], "creole.general.leader.leader": ["leader"], "creole.general.leader.follower1": [["value"]], "creole.general.leader.follower2": [["value1", "value2"]]}
|
@ -0,0 +1,33 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<creole>
|
||||
<family doc="" name="creole">
|
||||
<family doc="general" name="general">
|
||||
<property>normal</property>
|
||||
<variable doc="leader" multi="True" name="mode_conteneur_actif" type="choice">
|
||||
<choice type="string">oui</choice>
|
||||
<choice type="string">non</choice>
|
||||
<property>mandatory</property>
|
||||
<property>normal</property>
|
||||
<value type="string">non</value>
|
||||
</variable>
|
||||
<leader doc="leader" name="leader">
|
||||
<property>normal</property>
|
||||
<variable doc="leader" multi="True" name="leader" type="string">
|
||||
<property>mandatory</property>
|
||||
<value>leader</value>
|
||||
</variable>
|
||||
<variable doc="follower1" multi="submulti" name="follower1" type="string">
|
||||
<property>mandatory</property>
|
||||
<property>normal</property>
|
||||
<value>value</value>
|
||||
</variable>
|
||||
<variable doc="follower2" multi="submulti" name="follower2" type="string">
|
||||
<property>mandatory</property>
|
||||
<property>normal</property>
|
||||
<value>value1</value>
|
||||
<value>value2</value>
|
||||
</variable>
|
||||
</leader>
|
||||
</family>
|
||||
</family>
|
||||
</creole>
|
34
tests/flattener_dicos/10load_leadership_submulti/00-base.xml
Normal file
34
tests/flattener_dicos/10load_leadership_submulti/00-base.xml
Normal file
@ -0,0 +1,34 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<rougail>
|
||||
|
||||
<services/>
|
||||
|
||||
<variables>
|
||||
<family name="general">
|
||||
<variable name="mode_conteneur_actif" type="oui/non" description="No change">
|
||||
<value>non</value>
|
||||
</variable>
|
||||
</family>
|
||||
<family name="general1">
|
||||
<variable name="leader" type="string" description="leader" multi="True"/>
|
||||
<variable name="follower1" type="string" description="follower1" multi="True"/>
|
||||
<variable name="follower2" type="string" description="follower2" submulti="True"/>
|
||||
</family>
|
||||
</variables>
|
||||
|
||||
<constraints>
|
||||
<fill name="calc_val" target="follower1">
|
||||
<param name="valeur">valfill</param>
|
||||
</fill>
|
||||
<fill name="calc_val" target="follower2">
|
||||
<param type="variable">follower1</param>
|
||||
</fill>
|
||||
<group leader="leader">
|
||||
<follower>follower1</follower>
|
||||
<follower>follower2</follower>
|
||||
</group>
|
||||
</constraints>
|
||||
|
||||
<help/>
|
||||
|
||||
</rougail>
|
@ -0,0 +1 @@
|
||||
{"creole.general.mode_conteneur_actif": "non", "creole.general1.leader.leader": [], "creole.general1.leader.follower1": [], "creole.general1.leader.follower2": []}
|
@ -0,0 +1,34 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<creole>
|
||||
<family doc="" name="creole">
|
||||
<family doc="general" name="general">
|
||||
<property>normal</property>
|
||||
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
|
||||
<choice type="string">oui</choice>
|
||||
<choice type="string">non</choice>
|
||||
<property>mandatory</property>
|
||||
<property>normal</property>
|
||||
<value type="string">non</value>
|
||||
</variable>
|
||||
</family>
|
||||
<family doc="general1" name="general1">
|
||||
<property>normal</property>
|
||||
<leader doc="leader" name="leader">
|
||||
<property>normal</property>
|
||||
<variable doc="leader" multi="True" name="leader" type="string"/>
|
||||
<variable doc="follower1" multi="True" name="follower1" type="string">
|
||||
<property>normal</property>
|
||||
<value name="calc_val" type="calculation">
|
||||
<param name="valeur" transitive="False" type="string">valfill</param>
|
||||
</value>
|
||||
</variable>
|
||||
<variable doc="follower2" multi="submulti" name="follower2" type="string">
|
||||
<property>normal</property>
|
||||
<value name="calc_val" type="calculation">
|
||||
<param transitive="False" type="variable">creole.general1.leader.follower1</param>
|
||||
</value>
|
||||
</variable>
|
||||
</leader>
|
||||
</family>
|
||||
</family>
|
||||
</creole>
|
23
tests/flattener_dicos/10load_submulti_two_value/00-base.xml
Normal file
23
tests/flattener_dicos/10load_submulti_two_value/00-base.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<rougail>
|
||||
|
||||
<services/>
|
||||
|
||||
<variables>
|
||||
<family name="general">
|
||||
<variable name="mode_conteneur_actif" type="oui/non" description="Description" submulti="True">
|
||||
<value>non</value>
|
||||
<value>oui</value>
|
||||
</variable>
|
||||
</family>
|
||||
<separators/>
|
||||
</variables>
|
||||
|
||||
<constraints>
|
||||
</constraints>
|
||||
|
||||
<help/>
|
||||
|
||||
</rougail>
|
||||
<!-- vim: ts=4 sw=4 expandtab
|
||||
-->
|
@ -0,0 +1 @@
|
||||
{"creole.general.mode_conteneur_actif": [["non"], ["oui"]]}
|
@ -0,0 +1,17 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<creole>
|
||||
<family doc="" name="creole">
|
||||
<family doc="general" name="general">
|
||||
<property>normal</property>
|
||||
<variable doc="Description" multi="submulti" name="mode_conteneur_actif" type="choice">
|
||||
<choice type="string">oui</choice>
|
||||
<choice type="string">non</choice>
|
||||
<property>mandatory</property>
|
||||
<property>normal</property>
|
||||
<value type="string">non</value>
|
||||
<value type="string">oui</value>
|
||||
</variable>
|
||||
</family>
|
||||
<separators/>
|
||||
</family>
|
||||
</creole>
|
@ -65,7 +65,7 @@ def compare_xml(exported_xmlfile, expected_xmlfile):
|
||||
raise err
|
||||
|
||||
|
||||
def launch_flattener(test_dir):
|
||||
def launch_flattener(test_dir, test_ok=False):
|
||||
eolobj = objspace.CreoleObjSpace(dtdfilename)
|
||||
dirs = [test_dir]
|
||||
subfolder = join(test_dir, 'subfolder')
|
||||
@ -85,6 +85,8 @@ def launch_flattener(test_dir):
|
||||
if isfile(result_file):
|
||||
# eolobj.save(result_file)
|
||||
compare_xml(destfile, result_file)
|
||||
elif test_ok:
|
||||
raise Exception(f'no test found for {test_dir}')
|
||||
|
||||
|
||||
def fake_traduc(txt):
|
||||
@ -105,7 +107,7 @@ def teardown_module(module):
|
||||
|
||||
def test_dictionary(test_dir):
|
||||
test_dir = join(dico_dirs, test_dir)
|
||||
launch_flattener(test_dir)
|
||||
launch_flattener(test_dir, True)
|
||||
|
||||
|
||||
def test_error_dictionary(test_dir_error):
|
||||
|
@ -24,7 +24,7 @@ for test in listdir(dico_dirs):
|
||||
excludes = set([])
|
||||
#excludes = set(['70container_services'])
|
||||
test_ok -= excludes
|
||||
#test_ok = ['70container_services']
|
||||
#test_ok = ['10load_leadership_default_submulti']
|
||||
|
||||
|
||||
test_ok = list(test_ok)
|
||||
|
Loading…
Reference in New Issue
Block a user