Skip to content

Loader

load_template(path)

Loads a template from a file located at the specified path.

Parameters:

Name Type Description Default
path str

The path to the YAML template configuration file.

required

Returns:

Type Description
InternalTemplate

Loaded template.

Raises:

Type Description
OEError

In case there has been an error validating the correctness of the template.

Source code in src/officialeye/_internal/template/schema/loader.py
def load_template(path: str, /) -> InternalTemplate:
    """
    Loads a template from a file located at the specified path.

    Arguments:
        path: The path to the YAML template configuration file.

    Returns:
        Loaded template.

    Raises:
        OEError: In case there has been an error validating the correctness of the template.
    """

    template = get_internal_context().get_template_by_path(path)

    if template is not None:
        get_internal_afi().info(Verbosity.DEBUG, f"Template at path '{path}' has already been loaded and cached, reusing it!")
        return template

    get_internal_afi().info(Verbosity.DEBUG, f"Template at path '{path}' has not yet been loaded, loading it.")

    return _do_load_template(path)