"""Core names no plugin DRM: a plugin brings its own names, and its docs live in its own README.""" from __future__ import annotations import re from pathlib import Path ROOT = Path(__file__).resolve().parents[2] NAMES = re.compile("|".join(["mona" + "lisa", "bb" + "ts", "blow" + "fish", "stripe " + "cipher", r"\.ml" + "d"]), re.I) PLACES = ["unshackle", "tests", "docs", "mkdocs.yml", "README.md", "pyproject.toml"] SKIP = {"plugins", "_repos", "__pycache__"} def files() -> list[Path]: found = [] for place in PLACES: path = ROOT / place if path.is_file(): found.append(path) elif path.is_dir(): found += [ p for p in path.rglob("*") if p.is_file() and not SKIP & set(p.relative_to(path).parts) and p.suffix in {".py", ".md", ".yml", ".yaml", ".toml", ".json", ".txt"} ] return found def test_core_tests_and_docs_name_no_plugin_drm() -> None: hits = [ f"{path.relative_to(ROOT)}:{n}" for path in files() for n, line in enumerate(path.read_text(encoding="utf-8", errors="replace").splitlines(), 1) if NAMES.search(line) ] assert hits == []