48 lines
1.6 KiB
Python
Executable File
48 lines
1.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Inventory temporary names and reject them from public/installable surfaces."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
TOKENS = ("Project Kiln", "kiln", "KILN_")
|
|
IGNORED_PARTS = {".git", "target", "__pycache__"}
|
|
PUBLIC_SURFACES = {"dist", "packaging", "public", "release"}
|
|
TEXT_SUFFIXES = {"", ".csv", ".md", ".py", ".rs", ".toml", ".yml", ".yaml"}
|
|
|
|
|
|
def main() -> None:
|
|
matches: list[tuple[Path, str]] = []
|
|
violations: list[tuple[Path, str]] = []
|
|
for path in ROOT.rglob("*"):
|
|
relative = path.relative_to(ROOT)
|
|
if not path.is_file() or any(part in IGNORED_PARTS for part in relative.parts):
|
|
continue
|
|
if path.suffix.lower() not in TEXT_SUFFIXES:
|
|
continue
|
|
try:
|
|
content = path.read_text()
|
|
except UnicodeDecodeError:
|
|
continue
|
|
for token in TOKENS:
|
|
if token not in content:
|
|
continue
|
|
matches.append((relative, token))
|
|
if any(part in PUBLIC_SURFACES for part in relative.parts):
|
|
violations.append((relative, token))
|
|
if violations:
|
|
for path, token in violations:
|
|
print(f"FAIL: temporary token {token!r} in public surface {path}", file=sys.stderr)
|
|
raise SystemExit(1)
|
|
if not matches:
|
|
print("FAIL: expected private placeholders were not found", file=sys.stderr)
|
|
raise SystemExit(1)
|
|
print(f"PASS: {len(matches)} temporary-name occurrences remain private and inventoried")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|