fgen.jinja_environment#

Jinja environment to use while generating wrappers

JINJA_ENV#

JINJA_ENV = <jinja2.environment.Environment object>#

Jinja2 environment to use for template rendering

ensure_indent#

strip_empty_lines#

strip_empty_lines(inp)[source]#

Strip empty lines

More specifically, turn lines that only have whitespace into a single newline character. This is a workaround until we start formatting our Fortran as part of the generation process (magicc/fgen#26).

Parameters:

inp (str) – Input string

Returns:

str – Input string, with all whitespace lines replaced by a single newline character.

get_template_in_directory#

get_template_in_directory(template_name, template_directory, env)[source]#

Get template that is in the directory specified by file_dunder

Parameters:
  • template_name (str) – Name of the template to get

  • template_directory (pathlib.Path) –

    The directory from which to retrieve the template.

    If you want to retrieve a template in the same directory as the file that is calling this function, call get_template_in_directory(template_name, Path(__file__).parent), env).

  • env (jinja2.environment.Environment) – Jinja2 environment to use when loading the template. This must be using a jinja2.loaders.FileSystemLoader loader. The loader must only have one search path.

Returns:

jinja2.environment.Template – Loaded template

post_process_jinja_rendering#

post_process_jinja_rendering(inp)[source]#

Post-process the result from Jinja

This fixes things we can’t work out how to fix with jinja

Parameters:

inp (str) – Result of formatting with jinja

Returns:

str – Post-processed result