-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean.py
More file actions
executable file
·49 lines (38 loc) · 1.23 KB
/
clean.py
File metadata and controls
executable file
·49 lines (38 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
"""Cross-platform cleanup of build artifacts, cache files, and temp files."""
import glob
import shutil
import sys
from pathlib import Path
def main() -> int:
"""Remove build artifacts, cache directories, and temporary files."""
root = Path(".")
# Paths to remove (may be files or directories)
for name in [".pytest_cache", "htmlcov", ".coverage", "dist", "build"]:
path = root / name
if path.is_dir():
shutil.rmtree(path)
elif path.is_file():
path.unlink()
# Glob patterns for directories
for path in glob.glob("*.egg-info"):
shutil.rmtree(path)
# Glob patterns for files
for pattern in [
"sbom.*.json",
"vulns.*.json",
"license-check.*.json",
"{{ cookiecutter.github_org }}_{{ cookiecutter.project_slug }}_*_*.tar",
]:
for path in glob.glob(pattern):
Path(path).unlink()
# Recursively remove __pycache__ directories
for path in root.rglob("__pycache__"):
if path.is_dir():
shutil.rmtree(path)
# Recursively remove .pyc files
for path in root.rglob("*.pyc"):
path.unlink()
return 0
if __name__ == "__main__":
sys.exit(main())