remove condition not only a target
This commit is contained in:
@ -765,6 +765,7 @@ class ConstraintAnnotator:
|
||||
if target.type == 'variable':
|
||||
variable = self.objectspace.paths.get_variable_obj(target.name)
|
||||
family = self.objectspace.paths.get_family_obj(target.name.rsplit('.', 1)[0])
|
||||
# it's a leader, so apply property to leadership
|
||||
if isinstance(family, self.objectspace.Leadership) and family.name == variable.name:
|
||||
return family, family.variable
|
||||
return variable, [variable]
|
||||
@ -927,27 +928,28 @@ class ConstraintAnnotator:
|
||||
inverse = condition.name.endswith('_if_not_in')
|
||||
actions = self._get_condition_actions(condition.name)
|
||||
for param in condition.param:
|
||||
if hasattr(param, 'text'):
|
||||
param = param.text
|
||||
else:
|
||||
param = None
|
||||
text = getattr(param, 'text', None)
|
||||
for target in condition.target:
|
||||
leader_or_variable, variables = self._get_family_variables_from_target(target)
|
||||
# if option is already disable, do not apply disable_if_in
|
||||
if hasattr(leader_or_variable, actions[0]) and getattr(leader_or_variable, actions[0]) is True:
|
||||
# check only the first action (example of multiple actions: 'hidden', 'frozen', 'force_default_on_freeze')
|
||||
main_action = actions[0]
|
||||
if getattr(leader_or_variable, main_action, False) is True:
|
||||
continue
|
||||
for idx, action in enumerate(actions):
|
||||
prop = self.objectspace.property_(leader_or_variable.xmlfiles)
|
||||
prop.type = 'calculation'
|
||||
prop.inverse = inverse
|
||||
prop.source = condition.source
|
||||
prop.expected = param
|
||||
prop.expected = text
|
||||
prop.name = action
|
||||
if idx == 0:
|
||||
# main action is for the variable or family
|
||||
if not hasattr(leader_or_variable, 'property'):
|
||||
leader_or_variable.property = []
|
||||
leader_or_variable.property.append(prop)
|
||||
else:
|
||||
# other actions are set to the variable or children of family
|
||||
for variable in variables:
|
||||
if not hasattr(variable, 'property'):
|
||||
variable.property = []
|
||||
|
@ -441,16 +441,12 @@ class CreoleObjSpace:
|
||||
self.space.constraints.check.pop(idx) # pylint: disable=E1101
|
||||
|
||||
def remove_condition(self, name): # pylint: disable=C0111
|
||||
remove_conditions = []
|
||||
for idx, condition in enumerate(self.space.constraints.condition): # pylint: disable=E1101
|
||||
remove_targets = []
|
||||
if hasattr(condition, 'target'):
|
||||
for target_idx, target in enumerate(condition.target):
|
||||
if target.name == name:
|
||||
remove_targets.append(target_idx)
|
||||
remove_targets = list(set(remove_targets))
|
||||
remove_targets.sort(reverse=True)
|
||||
for idx in remove_targets:
|
||||
del condition.target[idx]
|
||||
if condition.source == name:
|
||||
remove_conditions.append(idx)
|
||||
for idx in remove_conditions:
|
||||
del self.space.constraints.condition[idx]
|
||||
|
||||
def add_to_tree_structure(self,
|
||||
variableobj,
|
||||
|
Reference in New Issue
Block a user