No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bool.py 634B

12345678910111213141516171819202122
  1. # -*- coding: utf-8 -*-
  2. from ..data_field import DataField
  3. class DataHandler(DataField):
  4. help = 'A basic boolean field'
  5. base_type = 'bool'
  6. ## @brief A boolean field
  7. def __init__(self, **kwargs):
  8. if 'check_data_value' not in kwargs:
  9. kwargs['check_data_value'] = self.check_value
  10. super().__init__(ftype='bool', **kwargs)
  11. def _check_data_value(self, value):
  12. error = None
  13. try:
  14. value = bool(value)
  15. except(ValueError, TypeError):
  16. error = TypeError("The value '%s' is not, and will never, be a boolean" % value)
  17. return value, error