flip_api.scripts.env_utils
Shared utilities for reading and updating environment files.
Functions
|
Extract a value from a JSON dict string. |
|
Read the value of a variable from env file lines. |
|
Update an existing env var line or append it. |
Module Contents
- flip_api.scripts.env_utils.get_json_value(json_str: str, key: str) str[source]
Extract a value from a JSON dict string.
- Parameters:
json_str (str) – A JSON-encoded dict (e.g. ‘{“Trust_1”: “key1”}’).
key (str) – The key to look up.
- Returns:
The value for key, or an empty string if the key is missing or json_str is empty.
- Return type:
str
- flip_api.scripts.env_utils.read_env_value(lines: list[str], var_name: str) str | None[source]
Read the value of a variable from env file lines.
- Parameters:
lines (list[str]) – Lines of the environment file.
var_name (str) – Variable name to look up.
- Returns:
The value if found, else None.
- Return type:
str | None
- flip_api.scripts.env_utils.update_or_append(lines: list[str], var_name: str, value: str) list[str][source]
Update an existing env var line or append it.
- Parameters:
lines (list[str]) – Lines of the environment file.
var_name (str) – Variable name to set.
value (str) – New value for the variable.
- Returns:
Updated lines.
- Return type:
list[str]