Commit 4b6bdfaa authored by 崔为之's avatar 崔为之 💪🏽

Update project

parent 53d881b0
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment