35
35
from scanpipe .models import CodebaseResource
36
36
from scanpipe .models import DiscoveredDependency
37
37
from scanpipe .models import DiscoveredPackage
38
+ from scanpipe .models import DiscoveredLicense
38
39
from scanpipe .pipes import scancode
39
40
from scanpipe .pipes .output import mappings_key_by_fieldname
40
41
@@ -78,10 +79,11 @@ def is_archive(location):
78
79
79
80
def load_inventory_from_toolkit_scan (project , input_location ):
80
81
"""
81
- Create packages, dependencies, and resources loaded from the ScanCode-toolkit scan
82
- results located at ``input_location``.
82
+ Create license detections, packages, dependencies, and resources
83
+ loaded from the ScanCode-toolkit scan results located at ``input_location``.
83
84
"""
84
85
scanned_codebase = scancode .get_virtual_codebase (project , input_location )
86
+ scancode .create_discovered_licenses (project , scanned_codebase )
85
87
scancode .create_discovered_packages (project , scanned_codebase )
86
88
scancode .create_codebase_resources (project , scanned_codebase )
87
89
scancode .create_discovered_dependencies (
@@ -91,9 +93,12 @@ def load_inventory_from_toolkit_scan(project, input_location):
91
93
92
94
def load_inventory_from_scanpipe (project , scan_data ):
93
95
"""
94
- Create packages, dependencies, resources, and relations loaded from a ScanCode.io
95
- JSON output provided as ``scan_data``.
96
+ Create license detections, packages, dependencies, resources, and relations
97
+ loaded from a ScanCode.io JSON output provided as ``scan_data``.
96
98
"""
99
+ for detection_data in scan_data .get ("license_detections" , []):
100
+ pipes .update_or_create_license_detection (project , detection_data )
101
+
97
102
for package_data in scan_data .get ("packages" , []):
98
103
pipes .update_or_create_package (project , package_data )
99
104
@@ -110,12 +115,14 @@ def load_inventory_from_scanpipe(project, scan_data):
110
115
model_to_object_maker_func = {
111
116
DiscoveredPackage : pipes .update_or_create_package ,
112
117
DiscoveredDependency : pipes .update_or_create_dependency ,
118
+ DiscoveredLicense : pipes .update_or_create_license_detection ,
113
119
CodebaseResource : pipes .update_or_create_resource ,
114
120
CodebaseRelation : pipes .get_or_create_relation ,
115
121
}
116
122
117
123
worksheet_name_to_model = {
118
124
"PACKAGES" : DiscoveredPackage ,
125
+ "LICENSE_DETECTIONS" : DiscoveredLicense ,
119
126
"RESOURCES" : CodebaseResource ,
120
127
"DEPENDENCIES" : DiscoveredDependency ,
121
128
"RELATIONS" : CodebaseRelation ,
0 commit comments