mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
chore: update rich-table print helper
This commit is contained in:
@@ -280,7 +280,7 @@ def start_list_markets(args: Dict[str, Any], pairs_only: bool = False) -> None:
|
||||
writer.writeheader()
|
||||
writer.writerows(tabular_data)
|
||||
else:
|
||||
print_rich_table(summary_str, headers, tabular_data)
|
||||
print_rich_table(tabular_data, headers, summary_str)
|
||||
elif not (
|
||||
args.get("print_one_column", False)
|
||||
or args.get("list_pairs_print_json", False)
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
from typing import Any, Dict, List
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from rich.console import Console
|
||||
from rich.table import Table
|
||||
|
||||
|
||||
def print_rich_table(summary: str, headers: List[str], tabular_data: List[Dict[str, Any]]) -> None:
|
||||
def print_rich_table(
|
||||
tabular_data: List[Dict[str, Any]], headers: List[str], summary: Optional[str] = None
|
||||
) -> 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])
|
||||
if isinstance(row, dict):
|
||||
table.add_row(*[str(row[header]) for header in headers])
|
||||
else:
|
||||
table.add_row(*row)
|
||||
|
||||
console = Console()
|
||||
console.print(table)
|
||||
|
||||
Reference in New Issue
Block a user