MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / _format_text

Function _format_text

src/ifcedit/ifcedit/__main__.py:42–61  ·  view source on GitHub ↗
(data, indent: int = 0)

Source from the content-addressed store, hash-verified

40
41
42def _format_text(data, indent: int = 0) -> str:
43 prefix = " " * indent
44 lines = []
45 if isinstance(data, dict):
46 for key, value in data.items():
47 if isinstance(value, (dict, list)):
48 lines.append(f"{prefix}{key}:")
49 lines.append(_format_text(value, indent + 1))
50 else:
51 lines.append(f"{prefix}{key}: {value}")
52 elif isinstance(data, list):
53 for item in data:
54 if isinstance(item, dict):
55 lines.append(_format_text(item, indent))
56 lines.append("")
57 else:
58 lines.append(f"{prefix}- {item}")
59 else:
60 lines.append(f"{prefix}{data}")
61 return "\n".join(lines)
62
63
64def cmd_list(args):

Callers 1

format_outputFunction · 0.70

Calls 3

itemsMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected