Commit 13791679 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent a3a05334
...@@ -36,6 +36,7 @@ from glob import glob ...@@ -36,6 +36,7 @@ from glob import glob
from collections import namedtuple from collections import namedtuple
from urllib.parse import unquote from urllib.parse import unquote
import email.parser import email.parser
import zipfile
# PkgInfo represents information about a package # PkgInfo represents information about a package
...@@ -86,14 +87,16 @@ def bom_software(installed_software_path): # -> {} (name,kind) -> PkgInfo ...@@ -86,14 +87,16 @@ def bom_software(installed_software_path): # -> {} (name,kind) -> PkgInfo
url = 'https://pypi.org/project/%s/%s/' % (name, v) url = 'https://pypi.org/project/%s/%s/' % (name, v)
if isdir(urlpath): if isdir(urlpath):
with open('%s/EGG-INFO/PKG-INFO' % urlpath) as f: with open('%s/EGG-INFO/PKG-INFO' % urlpath, 'rb') as f:
p = email.parser.Parser() pkginfo = f.read()
meta = p.parse(f, headersonly=True)
license = meta['license']
else: else:
# TODO unzip (e.g. setuptools) # unzip (e.g. setuptools)
pass 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: else:
raise NotImplementedError('TODO url for kind %r (urlpath: %r)' % (kind, urlpath)) 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