Files
beeos/tools/clean_project.py

31 lines
770 B
Python

from __future__ import annotations
"""Clean generated Python cache files from the BeeOS project."""
import argparse
import shutil
from pathlib import Path
def main() -> None:
parser = argparse.ArgumentParser(description="Remove __pycache__ and .pyc files.")
parser.add_argument("--project-root", default=".", help="BeeOS project root")
args = parser.parse_args()
project_root = Path(args.project_root).resolve()
removed = 0
for cache_dir in project_root.rglob("__pycache__"):
shutil.rmtree(cache_dir, ignore_errors=True)
removed += 1
for pyc in project_root.rglob("*.pyc"):
pyc.unlink(missing_ok=True)
removed += 1
print(f"Cleaned {removed} cache item(s).")
if __name__ == "__main__":
main()