This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git
The following commit(s) were added to refs/heads/main by this push:
new e261452 Ensure that all uses of htpy are through the htm module
e261452 is described below
commit e261452c3d54305a430998c32627ac01b5c583d8
Author: Sean B. Palmer <[email protected]>
AuthorDate: Mon Oct 27 16:21:03 2025 +0000
Ensure that all uses of htpy are through the htm module
---
atr/forms.py | 51 +++++++++++++++++++++++-----------------------
atr/get/distribution.py | 16 +++++++--------
atr/htm.py | 28 +++++++++++++++++++++++++
atr/routes/ignores.py | 46 +++++++++++++++++------------------------
atr/routes/root.py | 38 ++++++++++++++++------------------
atr/routes/sbom.py | 49 ++++++++++++++++++++++----------------------
atr/routes/user.py | 13 ++++++------
atr/shared/distribution.py | 31 ++++++++++++++--------------
atr/template.py | 5 +++--
9 files changed, 146 insertions(+), 131 deletions(-)
diff --git a/atr/forms.py b/atr/forms.py
index 439eded..bd0f3fe 100644
--- a/atr/forms.py
+++ b/atr/forms.py
@@ -21,12 +21,13 @@ import dataclasses
import enum
from typing import TYPE_CHECKING, Any, Final, Literal, TypeVar
-import htpy
import markupsafe
import quart_wtf
import quart_wtf.typing
import wtforms
+import atr.htm as htm
+
if TYPE_CHECKING:
from collections.abc import Callable
@@ -277,7 +278,7 @@ def render_columns(
form_classes: str = ".atr-canary",
submit_classes: str = "btn-primary",
descriptions: bool = False,
-) -> htpy.Element:
+) -> htm.Element:
label_classes = "col-sm-3 col-form-label text-sm-end"
elements = _render_elements(
form,
@@ -286,20 +287,20 @@ def render_columns(
descriptions=descriptions,
)
- field_rows: list[htpy.Element] = []
+ field_rows: list[htm.Element] = []
for label, widget in elements.fields:
- row_div = htpy.div(".mb-3.row")
- widget_div = htpy.div(".col-sm-8")
+ row_div = htm.div(".mb-3.row")
+ widget_div = htm.div(".col-sm-8")
field_rows.append(row_div[label, widget_div[widget]])
- form_children: list[htpy.Element | markupsafe.Markup] = elements.hidden +
field_rows
+ form_children: list[htm.Element | markupsafe.Markup] = elements.hidden +
field_rows
if elements.submit is not None:
- submit_div = htpy.div(".col-sm-9.offset-sm-3")
- submit_row = htpy.div(".row")[submit_div[elements.submit]]
+ submit_div = htm.div(".col-sm-9.offset-sm-3")
+ submit_row = htm.div(".row")[submit_div[elements.submit]]
form_children.append(submit_row)
- return htpy.form(form_classes, action=action, method="post")[form_children]
+ return htm.form(form_classes, action=action, method="post")[form_children]
def render_simple(
@@ -308,23 +309,23 @@ def render_simple(
form_classes: str = "",
submit_classes: str = "btn-primary",
descriptions: bool = False,
-) -> htpy.Element:
+) -> htm.Element:
elements = _render_elements(form, submit_classes=submit_classes,
descriptions=descriptions)
- field_rows: list[htpy.Element] = []
+ field_rows: list[htm.Element] = []
for label, widget in elements.fields:
- row_div = htpy.div[label, widget]
+ row_div = htm.div[label, widget]
field_rows.append(row_div)
- form_children: list[htpy.Element | markupsafe.Markup] = []
+ form_children: list[htm.Element | markupsafe.Markup] = []
form_children.extend(elements.hidden)
- form_children.append(htpy.div[field_rows])
+ form_children.append(htm.div[field_rows])
if elements.submit is not None:
- submit_row = htpy.p[elements.submit]
+ submit_row = htm.p[elements.submit]
form_children.append(submit_row)
- return htpy.form(form_classes, action=action, method="post")[form_children]
+ return htm.form(form_classes, action=action, method="post")[form_children]
def render_table(
@@ -334,24 +335,24 @@ def render_table(
table_classes: str = ".table.table-striped.table-bordered",
submit_classes: str = "btn-primary",
descriptions: bool = False,
-) -> htpy.Element:
+) -> htm.Element:
# Small elements in Bootstrap
elements = _render_elements(form, submit_classes=submit_classes,
small=True, descriptions=descriptions)
- field_rows: list[htpy.Element] = []
+ field_rows: list[htm.Element] = []
for label, widget in elements.fields:
- row_tr = htpy.tr[htpy.th[label], htpy.td[widget]]
+ row_tr = htm.tr[htm.th[label], htm.td[widget]]
field_rows.append(row_tr)
- form_children: list[htpy.Element | markupsafe.Markup] = []
+ form_children: list[htm.Element | markupsafe.Markup] = []
form_children.extend(elements.hidden)
- form_children.append(htpy.table(table_classes)[htpy.tbody[field_rows]])
+ form_children.append(htm.table(table_classes)[htm.tbody[field_rows]])
if elements.submit is not None:
- submit_row = htpy.p[elements.submit]
+ submit_row = htm.p[elements.submit]
form_children.append(submit_row)
- return htpy.form(form_classes, action=action, method="post")[form_children]
+ return htm.form(form_classes, action=action, method="post")[form_children]
def select(
@@ -469,11 +470,11 @@ def _render_elements(
if field.errors:
joined_errors = " ".join(field.errors)
- div = htpy.div(".invalid-feedback.d-block")[joined_errors]
+ div = htm.div(".invalid-feedback.d-block")[joined_errors]
widget += markupsafe.Markup(str(div))
if descriptions is True and field.description:
- desc =
htpy.div(".form-text.text-muted")[str(field.description)]
+ desc = htm.div(".form-text.text-muted")[str(field.description)]
widget += markupsafe.Markup(str(desc))
field_elements.append((label, widget))
diff --git a/atr/get/distribution.py b/atr/get/distribution.py
index 80738a2..aacd13d 100644
--- a/atr/get/distribution.py
+++ b/atr/get/distribution.py
@@ -17,8 +17,6 @@
from __future__ import annotations
-import htpy
-
import atr.blueprints.get as get
import atr.db as db
import atr.forms as forms
@@ -44,7 +42,7 @@ async def list_get(session: web.Committer, project: str,
version: str) -> str:
staging = release.phase == sql.ReleasePhase.RELEASE_CANDIDATE_DRAFT
shared.distribution.html_nav_phase(block, project, version, staging)
- record_a_distribution = htpy.a(
+ record_a_distribution = htm.a(
".btn.btn-primary",
href=util.as_url(
stage if staging else record,
@@ -54,7 +52,7 @@ async def list_get(session: web.Committer, project: str,
version: str) -> str:
)["Record a distribution"]
# Distribution list for project-version
- block.h1["Distribution list for ", htpy.em[f"{project}-{version}"]]
+ block.h1["Distribution list for ", htm.em[f"{project}-{version}"]]
if not distributions:
block.p["No distributions found."]
block.p[record_a_distribution]
@@ -65,9 +63,9 @@ async def list_get(session: web.Committer, project: str,
version: str) -> str:
block.p["Here are all of the distributions recorded for this release."]
block.p[record_a_distribution]
# Table of contents
- ul_toc = htm.Block(htpy.ul)
+ ul_toc = htm.Block(htm.ul)
for dist in distributions:
- a = htpy.a(href=f"#distribution-{dist.identifier}")[dist.title]
+ a = htm.a(href=f"#distribution-{dist.identifier}")[dist.title]
ul_toc.li[a]
block.append(ul_toc)
@@ -87,10 +85,10 @@ async def list_get(session: web.Committer, project: str,
version: str) -> str:
### Platform package version
block.h3(
# Cannot use "#id" here, because the ID contains "."
- # If an ID contains ".", htpy parses that as a class
+ # If an ID contains ".", htm parses that as a class
id=f"distribution-{dist.identifier}"
)[dist.title]
- tbody = htpy.tbody[
+ tbody = htm.tbody[
shared.distribution.html_tr("Release name", dist.release_name),
shared.distribution.html_tr("Platform", dist.platform.value.name),
shared.distribution.html_tr("Owner or Namespace",
dist.owner_namespace or "-"),
@@ -108,7 +106,7 @@ async def list_get(session: web.Committer, project: str,
version: str) -> str:
action=form_action,
submit_classes="btn-danger",
)
- block.append(htpy.div(".mb-3")[delete_form_element])
+ block.append(htm.div(".mb-3")[delete_form_element])
title = f"Distribution list for {project} {version}"
return await template.blank(title, content=block.collect())
diff --git a/atr/htm.py b/atr/htm.py
index a6d0513..ca35ce1 100644
--- a/atr/htm.py
+++ b/atr/htm.py
@@ -166,3 +166,31 @@ class Block:
@property
def ul(self) -> BlockElementCallable:
return BlockElementCallable(self, htpy.ul)
+
+
+type Element = htpy.Element
+
+a = htpy.a
+button = htpy.button
+code = htpy.code
+details = htpy.details
+div = htpy.div
+em = htpy.em
+form = htpy.form
+h1 = htpy.h1
+h2 = htpy.h2
+h3 = htpy.h3
+li = htpy.li
+p = htpy.p
+pre = htpy.pre
+script = htpy.script
+span = htpy.span
+strong = htpy.strong
+summary = htpy.summary
+table = htpy.table
+tbody = htpy.tbody
+td = htpy.td
+th = htpy.th
+thead = htpy.thead
+tr = htpy.tr
+ul = htpy.ul
diff --git a/atr/routes/ignores.py b/atr/routes/ignores.py
index 8bd1c20..4240e92 100644
--- a/atr/routes/ignores.py
+++ b/atr/routes/ignores.py
@@ -17,21 +17,13 @@
from typing import Final
-import htpy
import markupsafe
import quart
import werkzeug.wrappers.response as response
import wtforms
-from htpy import (
- div,
- h1,
- h2,
- h3,
- p,
- script,
-)
import atr.forms as forms
+import atr.htm as htm
import atr.models.sql as sql
import atr.route as route
import atr.storage as storage
@@ -110,9 +102,9 @@ async def ignores(session: route.CommitterSession,
committee_name: str) -> str |
ragp = read.as_general_public()
ignores = await ragp.checks.ignores(committee_name)
- content = div[
- h1["Ignored checks"],
- p[f"Manage ignored checks for committee {committee_name}."],
+ content = htm.div[
+ htm.h1["Ignored checks"],
+ htm.p[f"Manage ignored checks for committee {committee_name}."],
_add_ignore(committee_name),
_existing_ignores(ignores),
_script_dom_loaded(_UPDATE_IGNORE_FORM),
@@ -215,11 +207,11 @@ async def ignores_committee_update(session:
route.CommitterSession, committee_na
)
-def _check_result_ignore_card(cri: sql.CheckResultIgnore) -> htpy.Element:
+def _check_result_ignore_card(cri: sql.CheckResultIgnore) -> htm.Element:
h3_id = cri.id or ""
h3_asf_uid = cri.asf_uid
h3_created = util.format_datetime(cri.created)
- card_header_h3 = h3(".mt-3.mb-0")[f"{h3_id} - {h3_asf_uid} - {h3_created}"]
+ card_header_h3 = htm.h3(".mt-3.mb-0")[f"{h3_id} - {h3_asf_uid} -
{h3_created}"]
form_update = UpdateIgnoreForm(id=cri.id)
@@ -247,34 +239,34 @@ def _check_result_ignore_card(cri: sql.CheckResultIgnore)
-> htpy.Element:
submit_classes="btn-danger",
)
- card = div(".card.mb-5")[
- div(".card-header.d-flex.justify-content-between")[card_header_h3,
form_delete_html],
- div(".card-body")[form_update_html],
+ card = htm.div(".card.mb-5")[
+ htm.div(".card-header.d-flex.justify-content-between")[card_header_h3,
form_delete_html],
+ htm.div(".card-body")[form_update_html],
]
return card
-def _add_ignore(committee_name: str) -> htpy.Element:
+def _add_ignore(committee_name: str) -> htm.Element:
form_path = util.as_url(ignores_committee_add,
committee_name=committee_name)
- return div[
- h2["Add ignore"],
- p["Add a new ignore for a check result."],
+ return htm.div[
+ htm.h2["Add ignore"],
+ htm.p["Add a new ignore for a check result."],
forms.render_columns(AddIgnoreForm(), form_path),
]
-def _existing_ignores(ignores: list[sql.CheckResultIgnore]) -> htpy.Element:
- return div[
- h2["Existing ignores"],
- [_check_result_ignore_card(cri) for cri in ignores] or p["No ignores
found."],
+def _existing_ignores(ignores: list[sql.CheckResultIgnore]) -> htm.Element:
+ return htm.div[
+ htm.h2["Existing ignores"],
+ [_check_result_ignore_card(cri) for cri in ignores] or htm.p["No
ignores found."],
]
-def _script_dom_loaded(text: str) -> htpy.Element:
+def _script_dom_loaded(text: str) -> htm.Element:
script_text = markupsafe.Markup(f"""
document.addEventListener("DOMContentLoaded", function () {{
{text}
}});
""")
- return script[script_text]
+ return htm.script[script_text]
diff --git a/atr/routes/root.py b/atr/routes/root.py
index e5f340d..0645ea7 100644
--- a/atr/routes/root.py
+++ b/atr/routes/root.py
@@ -23,7 +23,6 @@ from typing import Final
import aiofiles
import asfquart.base as base
import asfquart.session
-import htpy
import quart.wrappers.response as quart_response
import sqlalchemy.orm as orm
import sqlmodel
@@ -31,40 +30,39 @@ import werkzeug.wrappers.response as response
import atr.config as config
import atr.db as db
+import atr.htm as htm
import atr.models.sql as sql
import atr.route as route
import atr.template as template
import atr.user as user
import atr.util as util
-_POLICIES: Final = htpy.div[
- htpy.h1["Release policy"],
- htpy.p[
+_POLICIES: Final = htm.div[
+ htm.h1["Release policy"],
+ htm.p[
"""Note that the ATR platform will replace the use
dist.apache.org svn repository where mentioned in
any of the following policies."""
],
- htpy.h2["Standard ASF policies"],
- htpy.ul[
-
htpy.li[htpy.a(href="https://www.apache.org/legal/release-policy.html")["Release
policy"],],
-
htpy.li[htpy.a(href="https://www.apache.org/legal/src-headers.html")["Source
headers"],],
-
htpy.li[htpy.a(href="https://www.apache.org/legal/resolved.html")["Third party
license"],],
-
htpy.li[htpy.a(href="https://www.apache.org/foundation/voting.html")["Voting
process"],],
-
htpy.li[htpy.a(href="https://infra.apache.org/release-publishing.html")["Release
process"],],
+ htm.h2["Standard ASF policies"],
+ htm.ul[
+
htm.li[htm.a(href="https://www.apache.org/legal/release-policy.html")["Release
policy"],],
+
htm.li[htm.a(href="https://www.apache.org/legal/src-headers.html")["Source
headers"],],
+ htm.li[htm.a(href="https://www.apache.org/legal/resolved.html")["Third
party license"],],
+
htm.li[htm.a(href="https://www.apache.org/foundation/voting.html")["Voting
process"],],
+
htm.li[htm.a(href="https://infra.apache.org/release-publishing.html")["Release
process"],],
],
- htpy.h2["Additional incubator policies"],
- htpy.ul[
- htpy.li[
-
htpy.a(href="https://incubator.apache.org/policy/incubation.html#releases")["Incubator
release process"],
+ htm.h2["Additional incubator policies"],
+ htm.ul[
+ htm.li[
+
htm.a(href="https://incubator.apache.org/policy/incubation.html#releases")["Incubator
release process"],
],
- htpy.li[
-
htpy.a(href="https://incubator.apache.org/guides/releasemanagement.html#podling_constraints")[
+ htm.li[
+
htm.a(href="https://incubator.apache.org/guides/releasemanagement.html#podling_constraints")[
"Incubator constraints"
],
],
- htpy.li[
-
htpy.a(href="https://incubator.apache.org/policy/incubation.html#disclaimers")["Incubation
disclaimer"],
- ],
+
htm.li[htm.a(href="https://incubator.apache.org/policy/incubation.html#disclaimers")["Incubation
disclaimer"],],
],
]
diff --git a/atr/routes/sbom.py b/atr/routes/sbom.py
index 4fe1c75..8ae5245 100644
--- a/atr/routes/sbom.py
+++ b/atr/routes/sbom.py
@@ -22,7 +22,6 @@ import pathlib
from typing import TYPE_CHECKING, Any
import asfquart.base as base
-import htpy
import markupsafe
import quart
@@ -138,7 +137,7 @@ async def report(session: route.CommitterSession, project:
str, version: str, fi
informational purposes. Please use it only as an approximate
guideline to the quality of your SBOM file."""
]
- block.p["This report is for revision ",
htpy.code[task_result.revision_number], "."]
+ block.p["This report is for revision ",
htm.code[task_result.revision_number], "."]
empty_form = await forms.Empty.create_form()
# TODO: Show the status if the task to augment the SBOM is still running
@@ -151,9 +150,9 @@ async def report(session: route.CommitterSession, project:
str, version: str, fi
file_path=file_path,
)
block.append(
- htpy.form("", action=action, method="post")[
+ htm.form("", action=action, method="post")[
markupsafe.Markup(str(empty_form.hidden_tag())),
- htpy.button(".btn.btn-primary", type="submit")["Augment SBOM"],
+ htm.button(".btn.btn-primary", type="submit")["Augment SBOM"],
]
)
@@ -262,16 +261,16 @@ def _extract_vulnerability_severity(vuln: dict[str, Any])
-> str:
def _missing_table(block: htm.Block, items:
list[sbom.models.conformance.Missing]) -> None:
warning_rows = [
- htpy.tr[
- htpy.td[kind.upper()],
- htpy.td[prop],
- htpy.td[str(count)],
+ htm.tr[
+ htm.td[kind.upper()],
+ htm.td[prop],
+ htm.td[str(count)],
]
for kind, prop, count in _missing_tally(items)
]
block.table(".table.table-sm.table-bordered.table-striped")[
- htpy.thead[htpy.tr[htpy.th["Kind"], htpy.th["Property"],
htpy.th["Count"]]],
- htpy.tbody[*warning_rows],
+ htm.thead[htm.tr[htm.th["Kind"], htm.th["Property"], htm.th["Count"]]],
+ htm.tbody[*warning_rows],
]
@@ -288,9 +287,9 @@ def _missing_tally(items:
list[sbom.models.conformance.Missing]) -> list[tuple[s
def _vulnerability_component_details(block: htm.Block, component:
results.OSVComponent) -> None:
details_content = []
- summary_element = htpy.summary[
-
htpy.span(".badge.bg-danger.me-2.font-monospace")[str(len(component.vulnerabilities))],
- htpy.strong[component.purl],
+ summary_element = htm.summary[
+
htm.span(".badge.bg-danger.me-2.font-monospace")[str(len(component.vulnerabilities))],
+ htm.strong[component.purl],
]
details_content.append(summary_element)
@@ -300,22 +299,22 @@ def _vulnerability_component_details(block: htm.Block,
component: results.OSVCom
vuln_modified = vuln.get("modified", "Unknown")
vuln_severity = _extract_vulnerability_severity(vuln)
- vuln_header = [htpy.strong(".me-2")[vuln_id]]
+ vuln_header = [htm.strong(".me-2")[vuln_id]]
if vuln_severity != "Unknown":
-
vuln_header.append(htpy.span(".badge.bg-warning.text-dark")[vuln_severity])
+
vuln_header.append(htm.span(".badge.bg-warning.text-dark")[vuln_severity])
- vuln_div =
htpy.div(".ms-3.mb-3.border-start.border-warning.border-3.ps-3")[
- htpy.div(".d-flex.align-items-center.mb-2")[*vuln_header],
- htpy.p(".mb-1")[vuln_summary],
- htpy.div(".text-muted.small")[
+ vuln_div =
htm.div(".ms-3.mb-3.border-start.border-warning.border-3.ps-3")[
+ htm.div(".d-flex.align-items-center.mb-2")[*vuln_header],
+ htm.p(".mb-1")[vuln_summary],
+ htm.div(".text-muted.small")[
"Last modified: ",
vuln_modified,
],
- htpy.div(".mt-2.text-muted")[vuln.get("details", "No additional
details available.")],
+ htm.div(".mt-2.text-muted")[vuln.get("details", "No additional
details available.")],
]
details_content.append(vuln_div)
- block.append(htpy.details(".mb-3.rounded")[*details_content])
+ block.append(htm.details(".mb-3.rounded")[*details_content])
def _vulnerability_scan_button(
@@ -330,9 +329,9 @@ def _vulnerability_scan_button(
file_path=file_path,
)
block.append(
- htpy.form("", action=action, method="post")[
+ htm.form("", action=action, method="post")[
markupsafe.Markup(str(empty_form.hidden_tag())),
- htpy.button(".btn.btn-primary", type="submit")["Scan file"],
+ htm.button(".btn.btn-primary", type="submit")["Scan file"],
]
)
@@ -420,11 +419,11 @@ def _vulnerability_scan_status(
) -> None:
status_text = task.status.value.replace("_", " ").capitalize()
block.p[f"Vulnerability scan is currently {status_text.lower()}."]
- block.p["Task ID: ", htpy.code[str(task.id)]]
+ block.p["Task ID: ", htm.code[str(task.id)]]
if (task.status == sql.TaskStatus.FAILED) and (task.error is not None):
block.p[
"Task reported an error: ",
- htpy.code[task.error],
+ htm.code[task.error],
". Additional details are unavailable from ATR.",
]
_vulnerability_scan_button(block, project, version, file_path,
empty_form)
diff --git a/atr/routes/user.py b/atr/routes/user.py
index 7ae4a47..84476ae 100644
--- a/atr/routes/user.py
+++ b/atr/routes/user.py
@@ -19,7 +19,6 @@ from __future__ import annotations
from typing import TYPE_CHECKING
-import htpy
import quart
import atr.forms as forms
@@ -63,18 +62,18 @@ async def cache_get(session: route.CommitterSession) -> str:
block.h2["Your cached session"]
block.p["Your session is currently cached."]
- tbody = htm.Block(htpy.tbody)
- tbody.append(htpy.tr[htpy.th["User ID"], htpy.td[session.uid]])
+ tbody = htm.Block(htm.tbody)
+ tbody.append(htm.tr[htm.th["User ID"], htm.td[session.uid]])
if "fullname" in cached_entry:
- tbody.append(htpy.tr[htpy.th["Full name"],
htpy.td[cached_entry["fullname"]]])
+ tbody.append(htm.tr[htm.th["Full name"],
htm.td[cached_entry["fullname"]]])
if "email" in cached_entry:
- tbody.append(htpy.tr[htpy.th["Email"],
htpy.td[cached_entry["email"]]])
+ tbody.append(htm.tr[htm.th["Email"],
htm.td[cached_entry["email"]]])
if "pmcs" in cached_entry:
committees = ", ".join(cached_entry["pmcs"]) if
cached_entry["pmcs"] else "-"
- tbody.append(htpy.tr[htpy.th["Committees"], htpy.td[committees]])
+ tbody.append(htm.tr[htm.th["Committees"], htm.td[committees]])
if "projects" in cached_entry:
projects = ", ".join(cached_entry["projects"]) if
cached_entry["projects"] else "-"
- tbody.append(htpy.tr[htpy.th["Projects"], htpy.td[projects]])
+ tbody.append(htm.tr[htm.th["Projects"], htm.td[projects]])
block.table(".table.table-striped.table-bordered")[tbody.collect()]
diff --git a/atr/shared/distribution.py b/atr/shared/distribution.py
index 4266e06..a584195 100644
--- a/atr/shared/distribution.py
+++ b/atr/shared/distribution.py
@@ -21,7 +21,6 @@ import dataclasses
import json
from typing import Literal
-import htpy
import quart
import atr.db as db
@@ -92,9 +91,9 @@ class FormProjectVersion:
# TODO: Move this to an appropriate module
def html_nav(container: htm.Block, back_url: str, back_anchor: str, phase:
Phase) -> None:
classes = ".d-flex.justify-content-between.align-items-center"
- block = htm.Block(htpy.p(classes))
+ block = htm.Block(htm.p(classes))
block.a(".atr-back-link", href=back_url)[f"← Back to {back_anchor}"]
- span = htm.Block(htpy.span)
+ span = htm.Block(htm.span)
def _phase(actual: Phase, expected: Phase) -> None:
nonlocal span
@@ -139,7 +138,7 @@ def html_nav_phase(block: htm.Block, project: str, version:
str, staging: bool)
def html_submitted_values_table(block: htm.Block, dd: distribution.Data) ->
None:
- tbody = htpy.tbody[
+ tbody = htm.tbody[
html_tr("Platform", dd.platform.name),
html_tr("Owner or Namespace", dd.owner_namespace or "-"),
html_tr("Package", dd.package),
@@ -148,18 +147,18 @@ def html_submitted_values_table(block: htm.Block, dd:
distribution.Data) -> None
block.table(".table.table-striped.table-bordered")[tbody]
-def html_tr(label: str, value: str) -> htpy.Element:
- return htpy.tr[htpy.th[label], htpy.td[value]]
+def html_tr(label: str, value: str) -> htm.Element:
+ return htm.tr[htm.th[label], htm.td[value]]
-def html_tr_a(label: str, value: str | None) -> htpy.Element:
- return htpy.tr[htpy.th[label], htpy.td[htpy.a(href=value)[value] if value
else "-"]]
+def html_tr_a(label: str, value: str | None) -> htm.Element:
+ return htm.tr[htm.th[label], htm.td[htm.a(href=value)[value] if value else
"-"]]
# This function is used for COMPOSE (stage) and FINISH (record)
# It's also used whenever there is an error
async def record_form_page(
- fpv: FormProjectVersion, *, extra_content: htpy.Element | None = None,
staging: bool = False
+ fpv: FormProjectVersion, *, extra_content: htm.Element | None = None,
staging: bool = False
) -> str:
await release_validated(fpv.project, fpv.version, staging=staging)
@@ -174,12 +173,12 @@ async def record_form_page(
block.append(extra_content)
block.p[
"Record a distribution of ",
- htpy.strong[f"{fpv.project}-{fpv.version}"],
+ htm.strong[f"{fpv.project}-{fpv.version}"],
" using the form below.",
]
block.p[
"You can also ",
- htpy.a(href=util.as_url(get.distribution.list_get,
project=fpv.project, version=fpv.version))[
+ htm.a(href=util.as_url(get.distribution.list_get, project=fpv.project,
version=fpv.version))[
"view the distribution list"
],
".",
@@ -200,7 +199,7 @@ async def record_form_process_page(fpv: FormProjectVersion,
/, staging: bool = F
# In case of error, show an alert
async def _alert(message: str) -> str:
- div = htm.Block(htpy.div(".alert.alert-danger"))
+ div = htm.Block(htm.div(".alert.alert-danger"))
div.p[message]
collected = div.collect()
return await record_form_page(fpv, extra_content=collected,
staging=staging)
@@ -227,7 +226,7 @@ async def record_form_process_page(fpv: FormProjectVersion,
/, staging: bool = F
else:
block.p["The distribution was already recorded."]
block.table(".table.table-striped.table-bordered")[
- htpy.tbody[
+ htm.tbody[
html_tr("Release name", dist.release_name),
html_tr("Platform", dist.platform.name),
html_tr("Owner or Namespace", dist.owner_namespace or "-"),
@@ -240,7 +239,7 @@ async def record_form_process_page(fpv: FormProjectVersion,
/, staging: bool = F
]
]
block.p[
- htpy.a(href=util.as_url(get.distribution.list_get,
project=fpv.project, version=fpv.version))[
+ htm.a(href=util.as_url(get.distribution.list_get, project=fpv.project,
version=fpv.version))[
"Back to distribution list"
],
]
@@ -264,8 +263,8 @@ async def record_form_process_page(fpv: FormProjectVersion,
/, staging: bool = F
### API response
block.h3["API response"]
block.details[
- htpy.summary["Show full API response"],
- htpy.pre(".atr-pre-wrap.mb-3")[json.dumps(metadata.result,
indent=2)],
+ htm.summary["Show full API response"],
+ htm.pre(".atr-pre-wrap.mb-3")[json.dumps(metadata.result,
indent=2)],
]
return await template.blank("Distribution submitted",
content=block.collect())
diff --git a/atr/template.py b/atr/template.py
index 00b6be7..63e00ab 100644
--- a/atr/template.py
+++ b/atr/template.py
@@ -18,16 +18,17 @@
import asyncio
from typing import Any
-import htpy
import jinja2
import quart
import quart.app as app
import quart.signals as signals
+import atr.htm as htm
+
render_async = quart.render_template
-async def blank(title: str, content: str | htpy.Element, description: str |
None = None) -> str:
+async def blank(title: str, content: str | htm.Element, description: str |
None = None) -> str:
return await render_sync("blank.html", title=title,
description=description or title, content=content)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]