Spaces:
Sleeping
Sleeping
Download src/hackathon/utils/util.py from Mistral-AI-Game-Jam/Team15: direct link, hf CLI and curl.
- Browser
- Download file 624 Bytes
-
https://huggingface.co/spaces/Mistral-AI-Game-Jam/Team15/resolve/main/src/hackathon/utils/util.py
- Command line
-
hf download hf://spaces/Mistral-AI-Game-Jam/Team15/src/hackathon/utils/util.py
-
curl -L -o util.py https://huggingface.co/spaces/Mistral-AI-Game-Jam/Team15/resolve/main/src/hackathon/utils/util.py
624 Bytes
| import yaml | |
| def read_yaml(file_path): | |
| """ | |
| Reads a YAML file and returns its contents as a Python object. | |
| Args: | |
| file_path (str): The path to the YAML file. | |
| Returns: | |
| dict or list: The parsed YAML structure (dictionary or list). | |
| """ | |
| try: | |
| with open(file_path, 'r') as file: | |
| data = yaml.safe_load(file) | |
| return data | |
| except FileNotFoundError: | |
| print(f"Error: File not found at {file_path}") | |
| except yaml.YAMLError as e: | |
| print(f"Error parsing YAML file: {e}") | |
| except Exception as e: | |
| print(f"An unexpected error occurred: {e}") | |