MCPcopy
hub / github.com/chriskiehl/Gooey / getValue

Method getValue

gooey/gui/components/widgets/bases.py:167–187  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

165
166
167 def getValue(self):
168 regexFunc = lambda x: bool(re.match(userValidator, x))
169
170 userValidator = getin(self._options, ['validator', 'test'], 'True')
171 message = getin(self._options, ['validator', 'message'], '')
172 testFunc = regexFunc \
173 if getin(self._options, ['validator', 'type'], None) == 'RegexValidator'\
174 else eval('lambda user_input: bool(%s)' % userValidator)
175 satisfies = testFunc if self._meta['required'] else ifPresent(testFunc)
176 value = self.getWidgetValue()
177
178 return {
179 'id': self._id,
180 'cmd': self.formatOutput(self._meta, value),
181 'rawValue': value,
182 'test': runValidator(satisfies, value),
183 'error': None if runValidator(satisfies, value) else message,
184 'clitype': 'positional'
185 if self._meta['required'] and not self._meta['commands']
186 else 'optional'
187 }
188
189 def setValue(self, value):
190 self.widget.SetValue(value)

Callers 15

testInitialValueMethod · 0.45
testInitialValueMethod · 0.45
testInitialValueMethod · 0.45
testInitialValueMethod · 0.45
testDefaultMethod · 0.45
testZerosAreReturnedMethod · 0.45
testNoLossOfPrecisionMethod · 0.45
testSliderDefaultMethod · 0.45
testZerosAreReturnedMethod · 0.45
testInitialValueMethod · 0.45
getPositionalArgsMethod · 0.45

Calls 5

getWidgetValueMethod · 0.95
formatOutputMethod · 0.95
getinFunction · 0.90
ifPresentFunction · 0.90
runValidatorFunction · 0.90

Tested by 11

testInitialValueMethod · 0.36
testInitialValueMethod · 0.36
testInitialValueMethod · 0.36
testInitialValueMethod · 0.36
testDefaultMethod · 0.36
testZerosAreReturnedMethod · 0.36
testNoLossOfPrecisionMethod · 0.36
testSliderDefaultMethod · 0.36
testZerosAreReturnedMethod · 0.36
testInitialValueMethod · 0.36