remove_check and remove_condition must be explicite
This commit is contained in:
@ -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,
|
||||
|
Reference in New Issue
Block a user