INNER CODE UNIT · Python

format_if_element

Leadaxe/LxBox · app/scripts/format_wizard_template.py:108

def format_if_element(obj: dict[str, Any], level: int, *, trailing_comma: bool) -> list[str]:
    ifd = obj["#if"]
    val = ifd.get("value")
    if isinstance(val, (str, int, float, bool)) or (
        isinstance(val, dict)
        and len(val) <= 4
        and not any(is_at(x) for x in val.values() if isinstance(x, str))
        and "inbound" not in val
    ):
        return [pad(level) + format_if_scalar(ifd) + ("," if trailing_comma else "")]

    cond_key = "and" if "and" in ifd else "or"
    lines = [
        pad(level)
        + '{"#if": {'
        + f'"{cond_key}": '
        + compact(ifd[cond_key])
        + ', "value": {'

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…