From 5ecd4ad7741e22915704c2b80d403cefe93cd713 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Sun, 19 Sep 2021 09:49:04 +0200 Subject: [PATCH] reformat dynamic_progress.py example with Black --- examples/dynamic_progress.py | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/examples/dynamic_progress.py b/examples/dynamic_progress.py index 8001f29a..0656eb65 100644 --- a/examples/dynamic_progress.py +++ b/examples/dynamic_progress.py @@ -10,7 +10,13 @@ import time from rich.console import RenderGroup from rich.live import Live -from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn, TimeElapsedColumn +from rich.progress import ( + BarColumn, + Progress, + SpinnerColumn, + TextColumn, + TimeElapsedColumn, +) def run_steps(name, step_times, app_steps_task_id): @@ -50,23 +56,20 @@ step_progress = Progress( ) # progress bar for current app (progress in steps) app_steps_progress = Progress( - TextColumn("[bold blue]Progress for app {task.fields[name]}: {task.percentage:.0f}%"), + TextColumn( + "[bold blue]Progress for app {task.fields[name]}: {task.percentage:.0f}%" + ), BarColumn(), TextColumn("({task.completed} of {task.total} steps done)"), ) # overall progress bar overall_progress = Progress( - TimeElapsedColumn(), - BarColumn(), - TextColumn("{task.description}") + TimeElapsedColumn(), BarColumn(), TextColumn("{task.description}") ) # group of progress bars; # some are always visible, others will disappear when progress is complete group = RenderGroup( - current_app_progress, - step_progress, - app_steps_progress, - overall_progress + current_app_progress, step_progress, app_steps_progress, overall_progress ) # tuple specifies how long each step takes for that app @@ -92,16 +95,22 @@ with Live(group): # add progress bar for steps of this app, and run the steps current_task_id = current_app_progress.add_task("Installing app %s" % name) - app_steps_task_id = app_steps_progress.add_task("", total=len(step_times), name=name) + app_steps_task_id = app_steps_progress.add_task( + "", total=len(step_times), name=name + ) run_steps(name, step_times, app_steps_task_id) # stop and hide steps progress bar for this specific app app_steps_progress.update(app_steps_task_id, visible=False) current_app_progress.stop_task(current_task_id) - current_app_progress.update(current_task_id, description="[bold green]App %s installed!" % name) + current_app_progress.update( + current_task_id, description="[bold green]App %s installed!" % name + ) # increase overall progress now this task is done overall_progress.update(overall_task_id, advance=1) # final update for message on overall progress bar - overall_progress.update(overall_task_id, description="[bold green]%s apps installed, done!" % len(apps)) + overall_progress.update( + overall_task_id, description="[bold green]%s apps installed, done!" % len(apps) + )