flip_api.scripts.env_utils ========================== .. py:module:: flip_api.scripts.env_utils .. autoapi-nested-parse:: Shared utilities for reading and updating environment files. Functions --------- .. autoapisummary:: flip_api.scripts.env_utils.get_json_value flip_api.scripts.env_utils.read_env_value flip_api.scripts.env_utils.update_or_append Module Contents --------------- .. py:function:: get_json_value(json_str: str, key: str) -> str Extract a value from a JSON dict string. :param json_str: A JSON-encoded dict (e.g. '{"Trust_1": "key1"}'). :type json_str: str :param key: The key to look up. :type key: str :returns: The value for *key*, or an empty string if the key is missing or *json_str* is empty. :rtype: str .. py:function:: read_env_value(lines: list[str], var_name: str) -> str | None Read the value of a variable from env file lines. :param lines: Lines of the environment file. :type lines: list[str] :param var_name: Variable name to look up. :type var_name: str :returns: The value if found, else None. :rtype: str | None .. py:function:: update_or_append(lines: list[str], var_name: str, value: str) -> list[str] Update an existing env var line or append it. :param lines: Lines of the environment file. :type lines: list[str] :param var_name: Variable name to set. :type var_name: str :param value: New value for the variable. :type value: str :returns: Updated lines. :rtype: list[str]