INNER CODE UNIT · Python

substitute

IvanMurzak/Unity-MCP · .github/scripts/chain_feed.py:602

def substitute(command, values, quote=None):
    """Replace every `{token}`; refuse on one this file does not define or cannot fill.

    `quote(name, value)` — `shell_value` for a command that reaches a shell — is applied to
    each value as it is pasted in; the recipe text itself is trusted (it is this file's own).
    """
    names = {m.group(1) for m in _PLACEHOLDER_RE.finditer(command)}
    unknown = sorted(names - set(values))
    if unknown:
        raise Refusal(
            "unknown placeholder(s) %s in %r" % (", ".join("{%s}" % u for u in unknown), command)
        )
    empty = sorted(name for name in names if not values[name])
    if empty:
        raise Refusal(
            "placeholder(s) %s in %r have no value in this lock"
            % (", ".join("{%s}" % e for e in empty), command)
        )

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…