Batch / directory processing
The PyReprism.batch module analyzes or transforms whole source trees.
Discovery skips junk folders (.git, node_modules, venv, …) and files
with unrecognized extensions:
from PyReprism import batch
report = batch.analyze("myproject/")
report.totals()
report.by_language()
print(report.to_csv())
batch.transform("myproject/",
lambda text, lang: lang.remove_comments(text),
output="stripped/")
Batch/directory processing: analyze or transform whole source trees.
Discovery walks directories, skips common junk folders, and keeps only files
whose extension maps to a supported language. analyze() returns aggregate
metrics (per file, per language, and totals) exportable as JSON or CSV;
transform() applies a text transformation across a tree, optionally writing
a mirrored output directory.
- class PyReprism.batch.BatchReport(files: ~typing.List[~PyReprism.batch.FileReport] = <factory>)
Bases:
objectAggregate report over a set of files.
- property errors: List[FileReport]
- files: List[FileReport]
- property ok: List[FileReport]
- class PyReprism.batch.FileReport(path: str, language: str, stats: CodeStats | None = None, error: str | None = None)
Bases:
objectMetrics for one processed file (
statsisNoneon error).
- PyReprism.batch.analyze(paths: str | PathLike | Sequence[str | PathLike], *, engine: str = 'regex', recursive: bool = True, include: Sequence[str] | None = None, exclude: Sequence[str] | None = None) BatchReport
Walk
pathsand computeCodeStatsfor every supported file.
- PyReprism.batch.iter_source_files(paths: str | PathLike | Sequence[str | PathLike], *, recursive: bool = True, include: Sequence[str] | None = None, exclude: Sequence[str] | None = None) Iterator[Tuple[Path, Path, type]]
Yield
(base, path, language_cls)for every supported source file.baseis the top-level input the file was discovered under (used to mirror directory structure). Files with an unrecognized extension are skipped.
- PyReprism.batch.transform(paths: str | PathLike | Sequence[str | PathLike], transformer: Callable[[str, type], str], *, output: str | PathLike | None = None, in_place: bool = False, recursive: bool = True, include: Sequence[str] | None = None, exclude: Sequence[str] | None = None) List[Tuple[str, str]]
Apply
transformer(text, language_cls)to every discovered file.With
outputthe tree is mirrored under that directory; within_placefiles are rewritten. Returns(path, status)pairs.