MCPcopy Index your code
hub / github.com/SourceCode-AI/aura / scan_directory

Method scan_directory

aura/package_analyzer.py:130–160  ·  view source on GitHub ↗
(item: base.ScanLocation)

Source from the content-addressed store, hash-verified

128
129 @staticmethod
130 def scan_directory(item: base.ScanLocation):
131 logger.debug(f"Collecting files in a directory '{item.str_location}")
132 topo = TopologySort()
133 collected = []
134
135 for f in utils.walk(item.location):
136 new_item = item.create_child(
137 f,
138 parent=item.parent,
139 strip_path=item.strip_path
140 )
141 collected.append(new_item)
142 topo.add_node(Path(new_item.location).absolute())
143
144 logger.debug("Computing import graph")
145
146 for x in collected:
147 if not x.metadata.get('py_imports'):
148 continue
149
150 node = Path(x.location).absolute()
151 topo.add_edge(node, x.metadata['py_imports']['dependencies'])
152
153 topology = topo.sort()
154
155 collected.sort(
156 key=lambda x: topology.index(x.location) if x.location in topology else 0
157 )
158 logger.debug("Topology sorting finished")
159
160 return collected

Callers 1

runMethod · 0.80

Calls 6

add_nodeMethod · 0.95
add_edgeMethod · 0.95
sortMethod · 0.95
TopologySortClass · 0.85
create_childMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected