Skip to content

Commit

Permalink
Create a separate section for unknown licenses
Browse files Browse the repository at this point in the history
Signed-off-by: akugarg <akanksha.garg2k@gmail.com>
  • Loading branch information
akugarg committed Jun 28, 2021
1 parent c8cf696 commit 9222562
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/scancode/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def get_licenses(location, min_score=0,

detected_licenses = []
detected_expressions = []

unknown_licenses=[]
matches = idx.match(
location=location, min_score=min_score, deadline=deadline, **kwargs)

Expand All @@ -181,15 +181,25 @@ def get_licenses(location, min_score=0,
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:
unknown_licenses.extend(_licenses_data_from_match(
match=match,
include_text=include_text,
license_text_diagnostics=license_text_diagnostics,
license_url_template=license_url_template))
else:
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)
)

)
if len(unknown_licenses) != 0:
result={}
result['Unknown_licenses'] = unknown_licenses
detected_licenses.append(result)

percentage_of_license_text = 0
if match:
# we need at least one match to compute a license_coverage
Expand Down

0 comments on commit 9222562

Please sign in to comment.