From 84a67b20d09370d5a24beb32a9f217842bf57f4f Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sat, 30 Jan 2021 16:05:55 +0100 Subject: [PATCH] invalid number valid enum in condition --- src/rougail/annotator/condition.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/rougail/annotator/condition.py b/src/rougail/annotator/condition.py index b24955af3..1bc76427a 100644 --- a/src/rougail/annotator/condition.py +++ b/src/rougail/annotator/condition.py @@ -291,18 +291,24 @@ class ConditionAnnotator: msg = _(f'the source "{condition.source}" in condition cannot be a dynamic ' f'variable in {xmlfiles}') 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): - """remove condition for ChoiceOption that don't have param + """remove condition of ChoiceOption that doesn't match """ remove_conditions = [] for condition_idx, condition in enumerate(self.objectspace.space.constraints.condition): - # FIXME only string? - if condition.source.path in self.objectspace.valid_enums and \ - self.objectspace.valid_enums[condition.source.path]['type'] == 'string': + if condition.source.path in self.objectspace.valid_enums: valid_enum = self.objectspace.valid_enums[condition.source.path]['values'] 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) for idx in remove_param: del condition.param[idx]