Implemented Rekordbox core base

This commit is contained in:
patben8 committed 2026-09-18 09:12:59 +02:00
1 parent 6e24f5ef1d
commit 4592e13228
18 files changed
+2170 -6

No files matched your search

+35
View File
@@ -46,5 +46,40 @@ print("== adapters own their native model ==")
store = (CORE.parent / "adapters" / "traktor" / "store.py").read_text()
check("the Traktor store is where traktor_nml_utils lives", "traktor_nml_utils" in store)
# No adapter may import another platform's library. That is the rule that keeps
# the packages independently removable, and it is checked on real imports (AST)
# rather than on text, so merely NAMING another platform in a comment is fine.
NATIVE = {"traktor": "traktor_nml_utils", "rekordbox": "pyrekordbox"}
def imported_modules(path):
names = set()
for node in ast.walk(ast.parse(path.read_text())):
if isinstance(node, ast.Import):
names.update(a.name for a in node.names)
elif isinstance(node, ast.ImportFrom) and not node.level:
names.add(node.module or "")
return names
for platform, module in NATIVE.items():
pkg = CORE.parent / "adapters" / platform
if not pkg.is_dir():
continue
foreign = {m for p_, m in NATIVE.items() if p_ != platform}
strays = []
for src in sorted(pkg.rglob("*.py")):
for name in imported_modules(src):
if any(name == f or name.startswith(f + ".") for f in foreign):
strays.append(f"{src.name}: {name}")
check(f"the {platform} adapter imports no other platform's library",
not strays, "; ".join(strays))
own = [
src.name
for src in sorted(pkg.rglob("*.py"))
if any(n == module or n.startswith(module + ".") for n in imported_modules(src))
]
check(f"the {platform} adapter does import {module} somewhere", bool(own), "nowhere")
print("\nRESULT:", "FAILED" if failed else "ALL PASSED")
sys.exit(1 if failed else 0)