pyopmnearwell.utils.mako module

Helper script for Mako templates.

pyopmnearwell.utils.mako.fill_template(var: dict, filename: str | Path | None = None, text: str | None = None) str

Fill a Mako template with the given variables.

The template is either loaded from a file or passed as a string. If rendering the template raises an error, render the error s.t. it can be easily debugged.

Args:

var (dict): A dictionary containing the variables to be used in the template. filename (Optional[str | pathlib.Path], optional): The path to the template

file. Defaults to None.

text (Optional[str], optional): The text of the template. Defaults to None.

Returns:

str: The filled template as a string.

Raises:

Error: When the template cannot be filled.