Skip to content

Config

injector.load_config.config.LoadConfig

The class includes all necessary methods to load the configuration from the config file

Source code in injector/load_config/config.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class LoadConfig:
    """The class includes all necessary methods to load the configuration from the config file"""

    @staticmethod
    def load_correct_config_dict() -> dict:
        """The method includes a functionality to translate the configuration from a Yaml file and returns the configuration as a dictionary

        Raises:
            KeyError: Missed specifying a necessary configuration environment variable

        Returns:
            data (Dict): Returns the configuration as dictionary
        """

        if os.environ.get("HANA_INJECTOR_CONFIG_FILE_PATH") is None:
            raise KeyError("Please, set the HANA_INJECTOR_CONFIG_FILE_PATH env variable.")

        path = Path(f"{os.environ.get('HANA_INJECTOR_CONFIG_FILE_PATH')}")
        with path.open("r", encoding="utf-8") as config_file:
            data: dict = yaml.safe_load(config_file)

        return data

Functions

load_correct_config_dict() staticmethod

The method includes a functionality to translate the configuration from a Yaml file and returns the configuration as a dictionary

Raises:

Type Description
KeyError

Missed specifying a necessary configuration environment variable

Returns:

Name Type Description
data Dict

Returns the configuration as dictionary

Source code in injector/load_config/config.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
@staticmethod
def load_correct_config_dict() -> dict:
    """The method includes a functionality to translate the configuration from a Yaml file and returns the configuration as a dictionary

    Raises:
        KeyError: Missed specifying a necessary configuration environment variable

    Returns:
        data (Dict): Returns the configuration as dictionary
    """

    if os.environ.get("HANA_INJECTOR_CONFIG_FILE_PATH") is None:
        raise KeyError("Please, set the HANA_INJECTOR_CONFIG_FILE_PATH env variable.")

    path = Path(f"{os.environ.get('HANA_INJECTOR_CONFIG_FILE_PATH')}")
    with path.open("r", encoding="utf-8") as config_file:
        data: dict = yaml.safe_load(config_file)

    return data