99from queue import Queue
1010
1111from . import FileScanInput , ScanResults
12+ from ..analyser import AnalysisResult
1213
1314from .pool import Pool
1415from .Scanner import Scanner
@@ -56,13 +57,12 @@ def process_results():
5657 error_msgs .append (f'An error occured while scanning { relpath } using \' { cat } \' analyser' )
5758
5859 self ._notifyCompletion (relpath , result , error_msgs )
59-
60+
6061 if result :
61- results .update ({
62- relpath : result
63- })
62+ results [relpath ] = result
63+
6464
65- def report_results (relpath : str , result : dict , errors : t .Dict [str , str ]):
65+ def report_results (relpath : str , result : t . List [ AnalysisResult ] , errors : t .Dict [str , str ]):
6666 results_queue .put ((relpath , result , errors ))
6767
6868 pool = futures .ThreadPoolExecutor ()
@@ -87,11 +87,11 @@ def report_results(relpath: str, result: dict, errors: t.Dict[str, str]):
8787
8888 def _get_scan_file_fn (self ) -> t .Callable [[Path ,
8989 t .Optional [Path ],
90- t .Callable [[str , dict , t .Dict [str , str ]], None ]], None ]:
90+ t .Callable [[str , t . List [ AnalysisResult ] , t .Dict [str , str ]], None ]], None ]:
9191
9292 def _scan_file (path : Path ,
9393 root : t .Optional [Path ],
94- report_results : t .Callable [[str , dict , t .Dict [str , str ]], None ]):
94+ report_results : t .Callable [[str , t . List [ AnalysisResult ] , t .Dict [str , str ]], None ]):
9595
9696 PoolScanner ._scan_file_parallel (path ,
9797 root ,
@@ -107,18 +107,16 @@ def _scan_file_parallel(path: Path,
107107 root : t .Optional [Path ],
108108 analysers : t .List [FileAnalyser ],
109109 timeout : int ,
110- report_results : t .Callable [[str , dict , t .Dict [str , str ]], None ],
110+ report_results : t .Callable [[str , t . List [ AnalysisResult ] , t .Dict [str , str ]], None ],
111111 pool : Pool ):
112- result = {}
112+ result = []
113113 errors = {}
114114
115115 relpath = str (path .relative_to (root ) if root else path )
116116
117- def task_completed (_cat ):
118- def _callback (_res ):
119- if _res :
120- result [_res .category ] = _res .data
121- return _callback
117+ def task_completed (_res ):
118+ if _res :
119+ result .append (_res )
122120
123121 def task_failed (_cat ):
124122 def _callback (_err ):
@@ -127,7 +125,7 @@ def _callback(_err):
127125
128126 tasks = [pool .apply_async (
129127 _apply_analysis , (analyser , path , root ),
130- callback = task_completed ( analyser . category ) ,
128+ callback = task_completed ,
131129 error_callback = task_failed (analyser .category ))
132130 for analyser in analysers if analyser .accepts (path )]
133131
0 commit comments