INNER CODE UNIT · Python
strip_trailing_commas
Leadaxe/LxBox · app/scripts/format_wizard_template.py:31
def strip_trailing_commas(text: str) -> str:
prev = None
while prev != text:
prev = text
text = re.sub(r",(\s*[\]\}])", r"\1", text)
return text
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)