24
24
25
25
import json
26
26
from pathlib import Path
27
- from typing import List , TypedDict
27
+ from typing import List , Optional , TypedDict
28
28
29
29
import importlib_resources
30
30
from jsonschema import validate
31
31
32
32
from .scanossbase import ScanossBase
33
- from .utils .file import JSON_ERROR_FILE_NOT_FOUND , JSON_ERROR_FILE_EMPTY , validate_json_file
33
+ from .utils .file import (
34
+ JSON_ERROR_FILE_EMPTY ,
35
+ JSON_ERROR_FILE_NOT_FOUND ,
36
+ validate_json_file ,
37
+ )
34
38
35
39
DEFAULT_SCANOSS_JSON_FILE = Path ('scanoss.json' )
36
40
@@ -96,12 +100,13 @@ def __init__(
96
100
if filepath :
97
101
self .load_json_file (filepath )
98
102
99
- def load_json_file (self , filepath : ' str | None' = None , scan_root : ' str | None' = None ) -> 'ScanossSettings' :
103
+ def load_json_file (self , filepath : Optional [ str ] = None , scan_root : Optional [ str ] = None ) -> 'ScanossSettings' :
100
104
"""
101
105
Load the scan settings file. If no filepath is provided, scanoss.json will be used as default.
102
106
103
107
Args:
104
108
filepath (str): Path to the SCANOSS settings file
109
+ scan_root (str): Path to the scan root directory
105
110
"""
106
111
107
112
if not filepath :
@@ -118,7 +123,7 @@ def load_json_file(self, filepath: 'str | None' = None, scan_root: 'str | None'
118
123
119
124
result = validate_json_file (json_file )
120
125
if not result .is_valid :
121
- if result .error_code == JSON_ERROR_FILE_NOT_FOUND or result . error_code == JSON_ERROR_FILE_EMPTY :
126
+ if result .error_code in ( JSON_ERROR_FILE_NOT_FOUND , JSON_ERROR_FILE_EMPTY ) :
122
127
self .print_msg (
123
128
f'WARNING: The supplied settings file "{ filepath } " was not found or is empty. Skipping...'
124
129
)
@@ -235,7 +240,7 @@ def _get_sbom_assets(self):
235
240
include_bom_entries = self ._remove_duplicates (self .normalize_bom_entries (self .get_bom_include ()))
236
241
replace_bom_entries = self ._remove_duplicates (self .normalize_bom_entries (self .get_bom_replace ()))
237
242
self .print_debug (
238
- f"Scan type set to 'identify'. Adding { len (include_bom_entries ) + len (replace_bom_entries )} components as context to the scan. \n "
243
+ f"Scan type set to 'identify'. Adding { len (include_bom_entries ) + len (replace_bom_entries )} components as context to the scan. \n " # noqa: E501
239
244
f'From Include list: { [entry ["purl" ] for entry in include_bom_entries ]} \n '
240
245
f'From Replace list: { [entry ["purl" ] for entry in replace_bom_entries ]} \n '
241
246
)
0 commit comments