mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
env_variable_to_bool function is more specific and have ability of default value
This commit is contained in:
parent
d82b95e59b
commit
e0a08007ce
1 changed files with 7 additions and 3 deletions
|
|
@ -311,10 +311,14 @@ class OrderGroups:
|
|||
return float(group_range)
|
||||
|
||||
|
||||
def env_variable_to_bool(env_key):
|
||||
def env_variable_to_bool(env_key, default=False):
|
||||
"""Boolean based on environment variable value."""
|
||||
# TODO: move to pype lib
|
||||
value = os.environ.get(env_key)
|
||||
if value is not None:
|
||||
value = value.lower()
|
||||
if value in ("true", "1", "yes"):
|
||||
if value in ("true", "1", "yes", "on"):
|
||||
return True
|
||||
return False
|
||||
elif value in ("false", "0", "no", "off"):
|
||||
return False
|
||||
return default
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue