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

Function get_declared_licenses

src/packagedcode/npm.py:1608–1639  ·  view source on GitHub ↗

Return a list of declared licenses, either strings or dicts.

(license_object)

Source from the content-addressed store, hash-verified

1606
1607
1608def get_declared_licenses(license_object):
1609 """
1610 Return a list of declared licenses, either strings or dicts.
1611 """
1612 if not license_object:
1613 return []
1614
1615 if isinstance(license_object, str):
1616 # current, up to date form
1617 return [license_object]
1618
1619 declared_licenses = []
1620 if isinstance(license_object, dict):
1621 # old, deprecated forms
1622 """
1623 "license": {
1624 "type": "MIT",
1625 "url": "http://github.com/kriskowal/q/raw/master/LICENSE"
1626 }
1627 """
1628 declared_licenses.append(license_object)
1629
1630 elif isinstance(license_object, list):
1631 # old, deprecated forms
1632 """
1633 "licenses": [{"type": "Apache License, Version 2.0",
1634 "url": "http://www.apache.org/licenses/LICENSE-2.0" } ]
1635 or
1636 "licenses": ["MIT"],
1637 """
1638 declared_licenses.extend(license_object)
1639 return declared_licenses
1640
1641
1642def licenses_mapper(license, licenses, package): # NOQA

Callers 1

licenses_mapperFunction · 0.85

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected