Skip to content

OutputHTML: Fix License Reference Table content #4474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The following organizations or individuals have contributed to ScanCode:
- Horie Issei @is2ei
- James Ward @jamesward
- Jelmer Vernooij @jelmer
- Jens Keim @pepper-jk
- Kunal Chhabra @kunalchhabra37
- Jillian Daguil @jdaguil
- Jiri Popelka @jpopelka
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

- Fix License Reference table in HTML Output by reverting to the
behavior of v32.0.0.
See https://github.com/aboutcode-org/scancode-toolkit/issues/4101

- We now support new package manifest formats:

- OpenWRT packages.
Expand Down
12 changes: 12 additions & 0 deletions src/formattedcode/output_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,13 @@ def generate_output(results, license_references, version, template):
"""
# FIXME: This code is highly coupled with actual scans and may not
# support adding new scans at all

from licensedcode.cache import get_licenses_db

converted = {}
converted_infos = {}
converted_packages = {}
licenses = {}

LICENSES = 'license_detections'
COPYRIGHTS = 'copyrights'
Expand Down Expand Up @@ -223,6 +227,11 @@ def generate_output(results, license_references, version, template):
'value': license_expression,
})

if license_expression not in licenses:
license_object = get_licenses_db().get(license_expression)
if license_object != None:
licenses[license_expression] = license_object

if results:
converted[path] = sorted(results, key=itemgetter('start'))

Expand All @@ -239,6 +248,9 @@ def generate_output(results, license_references, version, template):
if PACKAGES in scanned_file:
converted_packages[path] = scanned_file[PACKAGES]

licenses = dict(sorted(licenses.items()))
license_references = list(licenses.values())

files = {
'license_copyright': converted,
'infos': converted_infos,
Expand Down
Loading