MCPcopy Index your code
hub / github.com/google/adk-python / is_env_enabled

Function is_env_enabled

src/google/adk/utils/env_utils.py:27–60  ·  view source on GitHub ↗

Check if an environment variable is enabled. An environment variable is considered enabled if its value (case-insensitive) is 'true' or '1'. Args: env_var_name: The name of the environment variable to check. default: The default value to use if the environment variable is not set.

(env_var_name: str, default: str = '0')

Source from the content-addressed store, hash-verified

25
26
27def is_env_enabled(env_var_name: str, default: str = '0') -> bool:
28 """Check if an environment variable is enabled.
29
30 An environment variable is considered enabled if its value (case-insensitive)
31 is 'true' or '1'.
32
33 Args:
34 env_var_name: The name of the environment variable to check.
35 default: The default value to use if the environment variable is not set.
36 Defaults to '0'.
37
38 Returns:
39 True if the environment variable is enabled, False otherwise.
40
41 Examples:
42 >>> os.environ['MY_FLAG'] = 'true'
43 >>> is_env_enabled('MY_FLAG')
44 True
45
46 >>> os.environ['MY_FLAG'] = '1'
47 >>> is_env_enabled('MY_FLAG')
48 True
49
50 >>> os.environ['MY_FLAG'] = 'false'
51 >>> is_env_enabled('MY_FLAG')
52 False
53
54 >>> is_env_enabled('NONEXISTENT_FLAG')
55 False
56
57 >>> is_env_enabled('NONEXISTENT_FLAG', default='1')
58 True
59 """
60 return os.environ.get(env_var_name, default).lower() in ['true', '1']
61
62
63def is_enterprise_mode_enabled() -> bool:

Callers 8

test_is_env_enabledFunction · 0.90
is_feature_enabledFunction · 0.85
_setup_runner_contextFunction · 0.85
load_dotenv_for_agentFunction · 0.85

Calls 1

getMethod · 0.45

Tested by 2

test_is_env_enabledFunction · 0.72