Skip to content

Commit e37fec9

Browse files
committed
cli: Create a LicenseRef in case of a license not known to SPDX
1 parent 92b812c commit e37fec9

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/scancode/cli.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,12 +679,15 @@ def save_results(files_count, scanned_files, format, input, output_file):
679679
if file_licenses:
680680
for file_license in file_licenses:
681681
spdx_id = file_license.get('spdx_license_key')
682-
# TODO: we should create a "LicenseRef:xxx" identifier
683-
# if the license is not known to SPDX
684682
if spdx_id:
685683
spdx_license = License.from_identifier(spdx_id)
686684
file_entry.add_lics(spdx_license)
687685
doc.package.add_lics_from_file(spdx_license)
686+
else:
687+
license_key = 'LicenseRef-' + file_license.get('key')
688+
license_ref = License(file_license.get('short_name'), license_key)
689+
file_entry.add_lics(license_ref)
690+
doc.package.add_lics_from_file(license_ref)
688691

689692
else:
690693
file_entry.add_lics(SPDXNone())

0 commit comments

Comments
 (0)