Use shared binary dependency table renderer

This commit is contained in:
Nick Sweeting 2026-07-28 10:54:48 -07:00
parent e39ee82ead
commit eec8e63a76
No known key found for this signature in database
4 changed files with 16 additions and 63 deletions

View File

@ -79,48 +79,6 @@ def _render_binary_abspath(abspath: str):
return Text(abspath, style="green")
def _build_binary_table(rows: list[dict[str, object]]):
from rich import box
from rich.table import Table
table = Table(title="Binary Dependencies", box=box.SIMPLE_HEAVY, expand=True)
table.add_column("Binary", no_wrap=True, max_width=28)
table.add_column("Plugin", no_wrap=True, max_width=24)
table.add_column("State", no_wrap=True, width=8)
table.add_column("Status", justify="center", no_wrap=True, width=6)
table.add_column("Version", no_wrap=True, width=16)
table.add_column("Provider", no_wrap=True, width=8)
table.add_column("Path", overflow="fold", ratio=1)
for row in rows:
table.add_row(
str(row["binary"]),
str(row["plugin"]),
str(row["state"]),
str(row["status"]),
str(row["version"]),
str(row["provider"]),
row["path"],
style=str(row.get("style") or ""),
)
return table
def _print_binary_row(prnt, row: dict[str, object]) -> None:
prnt(
"",
str(row["binary"]).ljust(28),
row["status"],
str(row["plugin"]).ljust(24),
str(row["state"]).ljust(8),
str(row["version"]).ljust(16),
str(row["provider"]).ljust(8),
row["path"],
overflow="ignore",
crop=False,
style=str(row.get("style") or ""),
)
def _binary_record_matches_runtime(installed, lib_dir: Path) -> bool:
if not installed or not installed.is_valid or not installed.version:
return False
@ -169,6 +127,7 @@ def version(
from rich.panel import Panel
from rich.console import Console
from rich.live import Live
from abx_dl.tables import binary_dependency_status, binary_dependency_table
from archivebox.config import CONSTANTS
from archivebox.config.version import get_COMMIT_HASH, get_BUILD_TIME
@ -367,16 +326,12 @@ def version(
any_available = False
compact_paths = console.is_terminal
live_enabled = console.is_terminal
live_cm = Live(_build_binary_table(rows), console=console, refresh_per_second=8) if live_enabled else None
if not live_enabled:
prnt("", "Binary".ljust(28), "Status", "Plugin".ljust(24), "State".ljust(8), "Version".ljust(16), "Provider".ljust(8), "Path")
live_cm = Live(binary_dependency_table(rows), console=console, refresh_per_second=8) if live_enabled else None
def emit_row(row: dict[str, object]) -> None:
rows.append(row)
if live_cm is not None:
live_cm.update(_build_binary_table(rows), refresh=True)
else:
_print_binary_row(prnt, row)
live_cm.update(binary_dependency_table(rows), refresh=True)
if live_cm is not None:
live_cm.start()
@ -439,11 +394,9 @@ def version(
else abspath
)
rendered_path = _render_binary_abspath(display_path) if compact_paths else display_path
status = "[green]√[/green]" if plugin_enabled else "[grey53]-[/grey53]"
any_available = True
else:
rendered_path = "[grey53]not installed[/grey53]"
status = "[red]X[/red]" if plugin_enabled else "[grey53]-[/grey53]"
if plugin_enabled and display_name not in seen_failures:
failures.append(display_name)
seen_failures.add(display_name)
@ -462,8 +415,7 @@ def version(
emit_row(
{
"plugin": plugin_name,
"state": "enabled" if plugin_enabled else "disabled",
"status": status,
"status": binary_dependency_status(enabled=plugin_enabled, valid=valid),
"binary": display_name,
"version": version_str if valid else "-",
"provider": provider if valid else "-",
@ -504,8 +456,7 @@ def version(
emit_row(
{
"plugin": "(database)",
"state": "detected",
"status": "[green]√[/green]",
"status": binary_dependency_status(enabled=True, valid=True),
"binary": binary_name,
"version": version_str,
"provider": provider,
@ -518,6 +469,8 @@ def version(
finally:
if live_cm is not None:
live_cm.stop()
else:
prnt(binary_dependency_table(rows))
if not any_rows:
prnt("", "[grey53]No required binaries declared for discovered plugins.[/grey53]")

View File

@ -1,6 +1,6 @@
{
"name": "archivebox",
"version": "0.9.35rc160",
"version": "0.9.35rc161",
"repository": "github:ArchiveBox/ArchiveBox",
"license": "MIT",
"dependencies": {

View File

@ -1,6 +1,6 @@
[project]
name = "archivebox"
version = "0.9.35rc160"
version = "0.9.35rc161"
requires-python = ">=3.13"
description = "Self-hosted internet archiving solution."
authors = [{name = "Nick Sweeting", email = "pyproject.toml@archivebox.io"}]
@ -83,7 +83,7 @@ dependencies = [
"abxbus==2.5.40", # EventBus API
"abxpkg", # direct imports only; version constrained by abx-dl -> abx-plugins
"abx-plugins", # direct imports only; version constrained by abx-dl
"abx-dl==1.12.28", # shared ArchiveBox downloader package
"abx-dl==1.12.29", # shared ArchiveBox downloader package
### UUID7 backport for Python <3.14
"uuid7>=0.1.0; python_version < '3.14'", # provides the uuid_extensions module on Python 3.13
]
@ -348,7 +348,7 @@ Donate = "https://github.com/ArchiveBox/ArchiveBox/wiki/Donations"
[tool.bumpver]
current_version = "v0.9.35rc160"
current_version = "v0.9.35rc161"
version_pattern = "vMAJOR.MINOR.PATCH[PYTAGNUM]"
commit_message = "bump version {old_version} -> {new_version}"
tag_message = "{new_version}"

10
uv.lock
View File

@ -24,7 +24,7 @@ abxpkg = "2100-01-01T00:00:00Z"
[[package]]
name = "abx-dl"
version = "1.12.28"
version = "1.12.29"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "abx-plugins" },
@ -39,9 +39,9 @@ dependencies = [
{ name = "rich" },
{ name = "rich-click" },
]
sdist = { url = "https://files.pythonhosted.org/packages/2c/ed/dd5914a136b57bfbf40d54e3aee13ca9d2b8e07e82546a3bb6dfeb94b757/abx_dl-1.12.28.tar.gz", hash = "sha256:aa4deed655edad472b6afe47e061bbae6e38d769e60d4ec1e2fa6fab0c9759b3", size = 86871, upload-time = "2026-07-28T15:34:57.02Z" }
sdist = { url = "https://files.pythonhosted.org/packages/27/1c/ef4512b5209a94f3e3945907ae3fbefc47ff2b630aff9f7d957cfb8917da/abx_dl-1.12.29.tar.gz", hash = "sha256:d072755cb069ae8f412316810ab38a7c754e03555d02e0d9a8eb5ae04a8b0d60", size = 86814, upload-time = "2026-07-28T17:52:24.237Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/17/91/dbf344883e4ff2698b6b3b04f4e3ae2ba15f4bdea647d47fa000372e2fa7/abx_dl-1.12.28-py3-none-any.whl", hash = "sha256:b136a6ed0492fbe16d504739d4b56388858eb3d90a05c89ac6ab6c788b450d07", size = 90583, upload-time = "2026-07-28T15:34:58.529Z" },
{ url = "https://files.pythonhosted.org/packages/08/ea/9c15aeacf2492004bca3874008dad34557e06c56ae6c6caf037c068b93a9/abx_dl-1.12.29-py3-none-any.whl", hash = "sha256:429da9b175680ead21cae69ebf3e22204ad16a48c0e656d65d82b9153014caf7", size = 90704, upload-time = "2026-07-28T17:52:23.154Z" },
]
[[package]]
@ -123,7 +123,7 @@ wheels = [
[[package]]
name = "archivebox"
version = "0.9.35rc160"
version = "0.9.35rc161"
source = { editable = "." }
dependencies = [
{ name = "abx-dl" },
@ -223,7 +223,7 @@ dev = [
[package.metadata]
requires-dist = [
{ name = "abx-dl", specifier = "==1.12.28" },
{ name = "abx-dl", specifier = "==1.12.29" },
{ name = "abx-plugins" },
{ name = "abxbus", specifier = "==2.5.40" },
{ name = "abxpkg" },