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

Method run

aura/package_analyzer.py:28–101  ·  view source on GitHub ↗
(
            cls,
            initial_locations: Union[base.ScanLocation, Iterable[base.ScanLocation]]
    )

Source from the content-addressed store, hash-verified

26class Analyzer:
27 @classmethod
28 def run(
29 cls,
30 initial_locations: Union[base.ScanLocation, Iterable[base.ScanLocation]]
31 ) -> Coroutine[Detection, Optional[AnalysisQueueItem], None]:
32 cleanup = []
33 files_queue = deque()
34 executor = worker_executor.AuraExecutor(job_queue=files_queue)
35
36 if isinstance(initial_locations, base.ScanLocation):
37 initial_locations = (initial_locations,)
38
39 for x in initial_locations:
40 detections = tuple(cls.run_input_hooks(location=x))
41 files_queue.append(x)
42 for d in detections:
43 comm = yield d
44 if comm:
45 files_queue.append(comm)
46
47 files_queue.append(worker_executor.Wait)
48
49 try:
50 while len(files_queue) or bool(executor):
51 try:
52 item: AnalysisQueueItem = files_queue.popleft()
53 except IndexError: # Queue is empty
54 executor.wait()
55 item = False
56
57 if item is False or item is worker_executor.Wait:
58 for f in executor:
59 locations, detections = f.result()
60 for loc in locations: # type: base.ScanLocation
61 if loc.cleanup:
62 cleanup.append(loc)
63
64 files_queue.append(loc)
65
66 for x in detections:
67 comm = yield x
68 if comm:
69 files_queue.append(comm)
70 continue
71
72 should_continue: Union[bool, Detection] = item.should_continue()
73 # Equals True if it's ok to process this item
74 # Otherwise returns `Rule` indicating why processing of this location should be halted
75 if should_continue is not True:
76 comm = yield should_continue
77 if comm:
78 files_queue.append(comm)
79 continue
80
81 if item.location.is_dir():
82 collected = cls.scan_directory(item=item)
83
84 for x in collected:
85 files_queue.append(x)

Callers 3

scan_workerFunction · 0.45
analyze_changesMethod · 0.45
execute_interpreterFunction · 0.45

Calls 7

waitMethod · 0.95
submitMethod · 0.95
run_input_hooksMethod · 0.80
should_continueMethod · 0.80
scan_directoryMethod · 0.80
do_cleanupMethod · 0.80
existsMethod · 0.45

Tested by

no test coverage detected