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 ..i18n import _
|
||||||
from ..setting import undefined, OptionBag, Undefined
|
from ..setting import undefined, OptionBag, Undefined
|
||||||
from ..autolib import Calculation, Params, ParamOption, ParamInformation, ParamSelfInformation
|
from ..autolib import Calculation, Params, ParamOption, ParamInformation, ParamSelfInformation
|
||||||
from ..error import (ConfigError, ValueWarning, ValueErrorWarning, PropertiesOptionError,
|
from ..error import (ConfigError, ValueWarning, ValueErrorWarning,
|
||||||
ValueOptionError, display_list)
|
ValueOptionError, display_list)
|
||||||
from .syndynoption import SynDynOption
|
from .syndynoption import SynDynOption
|
||||||
#ALLOWED_CONST_LIST = ['_cons_not_equal']
|
#ALLOWED_CONST_LIST = ['_cons_not_equal']
|
||||||
|
@ -347,14 +347,17 @@ class Option(BaseOption):
|
||||||
|
|
||||||
def _is_not_unique(value, option_bag):
|
def _is_not_unique(value, option_bag):
|
||||||
# if set(value) has not same length than value
|
# if set(value) has not same length than value
|
||||||
if config_bag is not undefined and check_error and \
|
if config_bag is undefined or not check_error or \
|
||||||
'unique' in option_bag.properties:
|
'unique' not in option_bag.properties:
|
||||||
lvalue = [val for val in value if val is not None]
|
return
|
||||||
if len(set(lvalue)) != len(lvalue):
|
lvalue = [val for val in value if val is not None]
|
||||||
for idx, val in enumerate(value):
|
if len(set(lvalue)) == len(lvalue):
|
||||||
if val in value[idx+1:]:
|
return
|
||||||
raise ValueError(_('the value "{}" is not unique'
|
for idx, val in enumerate(value):
|
||||||
'').format(val))
|
if val not in value[idx+1:]:
|
||||||
|
continue
|
||||||
|
raise ValueError(_('the value "{}" is not unique'
|
||||||
|
'').format(val))
|
||||||
|
|
||||||
async def calculation_validator(val,
|
async def calculation_validator(val,
|
||||||
_index):
|
_index):
|
||||||
|
|
Loading…
Reference in a new issue