Skip to content

Commit

Permalink
Making boolify() more universal.
Browse files Browse the repository at this point in the history
  • Loading branch information
fwkz committed Apr 20, 2016
1 parent 5895ed7 commit c563698
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions routersploit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit c563698

Please sign in to comment.