diff options
| author | yo mama <pepper@scannerjammer.com> | 2015-09-21 14:20:13 -0700 |
|---|---|---|
| committer | yo mama <pepper@scannerjammer.com> | 2015-09-21 14:20:13 -0700 |
| commit | b29b0ec5f11dd66434cbdfba5287c4777d7f8ac9 (patch) | |
| tree | f02f45661bdab855d8392e14ba6448546586bf37 /lib/Param/Bool/__init__.py | |
| parent | 8f2230b7c866320e3839d6812b98b8370a7ec5d9 (diff) | |
new file structure
Diffstat (limited to 'lib/Param/Bool/__init__.py')
| -rw-r--r-- | lib/Param/Bool/__init__.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Param/Bool/__init__.py b/lib/Param/Bool/__init__.py new file mode 100644 index 0000000..8ccca00 --- /dev/null +++ b/lib/Param/Bool/__init__.py @@ -0,0 +1,18 @@ +from Param import Param +import re +class ParamBool(Param): + def __init__(self, value, classname=""): + super(ParamBool, self).__init__(classname=classname) + if value: + self.value = self._bool_correct(value) + else: + self.value = False + def _bool_correct(self, b): + if type(b) == str: + if re.match(r'true', b, re.IGNORECASE): + return True + elif re.match(r'false', b, re.IGNORECASE): + return False + elif type(b) == bool: + return b + self.err_warn("Not a bool: %s" % str(b)) |
