Skip to content
Snippets Groups Projects
Commit fca29b2e authored by Attila Farkas's avatar Attila Farkas
Browse files

Add a simple yaml reader

parent 15d1d5fc
No related branches found
No related tags found
1 merge request!32Version 2.0.0
import yaml
from pathlib import Path
from typing import Union, List, Dict
class Reader:
"""Static methods for reading from files"""
@staticmethod
def open_yaml(file_path: Path) -> Union[List, Dict]:
"""Open a yaml file and return its content"""
try:
with file_path.open() as input_file:
return yaml.safe_load(input_file)
except yaml.YAMLError:
raise IOError(f"Could not parse yaml file {file_path}.")
except IOError:
raise IOError(f"Could not open yaml file {file_path}.")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment