diff options
| author | yo mama <pepper@scannerjammer.com> | 2015-09-23 23:27:27 -0700 |
|---|---|---|
| committer | yo mama <pepper@scannerjammer.com> | 2015-09-23 23:27:27 -0700 |
| commit | 5c982ed500b51f5b8d911e5a5adec10ac2d31d2e (patch) | |
| tree | efca7a0f0209d25972df00173e4c92a814956a7a /lib/Param/Bool.py | |
| parent | 2755b029d873f93d91086b3d69a4c57d05c40fb5 (diff) | |
ok good
Diffstat (limited to 'lib/Param/Bool.py')
| -rw-r--r-- | lib/Param/Bool.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/Param/Bool.py b/lib/Param/Bool.py new file mode 100644 index 0000000..7b779cb --- /dev/null +++ b/lib/Param/Bool.py @@ -0,0 +1,19 @@ +from Param import Param +import re +import sys +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 or type(b) == unicode: + 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)) |
