mirror of
https://github.com/clearml/clearml-server
synced 2025-01-31 10:56:48 +00:00
15 lines
400 B
Python
15 lines
400 B
Python
|
from distutils.util import strtobool
|
||
|
from os import getenv
|
||
|
from typing import Optional
|
||
|
|
||
|
|
||
|
def get_env_bool(*keys: str, default: bool = None) -> Optional[bool]:
|
||
|
try:
|
||
|
value = next(env for env in (getenv(key) for key in keys) if env is not None)
|
||
|
except StopIteration:
|
||
|
return default
|
||
|
try:
|
||
|
return bool(strtobool(value))
|
||
|
except ValueError:
|
||
|
return bool(value)
|