License check: improve license detection for DistInfoDistribution packages. (#2054)

This commit is contained in:
Maico Timmerman
2021-05-03 14:54:39 +02:00
committed by GitHub
parent 36ac2b1e52
commit 2b5a704412

View File

@@ -168,12 +168,11 @@ class LicenseCheckView(StaffMemberRequiredMixin, FormView):
def _get_license_for_pkg(self, pkg):
license, url = None, None
try:
pkgs = pkg_resources.require(pkg)
pkg = pkgs[0]
pkg = pkg_resources.get_distribution(pkg)
except:
return None, None
try:
for line in pkg.get_metadata_lines('PKG-INFO'):
for line in pkg.get_metadata_lines(pkg.PKG_INFO):
if ': ' in line:
(k, v) = line.split(': ', 1)
if k == "License":