mass_driver.drivers.bricks
Patterns of PatchDriver that are reusable
Module Contents
Classes
A PatchDriver that edits a single file |
|
A PatchDriver that edits multiple files via Glob |
Functions
Forward a OK PatchResult if an OK happened on any file |
|
Process a file content through a list of old-new replacements |
API
- class mass_driver.drivers.bricks.SingleFileEditor[source]
Bases:
mass_driver.models.patchdriver.PatchDriverA PatchDriver that edits a single file
Reads
target_fileand callsprocess_file()with it string content, saving the file if process changes the file, or returns givenPatchResultif any.- target_file: str = None
The file to edit
- abstract process_file(file_contents: str) str | mass_driver.models.patchdriver.PatchResult[source]
Process the file, returning the new content or a PatchResult
- run(repo: mass_driver.models.repository.ClonedRepo) mass_driver.models.patchdriver.PatchResult[source]
Edit the target file
- class mass_driver.drivers.bricks.GlobFileEditor[source]
Bases:
mass_driver.models.patchdriver.PatchDriverA PatchDriver that edits multiple files via Glob
Reads
target_globand callsprocess_file()with each string content, saving the file if process changes each file.The aggregated
PatchResults are processed viaprocess_outcomes(), see thefail_on_any_errorparameter.- target_glob: str = None
The glob for files to edit, relative to project root
- fail_on_any_error: bool = True
Whether or not to declare failure on any PATCH_ERRROR, or assume any OK as good
- abstract process_file(filename, file_contents: str) str | mass_driver.models.patchdriver.PatchResult[source]
Process a file, returning the new content or a PatchResult
- run(repo: mass_driver.models.repository.ClonedRepo) mass_driver.models.patchdriver.PatchResult[source]
Edit the target file
- mass_driver.drivers.bricks.process_outcomes(outcomes: dict[str, mass_driver.models.patchdriver.PatchResult], fail_on_any_error: bool, logger: logging.Logger)[source]
Forward a OK PatchResult if an OK happened on any file