INNER CODE UNIT · Python
is_simple_var
Leadaxe/LxBox · app/scripts/format_wizard_template.py:39
def is_simple_var(v: dict[str, Any]) -> bool:
if "ref" in v:
return True
allowed = {"name", "type", "default_value", "title", "tooltip", "wizard_ui", "required"}
return set(v.keys()) <= allowed and "options" not in v and "on_change" not in v
def format_var(v: dict[str, Any], level: int, *, trailing_comma: bool) -> list[str]:
if is_simple_var(v):
line = pad(level) + compact(v)
return [line + ("," if trailing_comma else "")]
header_keys = ["name", "type", "wizard_ui", "title", "tooltip", "required"]
header = ", ".join(f'"{k}": {json.dumps(v[k], ensure_ascii=False)}' for k in header_keys if k in v)
lines = [pad(level) + "{ " + header + ","]
if "default_value" in v:
lines.append(pad(level + 1) + f'"default_value": {json.dumps(v["default_value"], ensure_ascii=False)},')