22
22
THE SOFTWARE.
23
23
"""
24
24
25
+ import datetime
25
26
import json
26
27
import os
27
- from pathlib import Path
28
28
import sys
29
- import datetime
29
+ from pathlib import Path
30
30
from typing import Any , Dict , List , Optional
31
- import importlib_resources
32
31
32
+ import importlib_resources
33
33
from progress .bar import Bar
34
34
from progress .spinner import Spinner
35
35
from pypac .parser import PACFile
36
36
37
37
from scanoss .file_filters import FileFilters
38
38
39
- from .scanossapi import ScanossApi
40
- from .cyclonedx import CycloneDx
41
- from .spdxlite import SpdxLite
39
+ from . import __version__
42
40
from .csvoutput import CsvOutput
43
- from .threadedscanning import ThreadedScanning
41
+ from .cyclonedx import CycloneDx
44
42
from .scancodedeps import ScancodeDeps
45
- from .threadeddependencies import ThreadedDependencies , SCOPE
46
- from .scanossgrpc import ScanossGrpc
47
- from .scantype import ScanType
48
- from .scanossbase import ScanossBase
49
43
from .scanoss_settings import ScanossSettings
44
+ from .scanossapi import ScanossApi
45
+ from .scanossbase import ScanossBase
46
+ from .scanossgrpc import ScanossGrpc
50
47
from .scanpostprocessor import ScanPostProcessor
51
- from . import __version__
48
+ from .scantype import ScanType
49
+ from .spdxlite import SpdxLite
50
+ from .threadeddependencies import SCOPE , ThreadedDependencies
51
+ from .threadedscanning import ThreadedScanning
52
52
53
53
FAST_WINNOWING = False
54
54
try :
55
55
from scanoss_winnowing .winnowing import Winnowing
56
56
57
57
FAST_WINNOWING = True
58
- except ModuleNotFoundError or ImportError :
58
+ except ( ModuleNotFoundError , ImportError ) :
59
59
FAST_WINNOWING = False
60
60
from .winnowing import Winnowing
61
61
@@ -284,7 +284,7 @@ def is_dependency_scan(self):
284
284
return True
285
285
return False
286
286
287
- def scan_folder_with_options (
287
+ def scan_folder_with_options ( # noqa: PLR0913
288
288
self ,
289
289
scan_dir : str ,
290
290
deps_file : str = None ,
@@ -332,7 +332,7 @@ def scan_folder_with_options(
332
332
success = False
333
333
return success
334
334
335
- def scan_folder (self , scan_dir : str ) -> bool :
335
+ def scan_folder (self , scan_dir : str ) -> bool : # noqa: PLR0912, PLR0915
336
336
"""
337
337
Scan the specified folder producing fingerprints, send to the SCANOSS API and return results
338
338
@@ -400,7 +400,7 @@ def scan_folder(self, scan_dir: str) -> bool:
400
400
scan_block += wfp
401
401
scan_size = len (scan_block .encode ('utf-8' ))
402
402
wfp_file_count += 1
403
- # If the scan request block (group of WFPs) or larger than the POST size or we have reached the file limit, add it to the queue
403
+ # If the scan request block (group of WFPs) or larger than the POST size or we have reached the file limit, add it to the queue # noqa: E501
404
404
if wfp_file_count > self .post_file_count or scan_size >= self .max_post_size :
405
405
self .threaded_scan .queue_add (scan_block )
406
406
queue_size += 1
@@ -484,7 +484,7 @@ def __finish_scan_threaded(self, file_map: Optional[Dict[Any, Any]] = None) -> b
484
484
self .__log_result (json .dumps (results , indent = 2 , sort_keys = True ))
485
485
elif self .output_format == 'cyclonedx' :
486
486
cdx = CycloneDx (self .debug , self .scan_output )
487
- success = cdx .produce_from_json (results )
487
+ success , _ = cdx .produce_from_json (results )
488
488
elif self .output_format == 'spdxlite' :
489
489
spdxlite = SpdxLite (self .debug , self .scan_output )
490
490
success = spdxlite .produce_from_json (results )
@@ -509,7 +509,7 @@ def _merge_scan_results(
509
509
for response in scan_responses :
510
510
if response is not None :
511
511
if file_map :
512
- response = self ._deobfuscate_filenames (response , file_map )
512
+ response = self ._deobfuscate_filenames (response , file_map ) # noqa: PLW2901
513
513
results .update (response )
514
514
515
515
dep_files = dep_responses .get ('files' , None ) if dep_responses else None
@@ -532,7 +532,7 @@ def _deobfuscate_filenames(self, response: dict, file_map: dict) -> dict:
532
532
deobfuscated [key ] = value
533
533
return deobfuscated
534
534
535
- def scan_file_with_options (
535
+ def scan_file_with_options ( # noqa: PLR0913
536
536
self ,
537
537
file : str ,
538
538
deps_file : str = None ,
@@ -603,7 +603,7 @@ def scan_file(self, file: str) -> bool:
603
603
success = False
604
604
return success
605
605
606
- def scan_files (self , files : []) -> bool :
606
+ def scan_files (self , files : []) -> bool : # noqa: PLR0912, PLR0915
607
607
"""
608
608
Scan the specified list of files, producing fingerprints, send to the SCANOSS API and return results
609
609
Please note that by providing an explicit list you bypass any exclusions that may be defined on the scanner
@@ -657,7 +657,7 @@ def scan_files(self, files: []) -> bool:
657
657
file_count += 1
658
658
if self .threaded_scan :
659
659
wfp_size = len (wfp .encode ('utf-8' ))
660
- # If the WFP is bigger than the max post size and we already have something stored in the scan block, add it to the queue
660
+ # If the WFP is bigger than the max post size and we already have something stored in the scan block, add it to the queue # noqa: E501
661
661
if scan_block != '' and (wfp_size + scan_size ) >= self .max_post_size :
662
662
self .threaded_scan .queue_add (scan_block )
663
663
queue_size += 1
@@ -666,7 +666,7 @@ def scan_files(self, files: []) -> bool:
666
666
scan_block += wfp
667
667
scan_size = len (scan_block .encode ('utf-8' ))
668
668
wfp_file_count += 1
669
- # If the scan request block (group of WFPs) or larger than the POST size or we have reached the file limit, add it to the queue
669
+ # If the scan request block (group of WFPs) or larger than the POST size or we have reached the file limit, add it to the queue # noqa: E501
670
670
if wfp_file_count > self .post_file_count or scan_size >= self .max_post_size :
671
671
self .threaded_scan .queue_add (scan_block )
672
672
queue_size += 1
@@ -755,7 +755,7 @@ def scan_contents(self, filename: str, contents: bytes) -> bool:
755
755
success = False
756
756
return success
757
757
758
- def scan_wfp_file (self , file : str = None ) -> bool :
758
+ def scan_wfp_file (self , file : str = None ) -> bool : # noqa: PLR0912, PLR0915
759
759
"""
760
760
Scan the contents of the specified WFP file (in the current process)
761
761
:param file: Scan the contents of the specified WFP file (in the current process)
0 commit comments