Commit c5636986 by fwkz

Making boolify() more universal.

parent 5895ed71
......@@ -293,7 +293,17 @@ def http_request(method, url, **kwargs):
def boolify(value):
if isinstance(value, bool):
return value
elif isinstance(value, basestring):
return bool(strtobool(value))
""" Function that will translate common strings into bool values
True -> "True", "t", "yes", "y", "on", "1"
False -> any other string
Objects other than string will be transformed using built-in bool() function.
"""
if isinstance(value, basestring):
try:
return bool(strtobool(value))
except ValueError:
return False
else:
return bool(value)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment