invalid number valid enum in condition

This commit is contained in:
Emmanuel Garette 2021-01-30 16:05:55 +01:00
parent c90324187b
commit 84a67b20d0
1 changed files with 11 additions and 5 deletions

View File

@ -291,18 +291,24 @@ class ConditionAnnotator:
msg = _(f'the source "{condition.source}" in condition cannot be a dynamic ' msg = _(f'the source "{condition.source}" in condition cannot be a dynamic '
f'variable in {xmlfiles}') f'variable in {xmlfiles}')
raise DictConsistencyError(msg, 20) from err raise DictConsistencyError(msg, 20) from err
if err.errno == 42:
xmlfiles = self.objectspace.display_xmlfiles(condition.xmlfiles)
msg = _(f'the source "{condition.source}" in condition is an unknown variable '
f'in {xmlfiles}')
raise DictConsistencyError(msg, 23) from err
raise err from err # pragma: no cover
def check_choice_option_condition(self): def check_choice_option_condition(self):
"""remove condition for ChoiceOption that don't have param """remove condition of ChoiceOption that doesn't match
""" """
remove_conditions = [] remove_conditions = []
for condition_idx, condition in enumerate(self.objectspace.space.constraints.condition): for condition_idx, condition in enumerate(self.objectspace.space.constraints.condition):
# FIXME only string? if condition.source.path in self.objectspace.valid_enums:
if condition.source.path in self.objectspace.valid_enums and \
self.objectspace.valid_enums[condition.source.path]['type'] == 'string':
valid_enum = self.objectspace.valid_enums[condition.source.path]['values'] valid_enum = self.objectspace.valid_enums[condition.source.path]['values']
remove_param = [param_idx for param_idx, param in enumerate(condition.param) \ remove_param = [param_idx for param_idx, param in enumerate(condition.param) \
if param.text not in valid_enum] if param.type != 'variable' and param.text not in valid_enum]
if not remove_param:
continue
remove_param.sort(reverse=True) remove_param.sort(reverse=True)
for idx in remove_param: for idx in remove_param:
del condition.param[idx] del condition.param[idx]