confab.loaders

Jinja2 Environment loading helper functions.

Confab uses the environments jinja2.Environment.list_templates() method to abstract template location from rendering and synchronization.

Note that the default Jinja2 Loaders assume a charset (default: utf-8).

class confab.loaders.ConfabFileSystemLoader(searchpath, encoding='utf-8')[source]

Bases: jinja2.loaders.FileSystemLoader

Adds support for binary templates when loading an environment from the file system.

Binary config files cannot be loaded as Jinja2 templates by default, but since confab’s model is built around Jinja2 environments we need to make sure we can still represent them as Jinja2 Templates.

Since confab only renders templates from text config files (see confab.conffiles.Conffile.generate() and confab.options.should_render()) we can workaround this by returning a dummy template for binary config files with the appropriate metadata. When generating the configuration, confab, instead of rendering the template, will just copy the template file (the binary config file) verbatim to the generated folder.

class confab.loaders.EmptyLoader[source]

Bases: jinja2.loaders.BaseLoader

Jinja template loader with no templates.

class confab.loaders.FileSystemEnvironmentLoader(dir_name)[source]

Bases: object

Loads Jinja2 environments from directories.

class confab.loaders.PackageEnvironmentLoader(package_name, templates_path='templates')[source]

Bases: object

Loads Jinja2 environments from python packages.