def getIndex(self, *args): value = self.getRealValue(*args) if self.isStringList(): return value elif self.isColorList(): return ColorUtil.keyToIndex(value) else: return self.findClosestIndex(value)
def ensureValidDropdownIndex(self, optionName, index): option = self.getOption(optionName) if option is None: return index, False if index < 0 or index >= len(option.getDisplayValues()): index = option.getDefault() if "COLOR" in str(index): index = ColorUtil.keyToIndex(index) if index < 0 or index >= len(option.getDisplayValues()): return index, False else: # Store the repaired index in the option object option.setIndex(index) return index, True