Skip to content

Commit

Permalink
Factor out file read into its own method
Browse files Browse the repository at this point in the history
  • Loading branch information
augusto-herrmann committed Aug 22, 2024
1 parent 862eebd commit f19baf0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,17 @@ class YAMLParser:
def __init__(self, filepath: str):
self.filepath = filepath

def read(self) -> dict:
"""Reads the contents of the YAML file."""
with open(self.filepath, "r", encoding="utf-8") as file:
dag_config_dict = yaml.safe_load(file)
return dag_config_dict

def parse(self) -> DAGConfig:
"""Processes the config file in order to instantiate the DAG in
Airflow.
"""
with open(self.filepath, "r") as file:
dag_config_dict = yaml.safe_load(file)

dag_config_dict = self.read()
dag = self._try_get(dag_config_dict, "dag")
dag_id = self._try_get(dag, "id")
description = self._try_get(dag, "description")
Expand Down

0 comments on commit f19baf0

Please sign in to comment.