"""Unzip the CLICS4 tables to a temporary folder and run the registered screen."""
import os
import subprocess
import sys
import tempfile
import zipfile

tmp = tempfile.mkdtemp()
for name in ("forms", "concepts"):
    with zipfile.ZipFile(f"data/clics4/{name}.csv.zip") as z:
        z.extractall(tmp)
os.makedirs("results", exist_ok=True)
subprocess.run([sys.executable, "code/mechanics.py", os.path.join(tmp, "forms.csv"), "data/clics4/languages.csv",
                "results/R1.json"], check=True, stdout=subprocess.DEVNULL)
