INNER CODE UNIT · Python

summarize

apistol78/traktor · scripts/generate-node-emitter-capture.py:80

def summarize(body):
    """Best-effort one-line GLSL expression for a node, or None if not cleanly
    expressible. Reconstructs the single `assign(f, out) << ...;` statement,
    substituting emitInput variables with their pin names. Bails on anything
    that isn't a single straightforward assignment of literals + input pins."""
    vars = {}
    for m in re.finditer(r"(\w+)\s*=\s*cx\.emitInput\(\s*node\s*,\s*L\"([^\"]+)\"", body):
        vars[m.group(1)] = m.group(2)

    om = re.search(r"cx\.emitOutput\(\s*node\s*,\s*L\"([^\"]+)\"", body)
    out_name = om.group(1) if om else "Output"

    assign_lines = [ln.strip() for ln in body.splitlines() if re.search(r"\bassign\s*\(\s*f\s*,", ln)]
    if len(assign_lines) != 1:
        return None

    m = re.search(r"assign\s*\(\s*f\s*,\s*\w+\s*\)\s*<<(.*)$", assign_lines[0])
    if not m:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…