From 2e0372d24739c2913281cd9210c2c7fcb16a2cbd Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 6 Jul 2024 13:12:16 +0200 Subject: [PATCH] extract print_rich_table --- freqtrade/commands/list_commands.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/freqtrade/commands/list_commands.py b/freqtrade/commands/list_commands.py index d6fdd3111..4260ed87b 100644 --- a/freqtrade/commands/list_commands.py +++ b/freqtrade/commands/list_commands.py @@ -80,6 +80,19 @@ def start_list_exchanges(args: Dict[str, Any]) -> None: console.print(table) +def _print_rich_table(summary: str, headers: List[str], tabular_data: List[Dict[str, Any]]) -> None: + table = Table(title=summary) + + for header in headers: + table.add_column(header, justify="right") + + for row in tabular_data: + table.add_row(*[str(row[header]) for header in headers]) + + console = Console() + console.print(table) + + def _print_objs_tabular(objs: List, print_colorized: bool) -> None: if print_colorized: colorama_init(autoreset=True) @@ -280,14 +293,7 @@ def start_list_markets(args: Dict[str, Any], pairs_only: bool = False) -> None: writer.writeheader() writer.writerows(tabular_data) else: - table = Table(title=summary_str) - for header in headers: - table.add_column(header, justify="right") - for row in tabular_data: - table.add_row(*[str(row[header]) for header in headers]) - - console = Console() - console.print(table) + _print_rich_table(summary_str, headers, tabular_data) elif not ( args.get("print_one_column", False) or args.get("list_pairs_print_json", False)