From 2fc03bc3a798f191197b4077f6658930a77bc042 Mon Sep 17 00:00:00 2001 From: Rhet Turnbull Date: Mon, 17 Jun 2024 07:42:34 -0700 Subject: [PATCH] Fixed verbose color output --- examples/recover_photos.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/recover_photos.py b/examples/recover_photos.py index d6df05e8e..49afccac6 100644 --- a/examples/recover_photos.py +++ b/examples/recover_photos.py @@ -12,9 +12,15 @@ import click import xattr from rich import print +from rich.console import Console import osxphotos -from osxphotos.cli.click_rich_echo import get_rich_console, rich_echo, set_rich_console +from osxphotos.cli.click_rich_echo import ( + get_rich_console, + get_rich_theme, + rich_echo, + set_rich_console, +) from osxphotos.cli.import_cli import rename_edited_group from osxphotos.cli.rich_progress import Progress from osxphotos.exiftool import ExifTool, get_exiftool_path @@ -30,7 +36,7 @@ def echo(*args, **kwargs): """Print message to console and to log file""" if args: - args = f"{datetime.datetime.now()} {args[0]}", *args[1:] + args = f"[time]{datetime.datetime.now()}[/time] {args[0]}", *args[1:] if _global_log_file: print(*args, **kwargs, file=_global_log_file) rich_echo(*args, **kwargs) @@ -121,7 +127,7 @@ def main(library_path: str, verbose: bool, destination: str, dry_run: bool): error_count = 0 # save console to restore after progress bar is done console = get_rich_console() - with Progress() as progress: + with Progress(console=Console(theme=get_rich_theme())) as progress: task = progress.add_task("Recovering photos", total=len(originals)) # set console to progress console so echo messages show up correctly set_rich_console(progress.console)