MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / _limit_namespaces

Function _limit_namespaces

code2flow/engine.py:571–610  ·  view source on GitHub ↗

Exclude namespaces (classes/modules) which match any of the exclude_namespaces :param list[Group] file_groups: :param list exclude_namespaces: :param list include_only_namespaces: :rtype: list[Group]

(file_groups, exclude_namespaces, include_only_namespaces)

Source from the content-addressed store, hash-verified

569
570
571def _limit_namespaces(file_groups, exclude_namespaces, include_only_namespaces):
572 """
573 Exclude namespaces (classes/modules) which match any of the exclude_namespaces
574
575 :param list[Group] file_groups:
576 :param list exclude_namespaces:
577 :param list include_only_namespaces:
578 :rtype: list[Group]
579 """
580
581 removed_namespaces = set()
582
583 for group in list(file_groups):
584 if group.token in exclude_namespaces:
585 for node in group.all_nodes():
586 node.remove_from_parent()
587 removed_namespaces.add(group.token)
588 if include_only_namespaces and group.token not in include_only_namespaces:
589 for node in group.nodes:
590 node.remove_from_parent()
591 removed_namespaces.add(group.token)
592
593 for subgroup in group.all_groups():
594 print(subgroup, subgroup.all_parents())
595 if subgroup.token in exclude_namespaces:
596 for node in subgroup.all_nodes():
597 node.remove_from_parent()
598 removed_namespaces.add(subgroup.token)
599 if include_only_namespaces and \
600 subgroup.token not in include_only_namespaces and \
601 all(p.token not in include_only_namespaces for p in subgroup.all_parents()):
602 for node in subgroup.nodes:
603 node.remove_from_parent()
604 removed_namespaces.add(group.token)
605
606 for namespace in exclude_namespaces:
607 if namespace not in removed_namespaces:
608 logging.warning(f"Could not exclude namespace '{namespace}' "
609 "because it was not found.")
610 return file_groups
611
612
613def _limit_functions(file_groups, exclude_functions, include_only_functions):

Callers 1

map_itFunction · 0.85

Calls 6

setFunction · 0.85
all_nodesMethod · 0.80
all_groupsMethod · 0.80
all_parentsMethod · 0.80
remove_from_parentMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected