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
indent_based_on_first_line#
- indent_based_on_first_line(code, indent)[source]#
Indent code based on the indent of the first line.
If the first line does not have indent equal to
indent, all the code except the first line will have an indent added such that the first line would have an indent ofindent. We exclude the first line so that the indent can be included in the jinja template too, which makes it easier to read what is going on.
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).
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 gettemplate_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 ajinja2.loaders.FileSystemLoaderloader. The loader must only have one search path.
- Returns:
jinja2.environment.Template– Loaded template