Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 14 additions & 19 deletions src/python_inspector/package_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@

from packageurl import PackageURL

from _packagedcode import models
from _packagedcode.models import PackageData
from _packagedcode.pypi import get_declared_license
from _packagedcode.pypi import get_keywords
from _packagedcode.pypi import get_parties
from python_inspector import utils_pypi
from python_inspector.resolution import get_python_version_from_env_tag
from python_inspector.utils_pypi import Environment
Expand Down Expand Up @@ -96,7 +98,6 @@ def get_pypi_data_from_purl(
return []
info = response.get("info") or {}
homepage_url = info.get("home_page")
license = info.get("license")
project_urls = info.get("project_urls") or {}
code_view_url = get_pypi_codeview_url(project_urls)
bug_tracking_url = get_pypi_bugtracker_url(project_urls)
Expand Down Expand Up @@ -125,33 +126,27 @@ def get_pypi_data_from_purl(
if dist_url not in valid_distribution_urls:
continue
digests = url.get("digests") or {}

yield PackageData(
primary_language="Python",
description=info.get("description"),
description=info.get("summary") or info.get("description"),
homepage_url=homepage_url,
api_data_url=api_url,
bug_tracking_url=bug_tracking_url,
code_view_url=code_view_url,
declared_license=license,
declared_license=get_declared_license(info),
download_url=dist_url,
size=url.get("size"),
md5=digests.get("md5") or url.get("md5_digest"),
sha256=digests.get("sha256"),
release_date=url.get("upload_time"),
keywords=info.get("keywords") or [],
parties=[
models.Party(
type=models.party_person,
name=info.get("author"),
role="author",
email=info.get("author_email"),
),
models.Party(
type=models.party_person,
name=info.get("maintainer"),
role="maintainer",
email=info.get("maintainer_email"),
),
],
keywords=get_keywords(info),
parties=get_parties(
info,
author_key="author",
author_email_key="author_email",
maintainer_key="maintainer",
maintainer_email_key="maintainer_email",
),
**purl.to_dict(),
).to_dict()
1,143 changes: 817 additions & 326 deletions tests/data/azure-devops.req-310-expected.json

Large diffs are not rendered by default.

1,143 changes: 817 additions & 326 deletions tests/data/azure-devops.req-38-expected.json

Large diffs are not rendered by default.

266 changes: 208 additions & 58 deletions tests/data/environment-marker-test-requirements.txt-expected.json

Large diffs are not rendered by default.

4,618 changes: 3,314 additions & 1,304 deletions tests/data/frozen-requirements.txt-expected.json

Large diffs are not rendered by default.

3,924 changes: 2,795 additions & 1,129 deletions tests/data/insecure-setup-2/setup.py-expected.json

Large diffs are not rendered by default.

186 changes: 126 additions & 60 deletions tests/data/insecure-setup/setup.py-expected.json

Large diffs are not rendered by default.

266 changes: 208 additions & 58 deletions tests/data/pdt-requirements.txt-expected.json

Large diffs are not rendered by default.

2,064 changes: 1,444 additions & 620 deletions tests/data/pinned-pdt-requirements.txt-expected.json

Large diffs are not rendered by default.

2,064 changes: 1,444 additions & 620 deletions tests/data/pinned-requirements.txt-expected.json

Large diffs are not rendered by default.

136 changes: 96 additions & 40 deletions tests/data/setup/simple-setup.py-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"qualifiers": {},
"subpath": null,
"primary_language": "Python",
"description": "\n\nThis library helps you deal with boolean expressions and algebra with variables\nand the boolean functions AND, OR, NOT.\n\nYou can parse expressions from strings and simplify and compare expressions.\nYou can also easily create your custom algreba and mini DSL and create custom\ntokenizers to handle custom expressions.\n\nFor extensive documentation look either into the docs directory or view it online, at\nhttps://booleanpy.readthedocs.org/en/latest/\n\nhttps://github.com/bastikr/boolean.py\n\nCopyright (c) 2009-2020 Sebastian Kraemer, [email protected] and others\nSPDX-License-Identifier: BSD-2-Clause\n\n\n",
"description": "Define boolean algebras, create and parse boolean expressions and create custom boolean DSL.",
"release_date": "2020-06-10T22:06:05",
"parties": [
{
Expand All @@ -107,16 +107,24 @@
"name": "Sebastian Kraemer",
"email": "[email protected]",
"url": null
},
{
"type": "person",
"role": "maintainer",
"name": "",
"email": "",
"url": null
}
],
"keywords": "boolean expression,boolean algebra,logic,expression parser",
"keywords": [
"boolean expression",
"boolean algebra",
"logic",
"expression parser",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Software Development :: Compilers",
"Topic :: Software Development :: Libraries",
"Topic :: Utilities"
],
"homepage_url": "https://github.com/bastikr/boolean.py",
"download_url": "https://files.pythonhosted.org/packages/eb/5b/f82983127b1a1a4db83ee290e00a94a2b08c566fa6c58466e82ed7b0a76f/boolean.py-3.8-py2.py3-none-any.whl",
"size": 23771,
Expand All @@ -129,7 +137,9 @@
"vcs_url": null,
"copyright": null,
"license_expression": null,
"declared_license": "BSD-2-Clause",
"declared_license": {
"license": "BSD-2-Clause"
},
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand All @@ -149,7 +159,7 @@
"qualifiers": {},
"subpath": null,
"primary_language": "Python",
"description": "\n\nThis library helps you deal with boolean expressions and algebra with variables\nand the boolean functions AND, OR, NOT.\n\nYou can parse expressions from strings and simplify and compare expressions.\nYou can also easily create your custom algreba and mini DSL and create custom\ntokenizers to handle custom expressions.\n\nFor extensive documentation look either into the docs directory or view it online, at\nhttps://booleanpy.readthedocs.org/en/latest/\n\nhttps://github.com/bastikr/boolean.py\n\nCopyright (c) 2009-2020 Sebastian Kraemer, [email protected] and others\nSPDX-License-Identifier: BSD-2-Clause\n\n\n",
"description": "Define boolean algebras, create and parse boolean expressions and create custom boolean DSL.",
"release_date": "2020-06-10T22:06:07",
"parties": [
{
Expand All @@ -158,16 +168,24 @@
"name": "Sebastian Kraemer",
"email": "[email protected]",
"url": null
},
{
"type": "person",
"role": "maintainer",
"name": "",
"email": "",
"url": null
}
],
"keywords": "boolean expression,boolean algebra,logic,expression parser",
"keywords": [
"boolean expression",
"boolean algebra",
"logic",
"expression parser",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Software Development :: Compilers",
"Topic :: Software Development :: Libraries",
"Topic :: Utilities"
],
"homepage_url": "https://github.com/bastikr/boolean.py",
"download_url": "https://files.pythonhosted.org/packages/a1/eb/b37ef5647243ade8308f7bb46b1a45e6204790c163cbd8cf6df990d5c1c1/boolean.py-3.8.tar.gz",
"size": 32196,
Expand All @@ -180,7 +198,9 @@
"vcs_url": null,
"copyright": null,
"license_expression": null,
"declared_license": "BSD-2-Clause",
"declared_license": {
"license": "BSD-2-Clause"
},
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand All @@ -200,7 +220,7 @@
"qualifiers": {},
"subpath": null,
"primary_language": "Python",
"description": "license-expression is small utility library to parse, compare, simplify and normalize license expressions (such as SPDX license expressions) using boolean logic.\n\n\n",
"description": "license-expression is small utility library to parse, compare, simplify and normalize license expressions (such as SPDX license expressions) using boolean logic.",
"release_date": "2019-10-16T17:48:45",
"parties": [
{
Expand All @@ -209,16 +229,29 @@
"name": "nexB Inc.",
"email": "[email protected]",
"url": null
},
{
"type": "person",
"role": "maintainer",
"name": "",
"email": "",
"url": null
}
],
"keywords": "license,spdx,license expression,open source,boolean,parse expression,normalize expression,compare expression,licence",
"keywords": [
"license",
"spdx",
"license expression",
"open source",
"boolean",
"parse expression",
"normalize expression",
"compare expression",
"licence",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Topic :: Utilities"
],
"homepage_url": "https://github.com/nexB/license-expression",
"download_url": "https://files.pythonhosted.org/packages/12/7a/dd02b8ac8f0cd81557012b8f249ba4d0d32fe8f98e8d951ebc882187fd92/license_expression-1.0-py2.py3-none-any.whl",
"size": 20066,
Expand All @@ -231,7 +264,12 @@
"vcs_url": null,
"copyright": null,
"license_expression": null,
"declared_license": "apache-2.0",
"declared_license": {
"license": "apache-2.0",
"classifiers": [
"License :: OSI Approved :: Apache Software License"
]
},
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand All @@ -251,7 +289,7 @@
"qualifiers": {},
"subpath": null,
"primary_language": "Python",
"description": "license-expression is small utility library to parse, compare, simplify and normalize license expressions (such as SPDX license expressions) using boolean logic.\n\n\n",
"description": "license-expression is small utility library to parse, compare, simplify and normalize license expressions (such as SPDX license expressions) using boolean logic.",
"release_date": "2019-10-16T17:48:47",
"parties": [
{
Expand All @@ -260,16 +298,29 @@
"name": "nexB Inc.",
"email": "[email protected]",
"url": null
},
{
"type": "person",
"role": "maintainer",
"name": "",
"email": "",
"url": null
}
],
"keywords": "license,spdx,license expression,open source,boolean,parse expression,normalize expression,compare expression,licence",
"keywords": [
"license",
"spdx",
"license expression",
"open source",
"boolean",
"parse expression",
"normalize expression",
"compare expression",
"licence",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Topic :: Utilities"
],
"homepage_url": "https://github.com/nexB/license-expression",
"download_url": "https://files.pythonhosted.org/packages/27/71/a8d8d78f7866a75f6a940cc53d1557a5edf1ae4a281fe8797cf36077105d/license-expression-1.0.tar.gz",
"size": 53559,
Expand All @@ -282,7 +333,12 @@
"vcs_url": null,
"copyright": null,
"license_expression": null,
"declared_license": "apache-2.0",
"declared_license": {
"license": "apache-2.0",
"classifiers": [
"License :: OSI Approved :: Apache Software License"
]
},
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down
Loading