mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-06 10:18:42 +02:00
[core] Values of ChoiceParam should be a list, Error message added for initialisation
This commit is contained in:
parent
8034d98914
commit
ad94effb98
1 changed files with 16 additions and 4 deletions
|
@ -354,12 +354,10 @@ class ChoiceParam(Param):
|
||||||
self._joinChar = joinChar
|
self._joinChar = joinChar
|
||||||
if self._values:
|
if self._values:
|
||||||
# Look at the type of the first element of the possible values
|
# Look at the type of the first element of the possible values
|
||||||
assert isinstance(self._values, list)
|
|
||||||
self._valueType = type(self._values[0])
|
self._valueType = type(self._values[0])
|
||||||
elif not exclusive:
|
elif not exclusive:
|
||||||
# Possible values may be defined later, so use the value to define the type.
|
# Possible values may be defined later, so use the value to define the type.
|
||||||
# if non exclusive, it is a list
|
# if non exclusive, it is a list
|
||||||
assert isinstance(self._value, list)
|
|
||||||
self._valueType = type(self._value[0])
|
self._valueType = type(self._value[0])
|
||||||
else:
|
else:
|
||||||
self._valueType = type(self._value)
|
self._valueType = type(self._value)
|
||||||
|
@ -380,12 +378,26 @@ class ChoiceParam(Param):
|
||||||
value = value.split(',')
|
value = value.split(',')
|
||||||
|
|
||||||
if not isinstance(value, Iterable):
|
if not isinstance(value, Iterable):
|
||||||
raise ValueError('Non exclusive ChoiceParam value should be iterable (param:{}, value:{}, type:{}).'.format(self.name, value, type(value)))
|
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):
|
||||||
# nothing to validate
|
# Check that the values have been provided as a list
|
||||||
|
if not isinstance(self._values, list):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
# If the choices are not exclusive, check that 'value' is a list, and check that it does not contain values that
|
||||||
|
# are not available
|
||||||
|
elif not self.exclusive and (not isinstance(self._value, list) or
|
||||||
|
not all(val in self._values for val in self._value)):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
# If the choices are exclusive, the value should NOT be a list but it can contain any value that is not in the
|
||||||
|
# list of possible ones
|
||||||
|
elif self.exclusive and isinstance(self._value, list):
|
||||||
|
return self.name
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
values = Property(VariantList, lambda self: self._values, constant=True)
|
values = Property(VariantList, lambda self: self._values, constant=True)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue