From 6f2a5e187baf515adaa6bab1b95a5de215460222 Mon Sep 17 00:00:00 2001 From: Angelo D <43831545+AngeloD2022@users.noreply.github.com> Date: Mon, 4 Dec 2023 10:06:47 -0500 Subject: [PATCH] Created an HTML table-based "package releases" view. (#157) * Created an HTML table-based "package releases" view. * Adapted test to prior changes. --- inspector/main.py | 14 +++++----- inspector/static/style.css | 10 +++++++ inspector/templates/releases.html | 45 +++++++++++++++++++++++++++++++ tests/test_main.py | 4 +-- 4 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 inspector/templates/releases.html 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 %} + +Version | +Upload Timestamp | +Artifacts | +|||
---|---|---|---|---|---|
{{ key }} | +{{ value[0]['upload_time'] }} | +{{ value|length }} | + {% else %} +{{ key }} | +Not Available | +Not Available | + {% endif %} +