Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions src/licensedcode/plugin_license.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ class LicenseScanner(ScanPlugin):

resource_attributes = dict([
('licenses', attr.ib(default=attr.Factory(list))),
('unknown_licenses', attr.ib(default=attr.Factory(list))),
('license_expressions', attr.ib(default=attr.Factory(list))),
('unknown_license_expressions', attr.ib(default=attr.Factory(list))),
('spdx_license_expressions', attr.ib(default=attr.Factory(list))),
Comment thread
akugarg marked this conversation as resolved.
Outdated
('percentage_of_license_text', attr.ib(default=0)),
])

Expand Down
24 changes: 17 additions & 7 deletions src/scancode/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ def get_licenses(location, min_score=0,

detected_licenses = []
detected_expressions = []

unknown_expressions = []
unknown_licenses=[]
Comment thread
akugarg marked this conversation as resolved.
matches = idx.match(
location=location, min_score=min_score, deadline=deadline, **kwargs)

Expand All @@ -180,16 +181,23 @@ def get_licenses(location, min_score=0,
for match in matches:
qspans.append(match.qspan)

detected_expressions.append(match.rule.license_expression)

detected_licenses.extend(
_licenses_data_from_match(
if "unknown" in match.rule.license_expression: # TODO: use is_unknwon flag instead
unknown_expressions.append(match.rule.license_expression)
unknown_licenses.extend(_licenses_data_from_match(
match=match,
Comment thread
akugarg marked this conversation as resolved.
include_text=include_text,
license_text_diagnostics=license_text_diagnostics,
license_url_template=license_url_template))
else:
detected_expressions.append(match.rule.license_expression)
detected_licenses.extend(
_licenses_data_from_match(
match=match,
include_text=include_text,
license_text_diagnostics=license_text_diagnostics,
license_url_template=license_url_template)
)

)
Comment thread
akugarg marked this conversation as resolved.
percentage_of_license_text = 0
if match:
# we need at least one match to compute a license_coverage
Expand All @@ -200,7 +208,9 @@ def get_licenses(location, min_score=0,
detected_spdx_expressions = []
return dict([
('licenses', detected_licenses),
('unknown_licenses', unknown_licenses),
Comment thread
akugarg marked this conversation as resolved.
Outdated
('license_expressions', detected_expressions),
('unknown_license_expressions', unknown_expressions),
('spdx_license_expressions', detected_spdx_expressions),
('percentage_of_license_text', percentage_of_license_text),
])
Expand Down