remove_check and remove_condition must be explicite
This commit is contained in:
parent
afdc19887f
commit
08ed28fc95
|
@ -704,7 +704,9 @@ class ConstraintAnnotator:
|
|||
for idx, check in enumerate(self.objectspace.space.constraints.check):
|
||||
if check.name == 'valid_enum':
|
||||
if check.target in self.valid_enums:
|
||||
raise DictConsistencyError(_(f'valid_enum already set for {check.target}'))
|
||||
old_xmlfiles = self.objectspace.display_xmlfiles(self.valid_enums[check.target]['xmlfiles'])
|
||||
xmlfiles = self.objectspace.display_xmlfiles(check.xmlfiles)
|
||||
raise DictConsistencyError(_(f'valid_enum define in {xmlfiles} but already set in {old_xmlfiles} for "{check.target}", did you forget remove_check?'))
|
||||
if not hasattr(check, 'param'):
|
||||
raise DictConsistencyError(_(f'param is mandatory for a valid_enum of variable {check.target}'))
|
||||
variable = self.objectspace.paths.get_variable_obj(check.target)
|
||||
|
@ -715,7 +717,8 @@ class ConstraintAnnotator:
|
|||
self._set_valid_enum(variable,
|
||||
values,
|
||||
variable.type,
|
||||
check.target
|
||||
check.target,
|
||||
check.xmlfiles,
|
||||
)
|
||||
remove_indexes.append(idx)
|
||||
remove_indexes.sort(reverse=True)
|
||||
|
@ -957,7 +960,13 @@ class ConstraintAnnotator:
|
|||
variable.property.append(prop)
|
||||
del self.objectspace.space.constraints.condition
|
||||
|
||||
def _set_valid_enum(self, variable, values, type_, target):
|
||||
def _set_valid_enum(self,
|
||||
variable,
|
||||
values,
|
||||
type_,
|
||||
target: str,
|
||||
xmlfiles: List[str],
|
||||
):
|
||||
# value for choice's variable is mandatory
|
||||
variable.mandatory = True
|
||||
# build choice
|
||||
|
@ -970,6 +979,7 @@ class ConstraintAnnotator:
|
|||
else:
|
||||
self.valid_enums[target] = {'type': type_,
|
||||
'values': values,
|
||||
'xmlfiles': xmlfiles,
|
||||
}
|
||||
choices = []
|
||||
for value in values:
|
||||
|
|
|
@ -515,12 +515,6 @@ class CreoleObjSpace:
|
|||
self.fill_removed.append(child.attrib['target'])
|
||||
if not hasattr(variableobj, 'index'):
|
||||
variableobj.index = self.index
|
||||
if child.tag == 'check' and child.attrib['target'] in self.redefine_variables and child.attrib['target'] not in self.check_removed:
|
||||
self.remove_check(child.attrib['target'])
|
||||
self.check_removed.append(child.attrib['target'])
|
||||
if child.tag == 'condition' and child.attrib['source'] in self.redefine_variables and child.attrib['source'] not in self.condition_removed:
|
||||
self.remove_condition(child.attrib['source'])
|
||||
self.condition_removed.append(child.attrib['source'])
|
||||
variableobj.namespace = namespace
|
||||
|
||||
def fill_variableobj_path_attribute(self,
|
||||
|
|
|
@ -25,9 +25,6 @@
|
|||
<check name="valid_differ" target="mode_conteneur_actif3">
|
||||
<param type="variable">mode_conteneur_actif1</param>
|
||||
</check>
|
||||
<check name="valid_differ" target="mode_conteneur_actif3">
|
||||
<param type="variable">mode_conteneur_actif1</param>
|
||||
</check>
|
||||
</constraints>
|
||||
|
||||
<help/>
|
||||
|
|
|
@ -11,7 +11,7 @@ from rougail.tiramisu import ConvertDynOptionDescription
|
|||
option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='oui', values=('oui', 'non'))
|
||||
option_4 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif1', doc='No change', multi=False, default='non', values=('oui', 'non'))
|
||||
option_5 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif2', doc='No change', multi=False, default='non', values=('oui', 'non'))
|
||||
option_6 = StrOption(properties=frozenset({'mandatory', 'normal'}), validators=[Calculation(func.valid_not_equal, Params((ParamSelfOption(), ParamOption(option_4, notraisepropertyerror=False, todict=True)), kwargs={}), warnings_only=False), Calculation(func.valid_not_equal, Params((ParamSelfOption(), ParamOption(option_5, notraisepropertyerror=False, todict=True)), kwargs={}), warnings_only=False)], name='mode_conteneur_actif3', doc='No change', multi=False, default='oui')
|
||||
option_6 = StrOption(properties=frozenset({'mandatory', 'normal'}), validators=[Calculation(func.valid_not_equal, Params((ParamSelfOption(), ParamOption(option_4, notraisepropertyerror=False, todict=True)), kwargs={}), warnings_only=False), Calculation(func.valid_not_equal, Params((ParamSelfOption(), ParamOption(option_4, notraisepropertyerror=False, todict=True)), kwargs={}), warnings_only=False), Calculation(func.valid_not_equal, Params((ParamSelfOption(), ParamOption(option_5, notraisepropertyerror=False, todict=True)), kwargs={}), warnings_only=False)], name='mode_conteneur_actif3', doc='No change', multi=False, default='oui')
|
||||
option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3, option_4, option_5, option_6])
|
||||
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2])
|
||||
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])
|
||||
|
|
|
@ -25,9 +25,6 @@
|
|||
<check name="valid_differ" target="mode_conteneur_actif3">
|
||||
<param type="variable">mode_conteneur_actif1</param>
|
||||
</check>
|
||||
<check name="valid_differ" target="mode_conteneur_actif3">
|
||||
<param type="variable">mode_conteneur_actif2</param>
|
||||
</check>
|
||||
</constraints>
|
||||
|
||||
<help/>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<variables>
|
||||
<family name="general">
|
||||
<variable name="mode_conteneur_actif3" redefine="True">
|
||||
<variable name="mode_conteneur_actif3" redefine="True" remove_check="True">
|
||||
<value>oui</value>
|
||||
</variable>
|
||||
</family>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<variables>
|
||||
<family name="enumfam" mode="expert">
|
||||
<variable name="enumvar" redefine="True">
|
||||
<variable name="enumvar" redefine="True" remove_check="True">
|
||||
<value>c</value>
|
||||
</variable>
|
||||
</family>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<rougail>
|
||||
<variables>
|
||||
<family name="general">
|
||||
<variable name="condition" redefine="True"/>
|
||||
<variable name="condition" redefine="True" remove_condition="True"/>
|
||||
</family>
|
||||
</variables>
|
||||
|
||||
|
|
Loading…
Reference in New Issue