fmf_jinja.generators

Generators that consume the template and its data.

class fmf_jinja.generators.FullGenerator(ctx)

Bases: object

Main generator.

Processes the fmf tree and generates all output files

ctx: TemplateContext

Current run context.

property curr_path: str

Current path string that is being processed.

property tree: Tree

Current fmf tree node.

vars: dict[str, DataType]
property sub_generators: list[SubGenerator]

Actual generators to execute.

generate()

Run the sub generators.

Return type:

None

class fmf_jinja.generators.SubGenerator(parent)

Bases: ABC

Generators that do the main work.

parent: FullGenerator

Main generator run.

property ctx: TemplateContext

Current run context.

abstract classmethod from_fmf_data(parent, data)

Construct from the fmf data.

Return type:

Self

abstract generate()

Run the generator.

Return type:

None

class fmf_jinja.generators.TemplateGenerator(parent, path, exclude=NOTHING, include_empty_folder=False)

Bases: SubGenerator

Jinja template generator.

Renders a jinja template or a whole folder.

path: Path

Relative path to the template folder.

exclude: list[Path]

Paths to be excluded from the template generation.

include_empty_folder: bool

Whether to include empty folders in the generated output.

property template_path: Path

Resolved path of the template.

property template_dir: Path

Directory of the template: either path or its parent.

classmethod from_fmf_data(parent, data)

Construct from the fmf data.

Return type:

TemplateGenerator

generate()

Run the generator.

Return type:

None

class fmf_jinja.generators.SymlinkGenerator(parent, symlinks)

Bases: SubGenerator

Symbolic link generator.

Creates symbolic links with the context of the fmf tree.

Symbolic links to generate

The dict structure is:
  • key: path to the symbolic link generated

  • value: target where the symbolic link points to

classmethod from_fmf_data(parent, data)

Construct from the fmf data.

Return type:

SymlinkGenerator

generate()

Run the generator.

Return type:

None

class fmf_jinja.generators.CopyGenerator(parent, files)

Bases: SubGenerator

Copy generator.

Copies files with the context of the fmf tree.

files: dict[str, Path]

Files to copy.

classmethod from_fmf_data(parent, data)

Construct from the fmf data.

Return type:

CopyGenerator

generate()

Run the generator.

Return type:

None