| 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) |