vamo_telbot.config.manager ========================== .. py:module:: vamo_telbot.config.manager .. autoapi-nested-parse:: Centralized application configuration manager. Functions --------- .. autoapisummary:: vamo_telbot.config.manager.load_config vamo_telbot.config.manager.save_config vamo_telbot.config.manager.set_config_value vamo_telbot.config.manager.get_config_value Module Contents --------------- .. py:function:: load_config() Load application configuration from disk. Reads the application configuration file defined by ``SECRETS_FILE_PATH`` and returns its contents as a dictionary. If the configuration file does not exist, cannot be read, contains invalid JSON, or does not represent a JSON object, an empty dictionary is returned. This function is intentionally defensive and guarantees that the return value is always a dictionary, making it safe to use as a mutable configuration store by callers. :returns: A dictionary containing configuration key-value pairs loaded from disk, or an empty dictionary if the configuration file is missing, invalid, or unreadable. :rtype: dict[str, Any] .. py:function:: save_config(config) Persist application configuration to disk. Serializes the provided configuration dictionary as JSON and writes it to the configuration file defined by ``SECRETS_FILE_PATH``. The file is written using UTF-8 encoding and pretty-printed formatting to remain human-readable. This function overwrites the existing configuration file content. Callers are expected to load the current configuration, modify only the required keys, and then save the updated dictionary. :param config: A dictionary containing application configuration key-value pairs to persist. .. py:function:: set_config_value(key, value) Set a single configuration value and persist it to disk. Loads the existing application configuration, adds or updates the specified key with the provided value, and writes the updated configuration back to the configuration file. This function preserves all other existing configuration entries by performing a read-modify-write cycle. :param key: Configuration key to add or update. :param value: Value to associate with the given key. The value must be JSON-serializable. .. py:function:: get_config_value(key, default = None) Retrieve a configuration value by key. Loads the application configuration from disk and returns the value associated with the specified key. If the key does not exist or the configuration file is missing or invalid, the provided default value is returned. :param key: Configuration key to retrieve. :param default: Value to return if the key is not present in the configuration. Defaults to ``None``. :returns: The value associated with the given key if it exists; otherwise, the provided default value.