From 5c77e1a43b37e63cddf471118d589be121bb33d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sat, 6 Jan 2024 02:09:01 +0200 Subject: [PATCH] Create Progress the way tqdm.rich made it --- plextraktsync/rich/RichProgressBar.py | 31 ++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/plextraktsync/rich/RichProgressBar.py b/plextraktsync/rich/RichProgressBar.py index 3a79ce13077..991eab38b68 100644 --- a/plextraktsync/rich/RichProgressBar.py +++ b/plextraktsync/rich/RichProgressBar.py @@ -27,6 +27,31 @@ def __exit__(self, *exc): @cached_property def progress(self): - from rich.progress import Progress - - return Progress(**self.options) + from tqdm.rich import FractionColumn, RateColumn + + from rich.progress import (BarColumn, Progress, TimeElapsedColumn, + TimeRemainingColumn) + + args = ( + "[progress.description]{task.description}" + "[progress.percentage]{task.percentage:>4.0f}%", + BarColumn(bar_width=None), + FractionColumn( + unit_scale=False, + unit_divisor=1000, + ), + "[", + TimeElapsedColumn(), + "<", + TimeRemainingColumn(), + ",", + RateColumn( + unit="it", + unit_scale=False, + unit_divisor=1000, + ), + "]" + ) + progress = Progress(*args, **self.options) + + return progress