INNER CODE UNIT · Python

format_if_scalar

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

def format_if_scalar(ifd: dict[str, Any]) -> str:
    return compact({"#if": ifd})


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)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…