Add bumblebee.util.asbool function
Harmonize the boolean parameter value. Now `t`, `true`, `y`, `yes`, `on`, `1` are considered truthy and everything else falsy.
This commit is contained in:
parent
cc6da2b70e
commit
b0268a412b
6 changed files with 26 additions and 13 deletions
|
@ -10,6 +10,15 @@ except ImportError:
|
|||
# Python3 doesn't require this anymore
|
||||
pass
|
||||
|
||||
|
||||
def asbool(val):
|
||||
if val is None:
|
||||
return False
|
||||
if isinstance(val, bool):
|
||||
return val
|
||||
val = str(val).strip().lower()
|
||||
return val in ("t", "true", "y", "yes", "on", "1")
|
||||
|
||||
def execute(cmd, wait=True):
|
||||
logging.info("executing command '{}'".format(cmd))
|
||||
args = shlex.split(cmd)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue