blob: 7b779cbb86f96f4972c4c85f3f42ee2d9821a896 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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))
|