F2x.template package

F2x.template.collect_template_data(include=None)

Collect all data files that are required by any registered template.

This includes:

  • all template files and their dependencies

  • all library files included in the templates

  • all Python modules included in the templates

Parameters

include – A set of strings that indicates what to collect. Possible choices are ‘templates’, ‘depends’, ‘libraries’, and ‘modules’. If nothing is select explicitly, everything will be collected.

Returns

A generator that yields pairs of template and the requested data files.

F2x.template.get_library_sources(*templates)

Collect source files for all libraries in the given list of templates.

Parameters

templates – A list of template names or template modules.

Returns

A list with all library files with full path that are required by the given templates.

F2x.template.get_template(name: str) → module

Retrieve a loaded template from the registry.

Parameters

name – Name of a loaded template.

Returns

The template module.

F2x.template.register_template(template)

Add a new template to the registry.

Before the module is registered, some preprocessing is made:

  • Check if all required attributes of the template are set. These are:
    • name: The name of the template. This will later be used to reference the template.

    • templates: A list of templates that should be rendered.

    • requires: Other templates that need to be rendered in order for this template to work. May be None.

    • modules: A list of Python modules the rendered output requires to work.

    • libraries: A list of libraries the compiled output of this template needs to work. You may

      use only module names if the required libraries are added to the distribution in any other way. Otherwise use a tuple with the library name and a library spec dict like used for numpy.

    • A docstring.

  • The following attributes are added:
    • package_dir: The directory of the template package.

    • template_files: A list with full pathes of all template files to be rendered.

    • depends: A list of dependencies for all rendered templates.

  • The docstring is extended to reference templates and libraries.

Parameters

template – The template module to register.

F2x.template.show_templates(out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, full_doc=False)

Print a nicely formatted list of templates and their documentation.

Parameters

out – The file to write to.