better is_not_unique support
This commit is contained in:
parent
22ef5c7c3b
commit
9731769694
1 changed files with 12 additions and 9 deletions
|
@ -28,7 +28,7 @@ from .baseoption import BaseOption, submulti, STATIC_TUPLE
|
|||
from ..i18n import _
|
||||
from ..setting import undefined, OptionBag, Undefined
|
||||
from ..autolib import Calculation, Params, ParamOption, ParamInformation, ParamSelfInformation
|
||||
from ..error import (ConfigError, ValueWarning, ValueErrorWarning, PropertiesOptionError,
|
||||
from ..error import (ConfigError, ValueWarning, ValueErrorWarning,
|
||||
ValueOptionError, display_list)
|
||||
from .syndynoption import SynDynOption
|
||||
#ALLOWED_CONST_LIST = ['_cons_not_equal']
|
||||
|
@ -347,12 +347,15 @@ class Option(BaseOption):
|
|||
|
||||
def _is_not_unique(value, option_bag):
|
||||
# if set(value) has not same length than value
|
||||
if config_bag is not undefined and check_error and \
|
||||
'unique' in option_bag.properties:
|
||||
if config_bag is undefined or not check_error or \
|
||||
'unique' not in option_bag.properties:
|
||||
return
|
||||
lvalue = [val for val in value if val is not None]
|
||||
if len(set(lvalue)) != len(lvalue):
|
||||
if len(set(lvalue)) == len(lvalue):
|
||||
return
|
||||
for idx, val in enumerate(value):
|
||||
if val in value[idx+1:]:
|
||||
if val not in value[idx+1:]:
|
||||
continue
|
||||
raise ValueError(_('the value "{}" is not unique'
|
||||
'').format(val))
|
||||
|
||||
|
|
Loading…
Reference in a new issue