mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-17 16:47:19 +02:00
[core] Bypass validation on values for ChoiceParams
This commit is contained in:
parent
c27281c9c1
commit
eda320374b
2 changed files with 4 additions and 6 deletions
|
@ -410,7 +410,7 @@ class ChoiceParam(Attribute):
|
||||||
|
|
||||||
def conformValue(self, val):
|
def conformValue(self, val):
|
||||||
""" Conform 'val' to the correct type and check for its validity """
|
""" Conform 'val' to the correct type and check for its validity """
|
||||||
return self.desc._valueType(val)
|
return self.desc.conformValue(val)
|
||||||
|
|
||||||
def validateValue(self, value):
|
def validateValue(self, value):
|
||||||
if self.desc.exclusive:
|
if self.desc.exclusive:
|
||||||
|
|
|
@ -314,9 +314,9 @@ class ChoiceParam(Param):
|
||||||
semantic=semantic, enabled=enabled, validValue=validValue, errorMessage=errorMessage)
|
semantic=semantic, enabled=enabled, validValue=validValue, errorMessage=errorMessage)
|
||||||
|
|
||||||
def conformValue(self, value):
|
def conformValue(self, value):
|
||||||
""" Conform 'val' to the correct type and check for its validity """
|
""" Conform 'value' to the correct type and check for its validity """
|
||||||
if not isinstance(value, self._valueType):
|
# Bypassing the validation allows to have values that are not initially in the list of choices
|
||||||
raise ValueError('ChoiceParam value should be a {} (param:{}, value:{}, type:{})'.format(self._valueType, self.name, value, type(value)))
|
# We cannot return _valueType(value) because some casts are not possible (e.g. str -> int)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def validateValue(self, value):
|
def validateValue(self, value):
|
||||||
|
@ -326,8 +326,6 @@ class ChoiceParam(Param):
|
||||||
if isinstance(value, str):
|
if isinstance(value, str):
|
||||||
value = value.split(',')
|
value = value.split(',')
|
||||||
|
|
||||||
if not isinstance(value, Iterable):
|
|
||||||
raise ValueError('Non exclusive ChoiceParam value should be iterable (param:{}, value:{}, type:{})'.format(self.name, value, type(value)))
|
|
||||||
return [self.conformValue(v) for v in value]
|
return [self.conformValue(v) for v in value]
|
||||||
|
|
||||||
def checkValueTypes(self):
|
def checkValueTypes(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue