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

Function get_declared_license

src/packagedcode/pypi.py:1941–1971  ·  view source on GitHub ↗

Return a mapping of declared license information and license file name found in a ``metainfo`` package data mapping.

(metainfo)

Source from the content-addressed store, hash-verified

1939
1940
1941def get_declared_license(metainfo):
1942 """
1943 Return a mapping of declared license information and license file name
1944 found in a ``metainfo`` package data mapping.
1945 """
1946 declared_license = {}
1947 # TODO: We should make the declared license as it is, this should be
1948 # updated in scancode to parse a pure string
1949 lic = get_attribute(metainfo, 'License')
1950 license_file = get_attribute(metainfo, 'License-File')
1951 if not license_file and lic:
1952 if isinstance(lic, dict) and 'file' in lic.keys():
1953 license_file = lic.pop('file')
1954
1955 if lic and not lic == 'UNKNOWN':
1956 if 'text' in lic:
1957 declared_license['license'] = lic.get('text')
1958 else:
1959 declared_license['license'] = lic
1960
1961 license_classifiers, _ = get_classifiers(metainfo)
1962 if license_classifiers:
1963 declared_license['classifiers'] = license_classifiers
1964
1965 if not declared_license:
1966 declared_license = None
1967
1968 if TRACE:
1969 logger_debug(f'declared_license: {declared_license!r}, license_file: {license_file} metainfo: {metainfo!r}')
1970
1971 return declared_license, license_file
1972
1973
1974def get_classifiers(metainfo):

Callers 6

parseMethod · 0.85
parseMethod · 0.85
parseMethod · 0.85
parse_metadataFunction · 0.85
parseMethod · 0.85
parseMethod · 0.85

Calls 6

get_attributeFunction · 0.85
get_classifiersFunction · 0.85
logger_debugFunction · 0.70
getMethod · 0.65
keysMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected