From 4b6bdfaa85e1a38336d8271f194dba26428fbe2a Mon Sep 17 00:00:00 2001 From: cuiweizhi <560397@gree.com.cn> Date: Sat, 4 Nov 2023 14:39:09 +0800 Subject: [PATCH] Update project --- application/libs/config/local.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/application/libs/config/local.py b/application/libs/config/local.py index c2c81a5..a26d506 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 -- GitLab