diff --git a/inspector/main.py b/inspector/main.py index a28d71e..826c691 100755 --- a/inspector/main.py +++ b/inspector/main.py @@ -67,13 +67,15 @@ def versions(project_name): if resp.status_code != 200: return redirect(pypi_project_url, 307) - version_urls = [ - "." + "/" + str(version) - for version in sorted(resp.json()["releases"].keys(), key=parse, reverse=True) - ] + releases = resp.json()["releases"] + sorted_releases = { + version: releases[version] + for version in sorted(releases.keys(), key=parse, reverse=True) + } + return render_template( - "links.html", - links=version_urls, + "releases.html", + releases=sorted_releases, h2=project_name, h2_link=f"/project/{project_name}", h2_paren="View this project on PyPI", diff --git a/inspector/static/style.css b/inspector/static/style.css index 1fd7dad..9d47c87 100644 --- a/inspector/static/style.css +++ b/inspector/static/style.css @@ -14,3 +14,13 @@ display: block; color: red; } + +table, th, td { + border: 1px solid black; + border-collapse: collapse; + padding: 4px; +} + +.no-entries { + color: grey; +} diff --git a/inspector/templates/releases.html b/inspector/templates/releases.html new file mode 100644 index 0000000..fa90ba5 --- /dev/null +++ b/inspector/templates/releases.html @@ -0,0 +1,45 @@ +{% extends 'base.html' %} + +{% block head %} + +{% endblock %} + +{% block body %} +{% if releases|length != 1 %} +

Retrieved {{ releases|length }} versions.

+{% else %} +

Retrieved 1 version.

+{% endif %} + + ++ + + + + + + + + + + +{% for key, value in releases.items() %} + + {% if value|length > 0 %} + + + + {% else %} + + + + {% endif %} + +{% endfor %} + + + +
VersionUpload TimestampArtifacts
{{ key }}{{ value[0]['upload_time'] }}{{ value|length }}{{ key }}Not AvailableNot Available
+ +{% endblock %} diff --git a/tests/test_main.py b/tests/test_main.py index 83fdde5..57ea011 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -20,8 +20,8 @@ def test_versions(monkeypatch): assert get.calls == [pretend.call("https://pypi.org/pypi/foo/json")] assert render_template.calls == [ pretend.call( - "links.html", - links=["./0.5.1e"], + "releases.html", + releases={"0.5.1e": None}, h2="foo", h2_link="/project/foo", h2_paren="View this project on PyPI",