From c5d3d9fe9bafdf85434a87437b90d606cd81fcb5 Mon Sep 17 00:00:00 2001 From: Redume Date: Sun, 15 Dec 2024 10:47:20 +0300 Subject: [PATCH] refactor(chart): The function with data retrieval from the config has been moved to a separate file and function --- chart/utils/load_config.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 chart/utils/load_config.py diff --git a/chart/utils/load_config.py b/chart/utils/load_config.py new file mode 100644 index 0000000..0cca814 --- /dev/null +++ b/chart/utils/load_config.py @@ -0,0 +1,21 @@ +""" +This module provides a function for loading a YAML configuration file. +The function reads the file content and returns it as a Python dictionary. +""" +import yaml + +def load_config(file_path: str) -> dict: + """ + Loads a YAML configuration file and returns its contents as a dictionary. + + This function opens the specified YAML file, parses its content, and + returns it in dictionary format, making it accessible for use in + the application. + + :param file_path: The path to the YAML configuration file to be loaded. + :return: A dictionary containing the parsed content of the YAML file. + """ + with open(file_path, 'r', encoding='utf-8') as file: + return yaml.safe_load(file) + +config = load_config('config.yaml')