maker

This module provides the core functionality for converting an existing project into a cookiecutter template. It handles file replacement, directory structure transformation, and generation of cookiecutter.json configuration.

The main class is Maker, which orchestrates the entire template conversion process.

class cookiecutter_maker.maker.Maker(dir_input: ~pathlib.Path, dir_output: ~pathlib.Path, parameters: list[~cookiecutter_maker.parameter.Parameter], include: list[str] = <factory>, exclude: list[str] = <factory>, no_render: list[str] = <factory>, dir_hooks: ~pathlib.Path | None = None, verbose: bool = True)[source]

Cookiecutter maker class for converting concrete projects into cookiecutter templates.

Parameters:
  • dir_input – The directory you want to use as a seed project.

  • dir_output – Where to place the generated template project.

  • parameter – a list of Parameter defining substitution rules.

  • include – List of file path patterns to include from the input dir. If empty, we include all files and directories.

  • exclude – List of file path patterns to exclude from the input dir. If empty, we exclude nothing.

  • no_render – List of file path patterns to copy without rendering.

  • dir_hooks – Optional directory containing cookiecutter hooks.

  • verbose – Whether to print verbose output during processing

property path_matcher: PathMatcher

Create and return a PathMatcher instance for filtering files and directories.

property dir_template: Path

Determine the output template directory path.

This creates the path for the project template folder with cookiecutter variables in the name, based on the original input directory name.

property path_cookiecutter_json: Path

Get the path for the cookiecutter.json configuration file.

This file will contain the parameter definitions, default values, and other cookiecutter configuration options.

readiness_check()[source]

Perform pre-execution checks to ensure the operation can proceed.

write_cookiecutter_json()[source]

Create the cookiecutter.json configuration file.

See https://cookiecutter.readthedocs.io/en/stable/tutorials/tutorial2.html#step-2-create-cookiecutter-json

copy_hooks()[source]

Copy the hooks directory to the output template if specified.

Cookiecutter hooks are scripts that run before or after template generation. If a hooks directory is specified, it is copied to the output template.

make_template()[source]

Execute the full template generation process.