Commit 13791679 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent a3a05334
......@@ -36,6 +36,7 @@ from glob import glob
from collections import namedtuple
from urllib.parse import unquote
import email.parser
import zipfile
# PkgInfo represents information about a package
......@@ -86,14 +87,16 @@ def bom_software(installed_software_path): # -> {} (name,kind) -> PkgInfo
url = 'https://pypi.org/project/%s/%s/' % (name, v)
if isdir(urlpath):
with open('%s/EGG-INFO/PKG-INFO' % urlpath) as f:
p = email.parser.Parser()
meta = p.parse(f, headersonly=True)
license = meta['license']
with open('%s/EGG-INFO/PKG-INFO' % urlpath, 'rb') as f:
pkginfo = f.read()
else:
# TODO unzip (e.g. setuptools)
pass
# unzip (e.g. setuptools)
with zipfile.ZipFile(urlpath, 'r') as z:
with z.open('EGG-INFO/PKG-INFO') as f:
pkginfo = f.read()
p = email.parser.BytesParser()
meta = p.parsebytes(pkginfo, headersonly=True)
license = meta['license']
else:
raise NotImplementedError('TODO url for kind %r (urlpath: %r)' % (kind, urlpath))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment