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)
| 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): |