Augment Generator

Augment generator - adds components to existing projects.

class pypreset.augment_generator.AugmentComponent[source]

Bases: StrEnum

Available augment components.

TEST_WORKFLOW = 'test_workflow'
LINT_WORKFLOW = 'lint_workflow'
DEPENDABOT = 'dependabot'
TESTS_DIR = 'tests_dir'
GITIGNORE = 'gitignore'
CONFTEST = 'conftest'
PRE_COMMIT = 'pre_commit'
PYPI_PUBLISH = 'pypi_publish'
DOCKERFILE = 'dockerfile'
DEVCONTAINER = 'devcontainer'
CODECOV = 'codecov'
DOCUMENTATION = 'documentation'
TOX = 'tox'
VERSION_SYNC_GUARD = 'version_sync_guard'
PYENV = 'pyenv'
README = 'readme'
__new__(value)
class pypreset.augment_generator.GeneratedFile[source]

Bases: object

Represents a generated file.

Parameters:
path: Path
content: str
overwritten: bool = False
__init__(path, content, overwritten=False)
Parameters:
Return type:

None

class pypreset.augment_generator.AugmentResult[source]

Bases: object

Result of an augment operation.

Parameters:
success: bool
files_created: list[GeneratedFile]
files_skipped: list[Path]
errors: list[str]
__init__(success, files_created, files_skipped, errors)
Parameters:
Return type:

None

pypreset.augment_generator.get_augment_templates_dir()[source]

Get the directory containing augment templates.

Return type:

Path

pypreset.augment_generator.create_augment_jinja_env()[source]

Create Jinja2 environment for augment templates.

Return type:

Environment

pypreset.augment_generator.get_augment_context(config)[source]

Build template context from augment config.

The context is designed to be compatible with README.md.j2 and other templates from the create pipeline.

Parameters:

config (AugmentConfig)

Return type:

dict[str, Any]

class pypreset.augment_generator.ComponentGenerator[source]

Bases: ABC

Base class for component generators.

Parameters:
  • project_dir (Path)

  • config (AugmentConfig)

__init__(project_dir, config)[source]
Parameters:
  • project_dir (Path)

  • config (AugmentConfig)

Return type:

None

abstract property component_name: str

Return the component name for logging.

abstractmethod should_generate()[source]

Check if this component should be generated.

Return type:

bool

abstractmethod generate(force=False)[source]

Generate the component files.

Parameters:

force (bool)

Return type:

list[GeneratedFile]

class pypreset.augment_generator.TestWorkflowGenerator[source]

Bases: ComponentGenerator

Generates test workflow for GitHub Actions.

Parameters:
  • project_dir (Path)

  • config (AugmentConfig)

property component_name: str

Return the component name for logging.

should_generate()[source]

Check if this component should be generated.

Return type:

bool

generate(force=False)[source]

Generate the component files.

Parameters:

force (bool)

Return type:

list[GeneratedFile]

class pypreset.augment_generator.LintWorkflowGenerator[source]

Bases: ComponentGenerator

Generates lint workflow for GitHub Actions.

Parameters:
  • project_dir (Path)

  • config (AugmentConfig)

property component_name: str

Return the component name for logging.

should_generate()[source]

Check if this component should be generated.

Return type:

bool

generate(force=False)[source]

Generate the component files.

Parameters:

force (bool)

Return type:

list[GeneratedFile]

class pypreset.augment_generator.DependabotGenerator[source]

Bases: ComponentGenerator

Generates dependabot.yml configuration.

Parameters:
  • project_dir (Path)

  • config (AugmentConfig)

property component_name: str

Return the component name for logging.

should_generate()[source]

Check if this component should be generated.

Return type:

bool

generate(force=False)[source]

Generate the component files.

Parameters:

force (bool)

Return type:

list[GeneratedFile]

class pypreset.augment_generator.TestsDirectoryGenerator[source]

Bases: ComponentGenerator

Generates tests directory and template test file.

Parameters:
  • project_dir (Path)

  • config (AugmentConfig)

property component_name: str

Return the component name for logging.

should_generate()[source]

Check if this component should be generated.

Return type:

bool

generate(force=False)[source]

Generate the component files.

Parameters:

force (bool)

Return type:

list[GeneratedFile]

class pypreset.augment_generator.GitignoreGenerator[source]

Bases: ComponentGenerator

Generates .gitignore file.

Parameters:
  • project_dir (Path)

  • config (AugmentConfig)

property component_name: str

Return the component name for logging.

should_generate()[source]

Check if this component should be generated.

Return type:

bool

generate(force=False)[source]

Generate the component files.

Parameters:

force (bool)

Return type:

list[GeneratedFile]

class pypreset.augment_generator.PypiPublishWorkflowGenerator[source]

Bases: ComponentGenerator

Generates PyPI publish workflow for GitHub Actions.

Parameters:
  • project_dir (Path)

  • config (AugmentConfig)

property component_name: str

Return the component name for logging.

should_generate()[source]

Check if this component should be generated.

Return type:

bool

generate(force=False)[source]

Generate the component files.

Parameters:

force (bool)

Return type:

list[GeneratedFile]

class pypreset.augment_generator.DockerfileGenerator[source]

Bases: ComponentGenerator

Generates Dockerfile/Containerfile and ignore file.

Parameters:
  • project_dir (Path)

  • config (AugmentConfig)

property component_name: str

Return the component name for logging.

should_generate()[source]

Check if this component should be generated.

Return type:

bool

generate(force=False)[source]

Generate the component files.

Parameters:

force (bool)

Return type:

list[GeneratedFile]

class pypreset.augment_generator.DevcontainerGenerator[source]

Bases: ComponentGenerator

Generates .devcontainer/devcontainer.json.

Parameters:
  • project_dir (Path)

  • config (AugmentConfig)

property component_name: str

Return the component name for logging.

should_generate()[source]

Check if this component should be generated.

Return type:

bool

generate(force=False)[source]

Generate the component files.

Parameters:

force (bool)

Return type:

list[GeneratedFile]

class pypreset.augment_generator.CodecovGenerator[source]

Bases: ComponentGenerator

Generates codecov.yml configuration.

Parameters:
  • project_dir (Path)

  • config (AugmentConfig)

property component_name: str

Return the component name for logging.

should_generate()[source]

Check if this component should be generated.

Return type:

bool

generate(force=False)[source]

Generate the component files.

Parameters:

force (bool)

Return type:

list[GeneratedFile]

class pypreset.augment_generator.DocumentationGenerator[source]

Bases: ComponentGenerator

Generates documentation scaffolding (MkDocs or Sphinx).

Parameters:
  • project_dir (Path)

  • config (AugmentConfig)

property component_name: str

Return the component name for logging.

should_generate()[source]

Check if this component should be generated.

Return type:

bool

generate(force=False)[source]

Generate the component files.

Parameters:

force (bool)

Return type:

list[GeneratedFile]

class pypreset.augment_generator.ToxGenerator[source]

Bases: ComponentGenerator

Generates tox.ini configuration.

Parameters:
  • project_dir (Path)

  • config (AugmentConfig)

property component_name: str

Return the component name for logging.

should_generate()[source]

Check if this component should be generated.

Return type:

bool

generate(force=False)[source]

Generate the component files.

Parameters:

force (bool)

Return type:

list[GeneratedFile]

class pypreset.augment_generator.PyenvGenerator[source]

Bases: ComponentGenerator

Generates .python-version file for pyenv/uv version pinning.

Parameters:
  • project_dir (Path)

  • config (AugmentConfig)

property component_name: str

Return the component name for logging.

should_generate()[source]

Check if this component should be generated.

Return type:

bool

generate(force=False)[source]

Generate the component files.

Parameters:

force (bool)

Return type:

list[GeneratedFile]

class pypreset.augment_generator.VersionSyncGuardGenerator[source]

Bases: ComponentGenerator

Generates scripts/check_tool_versions.py for version sync checking.

Parameters:
  • project_dir (Path)

  • config (AugmentConfig)

property component_name: str

Return the component name for logging.

should_generate()[source]

Check if this component should be generated.

Return type:

bool

generate(force=False)[source]

Generate the component files.

Parameters:

force (bool)

Return type:

list[GeneratedFile]

class pypreset.augment_generator.ReadmeGenerator[source]

Bases: ComponentGenerator

Generates README.md from the shared README template.

Parameters:
  • project_dir (Path)

  • config (AugmentConfig)

property component_name: str

Return the component name for logging.

should_generate()[source]

Check if this component should be generated.

Return type:

bool

generate(force=False)[source]

Generate the component files.

Parameters:

force (bool)

Return type:

list[GeneratedFile]

class pypreset.augment_generator.AugmentOrchestrator[source]

Bases: object

Orchestrates the augment operation across components.

Parameters:
  • project_dir (Path)

  • config (AugmentConfig)

__init__(project_dir, config)[source]
Parameters:
  • project_dir (Path)

  • config (AugmentConfig)

Return type:

None

generators: list[ComponentGenerator]
run(force=False, components=None)[source]

Run the augment operation.

Parameters:
Return type:

AugmentResult

pypreset.augment_generator.augment_project(project_dir, config, force=False, components=None)[source]

Augment an existing project with workflows and tests.

Parameters:
  • project_dir (Path) – Path to the project directory

  • config (AugmentConfig) – Augment configuration

  • force (bool) – Whether to overwrite existing files

  • components (list[AugmentComponent] | None) – Specific components to generate (None = all enabled)

Return type:

AugmentResult

Returns:

AugmentResult with details of generated files