Skip to content

Commit

Permalink
Collect classifiers from metadata.json #1749
Browse files Browse the repository at this point in the history
  * Update test results

Signed-off-by: Jono Yang <jyang@nexb.com>
  • Loading branch information
JonoYang committed Oct 8, 2019
1 parent 86b38ed commit cce5523
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
20 changes: 19 additions & 1 deletion src/packagedcode/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,31 @@ def parse_metadata(location):
infos.get('description')
)

classifiers = infos.get('classifiers')
license_classifiers = []
other_classifiers = []
if classifiers:
for classifier in classifiers:
if classifier.startswith('License'):
license_classifiers.append(classifier)
else:
other_classifiers.append(classifier)

declared_license = OrderedDict()
license = infos.get('license')
if license:
declared_license['license'] = license
if license_classifiers:
declared_license['classifiers'] = license_classifiers

package = PythonPackage(
name=infos.get('name'),
version=infos.get('version'),
description=description or None,
declared_license=infos.get('license') or None,
declared_license=declared_license or None,
homepage_url=homepage_url or None,
parties=parties,
keywords=other_classifiers,
)
return package

Expand Down
11 changes: 10 additions & 1 deletion tests/packagedcode/test_pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,16 @@ def test_parse_metadata(self):
assert 'six' == package.name
assert '1.10.0' == package.version
assert 'Python 2 and 3 compatibility utilities' == package.description
assert 'MIT' in package.declared_license
assert 'MIT' in package.declared_license['license']
assert ['License :: OSI Approved :: MIT License'] == package.declared_license['classifiers']
expected_classifiers = [
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries",
"Topic :: Utilities"
]
assert expected_classifiers == package.keywords
expected = [
OrderedDict([
('type', u'person'), ('role', u'contact'),
Expand Down

0 comments on commit cce5523

Please sign in to comment.