(module_tree: dict[str, any], indent: int = 0)
| 265 | lines = [] |
| 266 | |
| 267 | def _format_module_tree(module_tree: dict[str, any], indent: int = 0): |
| 268 | for key, value in module_tree.items(): |
| 269 | if key == module_name: |
| 270 | lines.append(f"{' ' * indent}{key} (current module)") |
| 271 | else: |
| 272 | lines.append(f"{' ' * indent}{key}") |
| 273 | |
| 274 | # Group components by file |
| 275 | from collections import defaultdict |
| 276 | by_file = defaultdict(list) |
| 277 | for c in value['components']: |
| 278 | if "::" in c: |
| 279 | fpath, name = c.split("::", 1) |
| 280 | by_file[fpath].append(name) |
| 281 | else: |
| 282 | by_file[""].append(c) |
| 283 | for fpath, names in by_file.items(): |
| 284 | if fpath: |
| 285 | lines.append(f"{' ' * (indent + 1)} {fpath}: {', '.join(names)}") |
| 286 | else: |
| 287 | lines.append(f"{' ' * (indent + 1)} {', '.join(names)}") |
| 288 | |
| 289 | if isinstance(value["children"], dict) and len(value["children"]) > 0: |
| 290 | lines.append(f"{' ' * (indent + 1)} Children:") |
| 291 | _format_module_tree(value["children"], indent + 2) |
| 292 | |
| 293 | _format_module_tree(module_tree, 0) |
| 294 | formatted_module_tree = "\n".join(lines) |
no outgoing calls
no test coverage detected