Returns the tree starting at a given module following all edges. Args: module (`str`): The module that will be the root of the subtree we want. edges (`List[Tuple[str, str]]`): The list of all edges of the tree. Returns: `List[Union[str, List[str]]]`: The tree
(module: str, edges: List[Tuple[str, str]])
| 630 | |
| 631 | |
| 632 | def get_tree_starting_at(module: str, edges: List[Tuple[str, str]]) -> List[Union[str, List[str]]]: |
| 633 | """ |
| 634 | Returns the tree starting at a given module following all edges. |
| 635 | |
| 636 | Args: |
| 637 | module (`str`): The module that will be the root of the subtree we want. |
| 638 | edges (`List[Tuple[str, str]]`): The list of all edges of the tree. |
| 639 | |
| 640 | Returns: |
| 641 | `List[Union[str, List[str]]]`: The tree to print in the following format: [module, [list of edges |
| 642 | starting at module], [list of edges starting at the preceding level], ...] |
| 643 | """ |
| 644 | vertices_seen = [module] |
| 645 | new_edges = [edge for edge in edges if edge[0] == module and edge[1] != module and "__init__.py" not in edge[1]] |
| 646 | tree = [module] |
| 647 | while len(new_edges) > 0: |
| 648 | tree.append(new_edges) |
| 649 | final_vertices = list({edge[1] for edge in new_edges}) |
| 650 | vertices_seen.extend(final_vertices) |
| 651 | new_edges = [ |
| 652 | edge |
| 653 | for edge in edges |
| 654 | if edge[0] in final_vertices and edge[1] not in vertices_seen and "__init__.py" not in edge[1] |
| 655 | ] |
| 656 | |
| 657 | return tree |
| 658 | |
| 659 | |
| 660 | def print_tree_deps_of(module, all_edges=None): |
no outgoing calls
no test coverage detected