2222 THE SOFTWARE.
2323"""
2424
25+ import datetime
2526import json
2627import os
27- from pathlib import Path
2828import sys
29- import datetime
29+ from pathlib import Path
3030from typing import Any , Dict , List , Optional
31- import importlib_resources
3231
32+ import importlib_resources
3333from progress .bar import Bar
3434from progress .spinner import Spinner
3535from pypac .parser import PACFile
3636
3737from scanoss .file_filters import FileFilters
3838
39- from .scanossapi import ScanossApi
40- from .cyclonedx import CycloneDx
41- from .spdxlite import SpdxLite
39+ from . import __version__
4240from .csvoutput import CsvOutput
43- from .threadedscanning import ThreadedScanning
41+ from .cyclonedx import CycloneDx
4442from .scancodedeps import ScancodeDeps
45- from .threadeddependencies import ThreadedDependencies , SCOPE
46- from .scanossgrpc import ScanossGrpc
47- from .scantype import ScanType
48- from .scanossbase import ScanossBase
4943from .scanoss_settings import ScanossSettings
44+ from .scanossapi import ScanossApi
45+ from .scanossbase import ScanossBase
46+ from .scanossgrpc import ScanossGrpc
5047from .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
5252
5353FAST_WINNOWING = False
5454try :
@@ -69,7 +69,7 @@ class Scanner(ScanossBase):
6969 Handle the scanning of files, snippets and dependencies
7070 """
7171
72- def __init__ ( # noqa: PLR0913, PLR0915
72+ def __init__ ( # noqa: PLR0913, PLR0915
7373 self ,
7474 wfp : str = None ,
7575 scan_output : str = None ,
@@ -159,7 +159,7 @@ def __init__( # noqa: PLR0913, PLR0915
159159 ca_cert = ca_cert ,
160160 pac = pac ,
161161 retry = retry ,
162- req_headers = self .req_headers ,
162+ req_headers = self .req_headers ,
163163 )
164164 sc_deps = ScancodeDeps (debug = debug , quiet = quiet , trace = trace , timeout = sc_timeout , sc_command = sc_command )
165165 grpc_api = ScanossGrpc (
@@ -286,7 +286,7 @@ def is_dependency_scan(self):
286286 return True
287287 return False
288288
289- def scan_folder_with_options (
289+ def scan_folder_with_options ( # noqa: PLR0913
290290 self ,
291291 scan_dir : str ,
292292 deps_file : str = None ,
@@ -334,7 +334,7 @@ def scan_folder_with_options(
334334 success = False
335335 return success
336336
337- def scan_folder (self , scan_dir : str ) -> bool :
337+ def scan_folder (self , scan_dir : str ) -> bool : # noqa: PLR0912, PLR0915
338338 """
339339 Scan the specified folder producing fingerprints, send to the SCANOSS API and return results
340340
@@ -402,7 +402,7 @@ def scan_folder(self, scan_dir: str) -> bool:
402402 scan_block += wfp
403403 scan_size = len (scan_block .encode ('utf-8' ))
404404 wfp_file_count += 1
405- # 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
405+ # 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
406406 if wfp_file_count > self .post_file_count or scan_size >= self .max_post_size :
407407 self .threaded_scan .queue_add (scan_block )
408408 queue_size += 1
@@ -511,7 +511,7 @@ def _merge_scan_results(
511511 for response in scan_responses :
512512 if response is not None :
513513 if file_map :
514- response = self ._deobfuscate_filenames (response , file_map )
514+ response = self ._deobfuscate_filenames (response , file_map ) # noqa: PLW2901
515515 results .update (response )
516516
517517 dep_files = dep_responses .get ('files' , None ) if dep_responses else None
@@ -534,7 +534,7 @@ def _deobfuscate_filenames(self, response: dict, file_map: dict) -> dict:
534534 deobfuscated [key ] = value
535535 return deobfuscated
536536
537- def scan_file_with_options (
537+ def scan_file_with_options ( # noqa: PLR0913
538538 self ,
539539 file : str ,
540540 deps_file : str = None ,
@@ -605,7 +605,7 @@ def scan_file(self, file: str) -> bool:
605605 success = False
606606 return success
607607
608- def scan_files (self , files : []) -> bool :
608+ def scan_files (self , files : []) -> bool : # noqa: PLR0912, PLR0915
609609 """
610610 Scan the specified list of files, producing fingerprints, send to the SCANOSS API and return results
611611 Please note that by providing an explicit list you bypass any exclusions that may be defined on the scanner
@@ -659,7 +659,7 @@ def scan_files(self, files: []) -> bool:
659659 file_count += 1
660660 if self .threaded_scan :
661661 wfp_size = len (wfp .encode ('utf-8' ))
662- # 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
662+ # 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
663663 if scan_block != '' and (wfp_size + scan_size ) >= self .max_post_size :
664664 self .threaded_scan .queue_add (scan_block )
665665 queue_size += 1
@@ -668,7 +668,7 @@ def scan_files(self, files: []) -> bool:
668668 scan_block += wfp
669669 scan_size = len (scan_block .encode ('utf-8' ))
670670 wfp_file_count += 1
671- # 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
671+ # 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
672672 if wfp_file_count > self .post_file_count or scan_size >= self .max_post_size :
673673 self .threaded_scan .queue_add (scan_block )
674674 queue_size += 1
@@ -677,9 +677,7 @@ def scan_files(self, files: []) -> bool:
677677 if not scan_started and queue_size > self .nb_threads : # Start scanning if we have something to do
678678 scan_started = True
679679 if not self .threaded_scan .run (wait = False ):
680- self .print_stderr (
681- 'Warning: Some errors encounted while scanning. Results might be incomplete.'
682- )
680+ self .print_stderr ('Warning: Some errors encounted while scanning. Results might be incomplete.' )
683681 success = False
684682
685683 # End for loop
@@ -757,7 +755,7 @@ def scan_contents(self, filename: str, contents: bytes) -> bool:
757755 success = False
758756 return success
759757
760- def scan_wfp_file (self , file : str = None ) -> bool :
758+ def scan_wfp_file (self , file : str = None ) -> bool : # noqa: PLR0912, PLR0915
761759 """
762760 Scan the contents of the specified WFP file (in the current process)
763761 :param file: Scan the contents of the specified WFP file (in the current process)
0 commit comments