Return a mapping of declared license information and license file name found in a ``metainfo`` package data mapping.
(metainfo)
| 1939 | |
| 1940 | |
| 1941 | def 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 | |
| 1974 | def get_classifiers(metainfo): |
no test coverage detected