pyopmnearwell.utils.mako module#

Render Mako templates used by pyopmnearwell.

fill_template(var, filename=None, text=None)[source]#

Fill a Mako template with the given variables.

The template is loaded from filename or supplied directly through text. If rendering fails, the formatted Mako traceback is reported through the pyopmnearwell command-line error helper so the template can be debugged.

Parameters:
  • var (dict) -- Variables exposed to the Mako template during rendering.

  • filename (str | pathlib.Path | None, optional) -- Path to the template file. This may be omitted when text is supplied.

  • text (str | None, optional) -- Template source supplied directly as a string. This may be omitted when filename is supplied.

Returns:

Rendered template text.

Return type:

str

Raises:

SystemExit -- If the template cannot be rendered.