diff --git a/application/libs/config/local.py b/application/libs/config/local.py index c2c81a5f01766c7d4260ec500441879e3398cfa8..a26d506677b6ecda2481a548d7f7dbe16508c594 100644 --- a/application/libs/config/local.py +++ b/application/libs/config/local.py @@ -18,12 +18,27 @@ import yaml class LocalConfig: def __init__(self, config_dir: str): + """ + Initialize a LocalConfig instance. + + :param config_dir: The directory where the config files are located. + """ self.config_dir = config_dir def load(self, filename: str) -> Any: + """ + Load a config file and return its content. + + :param filename: The name of the config file to load. + :return: The content of the config file. + :raises FileNotFoundError: If the file does not exist. + """ + # Construct the full path of the config file filepath = os.path.join(self.config_dir, filename) + # Check if the file exists if not os.path.exists(filepath): raise FileNotFoundError(f'No such file or directory: {filepath}') + # Open the file and load its content with open(filepath, 'r') as file: cfg = yaml.safe_load(file) return cfg