MCPcopy
hub / github.com/msoedov/agentic_security / load_config

Method load_config

agentic_security/config.py:47–67  ·  view source on GitHub ↗

Load configuration from a TOML file and store it in the class variable. Args: config_path (str): Path to the TOML configuration file. Raises: FileNotFoundError: If the configuration file is not found. toml.TomlDecodeError: If the configu

(cls, config_path: str)

Source from the content-addressed store, hash-verified

45
46 @classmethod
47 def load_config(cls, config_path: str):
48 """
49 Load configuration from a TOML file and store it in the class variable.
50
51 Args:
52 config_path (str): Path to the TOML configuration file.
53
54 Raises:
55 FileNotFoundError: If the configuration file is not found.
56 toml.TomlDecodeError: If the configuration file has syntax errors.
57 """
58 try:
59 with open(config_path, "rb") as config_file:
60 cls.config = tomli.load(config_file)
61 logger.info(f"Configuration loaded successfully from {config_path}.")
62 except FileNotFoundError:
63 logger.error(f"Configuration file {config_path} not found.")
64 raise
65 except Exception as e:
66 logger.error(f"Error parsing TOML configuration: {e}")
67 raise
68
69 @classmethod
70 def get_config_value(cls, key: str, default=None):

Callers 3

get_or_create_configMethod · 0.95
entrypointMethod · 0.80

Calls 2

loadMethod · 0.80
errorMethod · 0.80

Tested by 1