MCPcopy Create free account
hub / github.com/FSoft-AI4Code/CodeWiki / _get_processing_order

Function _get_processing_order

codewiki/mcp/tools/module_tree.py:22–56  ·  view source on GitHub ↗

Compute leaf-first processing order from a module tree. Returns a list of dicts with module path, name, leaf status, and component/children info.

(module_tree: Dict[str, Any], parent_path: List[str] | None = None)

Source from the content-addressed store, hash-verified

20
21
22def _get_processing_order(module_tree: Dict[str, Any], parent_path: List[str] | None = None) -> List[Dict[str, Any]]:
23 """Compute leaf-first processing order from a module tree.
24
25 Returns a list of dicts with module path, name, leaf status, and
26 component/children info.
27 """
28 if parent_path is None:
29 parent_path = []
30 order: List[Dict[str, Any]] = []
31
32 def _collect(tree: Dict[str, Any], path: List[str]) -> None:
33 for module_name, module_info in tree.items():
34 current_path = path + [module_name]
35 children = module_info.get("children", {})
36 has_children = isinstance(children, dict) and len(children) > 0
37
38 if has_children:
39 _collect(children, current_path)
40 order.append({
41 "module": module_name,
42 "path": current_path,
43 "is_leaf": False,
44 "children": list(children.keys()),
45 "components": module_info.get("components", []),
46 })
47 else:
48 order.append({
49 "module": module_name,
50 "path": current_path,
51 "is_leaf": True,
52 "components": module_info.get("components", []),
53 })
54
55 _collect(module_tree, parent_path)
56 return order
57
58
59def handle_save_module_tree(

Callers 2

handle_save_module_treeFunction · 0.85

Calls 1

_collectFunction · 0.85

Tested by

no test coverage detected