mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-04 06:55:09 +00:00
feat(drm)!: load DRM systems beyond the built-ins from plugins in directories.plugins
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
"""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 == []
|
||||
Reference in New Issue
Block a user