2025-12-20 23:57:44 -08:00
|
|
|
"""Rich-only progress helpers.
|
2025-11-25 20:09:33 -08:00
|
|
|
|
2025-12-20 23:57:44 -08:00
|
|
|
These functions preserve the legacy call signatures used around the codebase,
|
|
|
|
|
but all rendering is performed via Rich (no ASCII progress bars).
|
|
|
|
|
"""
|
2025-12-11 19:04:02 -08:00
|
|
|
|
2025-12-20 23:57:44 -08:00
|
|
|
from __future__ import annotations
|
2025-11-25 20:09:33 -08:00
|
|
|
|
2025-12-20 23:57:44 -08:00
|
|
|
import sys
|
2025-11-25 20:09:33 -08:00
|
|
|
|
2025-12-20 23:57:44 -08:00
|
|
|
from models import ProgressBar
|
2025-12-11 19:04:02 -08:00
|
|
|
|
|
|
|
|
|
2025-12-20 23:57:44 -08:00
|
|
|
_BAR = ProgressBar()
|
2025-11-25 20:09:33 -08:00
|
|
|
|
|
|
|
|
|
2025-12-29 17:05:03 -08:00
|
|
|
def print_progress(
|
|
|
|
|
filename: str, current: int, total: int, speed: float = 0, end: str = "\r"
|
|
|
|
|
) -> None:
|
|
|
|
|
_BAR.update(
|
|
|
|
|
downloaded=int(current),
|
|
|
|
|
total=int(total) if total else None,
|
|
|
|
|
label=str(filename or "progress"),
|
|
|
|
|
file=sys.stderr,
|
|
|
|
|
)
|
2025-11-25 20:09:33 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def print_final_progress(filename: str, total: int, elapsed: float) -> None:
|
2025-12-20 23:57:44 -08:00
|
|
|
_BAR.finish()
|