mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
moved env_value_to_bool to env_tools
This commit is contained in:
parent
fc2f4f929d
commit
24a8fad513
3 changed files with 20 additions and 16 deletions
|
|
@ -6,6 +6,7 @@ from .deprecated import (
|
|||
set_io_database
|
||||
)
|
||||
|
||||
from .env_tools import env_value_to_bool
|
||||
from .avalon_context import (
|
||||
is_latest,
|
||||
any_outdated,
|
||||
|
|
@ -44,6 +45,8 @@ __all__ = [
|
|||
"get_avalon_database",
|
||||
"set_io_database",
|
||||
|
||||
"env_value_to_bool",
|
||||
|
||||
"is_latest",
|
||||
"any_outdated",
|
||||
"get_asset",
|
||||
|
|
|
|||
|
|
@ -39,22 +39,6 @@ class ApplicationLaunchFailed(Exception):
|
|||
pass
|
||||
|
||||
|
||||
def env_value_to_bool(env_key=None, value=None, default=False):
|
||||
if value is None and env_key is None:
|
||||
return default
|
||||
|
||||
if value is None:
|
||||
value = os.environ.get(env_key)
|
||||
|
||||
if value is not None:
|
||||
value = str(value).lower()
|
||||
if value in ("true", "yes", "1"):
|
||||
return True
|
||||
elif value in ("false", "no", "0"):
|
||||
return False
|
||||
return default
|
||||
|
||||
|
||||
def compile_list_of_regexes(in_list):
|
||||
"""Convert strings in entered list to compiled regex objects."""
|
||||
regexes = list()
|
||||
|
|
|
|||
17
pype/lib/env_tools.py
Normal file
17
pype/lib/env_tools.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import os
|
||||
|
||||
|
||||
def env_value_to_bool(env_key=None, value=None, default=False):
|
||||
if value is None and env_key is None:
|
||||
return default
|
||||
|
||||
if value is None:
|
||||
value = os.environ.get(env_key)
|
||||
|
||||
if value is not None:
|
||||
value = str(value).lower()
|
||||
if value in ("true", "yes", "1"):
|
||||
return True
|
||||
elif value in ("false", "no", "0"):
|
||||
return False
|
||||
return default
|
||||
Loading…
Add table
Add a link
Reference in a new issue