remove_choice only avalable for choice

This commit is contained in:
Emmanuel Garette 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(): for attr, val in child.attrib.items():
if redefine and attr in UNREDEFINABLE: if redefine and attr in UNREDEFINABLE:
msg = _(f'cannot redefine attribute "{attr}" for variable "{child.attrib["name"]}"' 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]) raise DictConsistencyError(msg, 48, variableobj.xmlfiles[:-1])
if attr in self.booleans_attributs: if attr in self.booleans_attributs:
val = convert_boolean(val) val = convert_boolean(val)
@ -411,6 +411,10 @@ class RougailObjSpace:
""" """
if child.tag == 'variable': if child.tag == 'variable':
if child.attrib.get('remove_choice', False): 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 = [] variableobj.choice = []
if child.attrib.get('remove_check', False): if child.attrib.get('remove_check', False):
self.remove_check(variableobj.name) self.remove_check(variableobj.name)

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<variables>
<variable name="enumvar" type="string"/>
</variables>
<constraints/>
</rougail>

View File

@ -0,0 +1,8 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<variables>
<variable name="enumvar" redefine="True" remove_choice="True"/>
</variables>
<constraints/>
</rougail>