Skip to content
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
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ template. Your help and contribution make ScanCode docs better, we love hearing

The ScanCode documentation is hosted at `scancode-toolkit.readthedocs.io <https://scancode-toolkit.readthedocs.io/en/latest/>`_.

If you want to contribute to Scancode Documentation, you'll find `this guide here <https://scancode-toolkit.readthedocs.io/en/latest/contribute/contrib_doc.html>`_ helpful.
If you want to contribute to Scancode Documentation, you'll find `this guide here https://scancode-toolkit.readthedocs.io/en/latest/getting-started/contribute/contributing-docs.html`_ helpful.

Development
===========
Expand Down
23 changes: 22 additions & 1 deletion src/packagedcode/nuget.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,30 @@ def parse(cls, location, package_only=False):
urls = get_urls(name, version)

extracted_license_statement = None
license_file_references = []

# See https://docs.microsoft.com/en-us/nuget/reference/nuspec#license
# This is a SPDX license expression
if 'license' in nuspec:
extracted_license_statement = nuspec.get('license')
license_data = nuspec.get('license')

if isinstance(license_data, dict):
license_type = license_data.get('@type', '')
license_text = license_data.get('#text', '')

if license_type == 'expression':
extracted_license_statement = license_text

elif license_type == 'file':
extracted_license_statement = license_text
license_file_references = [license_text]

elif license_type == 'url':
extracted_license_statement = license_text
else:
extracted_license_statement = str(license_data)
else:
extracted_license_statement = license_data
# Deprecated and not a license expression, just a URL
elif 'licenseUrl' in nuspec:
extracted_license_statement = nuspec.get('licenseUrl')
Expand All @@ -174,6 +194,7 @@ def parse(cls, location, package_only=False):
parties=parties,
dependencies=list(get_dependencies(nuspec)),
extracted_license_statement=extracted_license_statement,
license_file_references=license_file_references,
copyright=nuspec.get('copyright') or None,
vcs_url=vcs_url,
**urls,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": "http://www.apache.org/licenses/LICENSE-2.0.html",
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": "http://www.apache.org/licenses/LICENSE-2.0.html",
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": "http://go.microsoft.com/fwlink/?LinkID=320539",
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": "http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm",
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": "http://go.microsoft.com/fwlink/?LinkId=329770",
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": "https://github.com/twbs/bootstrap/blob/master/LICENSE",
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": "http://jquery.org/license",
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down
10 changes: 10 additions & 0 deletions tests/packagedcode/data/nuget/license_file.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Test.Package</id>
<version>1.0.0</version>
<authors>Tester</authors>
<description>Test package with license file</description>
<license type="file">LICENSE.txt</license>
</metadata>
</package>
35 changes: 35 additions & 0 deletions tests/packagedcode/data/nuget/packages.lock.json.expected
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -78,6 +79,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -166,6 +168,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -452,6 +455,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -540,6 +544,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -606,6 +611,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -683,6 +689,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -749,6 +756,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -815,6 +823,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -892,6 +901,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -969,6 +979,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -1079,6 +1090,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -1189,6 +1201,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -1288,6 +1301,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -1365,6 +1379,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -1419,6 +1434,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -1485,6 +1501,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -1573,6 +1590,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -1627,6 +1645,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -1715,6 +1734,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -1825,6 +1845,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -1879,6 +1900,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -2022,6 +2044,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -2143,6 +2166,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -2231,6 +2255,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -2341,6 +2366,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -2473,6 +2499,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -2550,6 +2577,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -2660,6 +2688,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -2726,6 +2755,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -2780,6 +2810,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -2846,6 +2877,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -2900,6 +2932,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -2954,6 +2987,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down Expand Up @@ -3020,6 +3054,7 @@
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"license_file_references": [],
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down
Loading
Loading