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-29 23:28:15 -08:00
|
|
|
from SYS.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(
|
2025-12-29 18:42:02 -08:00
|
|
|
filename: str,
|
|
|
|
|
current: int,
|
|
|
|
|
total: int,
|
|
|
|
|
speed: float = 0,
|
|
|
|
|
end: str = "\r"
|
2025-12-29 17:05:03 -08:00
|
|
|
) -> 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()
|