From d3e99cc9a5252ef1fa675ac797da53619f35fb97 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Tue, 19 Nov 2019 18:52:20 +0100 Subject: [PATCH] notunique and notempty support --- tiramisu/option/baseoption.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tiramisu/option/baseoption.py b/tiramisu/option/baseoption.py index 23e9776..33c68bb 100644 --- a/tiramisu/option/baseoption.py +++ b/tiramisu/option/baseoption.py @@ -70,10 +70,17 @@ class Base: properties = frozenset() elif isinstance(properties, tuple): properties = frozenset(properties) - if is_multi and 'empty' not in properties: - # if option is a multi, it cannot be "empty" (None not allowed in the list) - # "empty" is removed for follower's option - properties = properties | {'empty'} + if is_multi: + # if option is a multi, it cannot be 'empty' (None not allowed in the list) and cannot have multiple time the same value + # 'empty' and 'unique' are removed for follower's option + if 'notunique' in properties: + properties = properties - {'notunique'} + else: + properties = properties | {'unique'} + if 'notempty' in properties: + properties = properties - {'notempty'} + else: + properties = properties | {'empty'} assert isinstance(properties, frozenset), _('invalid properties type {0} for {1},' ' must be a frozenset').format(type(properties), name)