Skip to content

expansion

expansion

Restricted variable expansion for validation and flow file templates.

Functions:

expand_known

expand_known(template, context)

Substitute declared keys; preserve unknown braces and regex quantifiers.

Source code in src/marianne/execution/validation/expansion.py
def expand_known(template: str, context: Mapping[str, Any]) -> str:
    """Substitute declared keys; preserve unknown braces and regex quantifiers."""
    return _NAME.sub(
        lambda match: str(context[match.group(1)])
        if match.group(1) in context else match.group(0),
        template,
    )