MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / licenses_mapper

Function licenses_mapper

src/packagedcode/npm.py:1642–1661  ·  view source on GitHub ↗

Update package licensing and return package based on the `license` and `licenses` values found in a package. Licensing data structure has evolved over time and is a tad messy. https://docs.npmjs.com/files/package.json#license license(s) is either: - a string with: - an

(license, licenses, package)

Source from the content-addressed store, hash-verified

1640
1641
1642def licenses_mapper(license, licenses, package): # NOQA
1643 """
1644 Update package licensing and return package based on the `license` and
1645 `licenses` values found in a package.
1646
1647 Licensing data structure has evolved over time and is a tad messy.
1648 https://docs.npmjs.com/files/package.json#license
1649 license(s) is either:
1650 - a string with:
1651 - an SPDX id or expression { "license" : "(ISC OR GPL-3.0)" }
1652 - some license name or id
1653 - "SEE LICENSE IN <filename>"
1654 - (Deprecated) an array or a list of arrays of type, url.
1655 - "license": "UNLICENSED" means this is proprietary
1656 """
1657 declared_license = get_declared_licenses(license) or []
1658 declared_license.extend(get_declared_licenses(licenses) or [])
1659 if declared_license:
1660 package.extracted_license_statement = declared_license
1661 return package
1662
1663
1664def party_mapper(party, package, party_type):

Callers 1

_parseMethod · 0.70

Calls 1

get_declared_licensesFunction · 0.85

Tested by

no test coverage detected