remove_choice only avalable for choice

This commit is contained in:
2021-05-06 07:06:42 +02:00
parent 8d32ec9f01
commit 20f329d433
5 changed files with 20 additions and 1 deletions

View File

@ -393,7 +393,7 @@ class RougailObjSpace:
for attr, val in child.attrib.items():
if redefine and attr in UNREDEFINABLE:
msg = _(f'cannot redefine attribute "{attr}" for variable "{child.attrib["name"]}"'
f' in "{xmlfile}", already defined')
f' already defined')
raise DictConsistencyError(msg, 48, variableobj.xmlfiles[:-1])
if attr in self.booleans_attributs:
val = convert_boolean(val)
@ -411,6 +411,10 @@ class RougailObjSpace:
"""
if child.tag == 'variable':
if child.attrib.get('remove_choice', False):
if variableobj.type != 'choice':
msg = _(f'cannot remove choices for variable "{variableobj.path}"'
f' the variable has type "{variableobj.type}"')
raise DictConsistencyError(msg, 33, variableobj.xmlfiles)
variableobj.choice = []
if child.attrib.get('remove_check', False):
self.remove_check(variableobj.name)