jinja2_interface#

confs.jinja2_interface.expand_template(tmpl_path, in_dict=None)[source]#

DESCRIPTION:

This function expands a Jinja-formatted template file by concatenating all %include directive file paths into a single virtual filepath (output_tmpl); if in_dict is not NoneType, any Jinja-formatted variabl within the available %include directives will be replaced prior to expansion.

Parameters:
tmpl_path: str

A Python string specifying the template file to be expanded.

Keywords:
in_dict: Dict, optional

A Python dictionary containing key and value pairs to be used to parse the respective Jinja-formatted template prior to expansion.

Returns:
output_tmpl: str

A Python string specifying the path to the virtual file path containing the expanded template.

Return type:

str

confs.jinja2_interface.write_from_template(tmpl_path, output_file, in_dict, fail_missing=False, rpl_tmpl_mrks=False, f90_bool=False, skip_missing=False, warn=True, concat_tmpl=False, **kwargs)[source]#

DESCRIPTION:

This function writes a Jinja2-formatted file established from a templated Jinja2-formatted file.

Parameters:
tmpl_path: str

A Python string defining the path to the Jinja2-formatted template file.

output_file: str

A Python string containing the full-path to the Jinja2-formatted file to be written.

in_dict: Dict

A Python dictionary containing the template variable key and value pairs.

Keywords:
fail_missing: bool, optional

A Python boolean valued variable specifying whether to fail if variables within the Jinja2-formatted template file have not been specified within the Python dictionary containing the Jinja2-formatted file template variable key and value pairs (in_dict).

rpl_tmpl_mrks: bool, optional

A Python boolean valued variable specifying whether to replace any pre-defined template markers (see confs/template_interface.py, prior to populating the Jinja2-formatted template.

f90_bool: bool, optional

A Python boolean valued variable specifying whether to transform boolean variables to a FORTRAN 90 format.

skip_missing: bool, optional

A Python boolean valued variable specifying whether to skip (i.e., exclude from output) template variables that are not specified within Python dictionary containing the Jinja2-formatted file template variable key and value pairs (in_dict).

warn: bool, optional

A Python boolean valued variable specifying whether to create Logger warning messages for missing template variables.

Raises:
Jinja2InterfaceError:
  • raised if an exception is encountered while writing the Jinja2-formatted file.

Return type:

None

confs.jinja2_interface.write_jinja2(jinja2_file, in_dict)[source]#

DESCRIPTION:

This function writes a Jinja2-formatted file using the specified Python dictionary.

Parameters:
jinja2_file: str

A Python string containing the full-path to the Jinja2-formatted file to be written.

in_dict: Dict

A Python dictionary containing the attributes to be written to the Jinja2 file.

Raises:
Jinja2InterfaceError:
  • raised if an exception is encountered while writing the Jinja2-formatted file.

Return type:

None