From 94bbc81449b665a0cf4345c460242ae251bf90e2 Mon Sep 17 00:00:00 2001 From: Sam Chau Date: Fri, 17 Jan 2025 20:49:14 +1030 Subject: [PATCH] feat: normalize file path brackets in load_yaml_file function --- backend/app/data/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/app/data/utils.py b/backend/app/data/utils.py index 27233e4..dfa0bec 100644 --- a/backend/app/data/utils.py +++ b/backend/app/data/utils.py @@ -92,6 +92,8 @@ def get_category_directory(category: str) -> str: def load_yaml_file(file_path: str) -> Dict[str, Any]: + file_path = file_path.replace('[', '(').replace(']', ')') + if not os.path.exists(file_path): logger.error(f"File not found: {file_path}") raise FileNotFoundError(f"File not found: {file_path}") @@ -100,9 +102,11 @@ def load_yaml_file(file_path: str) -> Dict[str, Any]: with open(file_path, 'r') as f: content = yaml.safe_load(f) return content + except yaml.YAMLError as e: logger.error(f"Error parsing YAML file {file_path}: {e}") raise + except Exception as e: logger.error(f"Unexpected error reading file {file_path}: {e}") raise