mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 00:23:07 +00:00
Improve rich tables interface
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import sys
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from rich.console import Console
|
||||
@@ -5,9 +6,13 @@ from rich.table import Table
|
||||
|
||||
|
||||
def print_rich_table(
|
||||
tabular_data: List[Dict[str, Any]], headers: List[str], summary: Optional[str] = None
|
||||
tabular_data: List[Dict[str, Any]],
|
||||
headers: List[str],
|
||||
summary: Optional[str] = None,
|
||||
*,
|
||||
table_kwargs: Optional[Dict[str, Any]] = None,
|
||||
) -> None:
|
||||
table = Table(title=summary)
|
||||
table = Table(title=summary, **(table_kwargs or {}))
|
||||
|
||||
for header in headers:
|
||||
table.add_column(header, justify="right")
|
||||
@@ -18,5 +23,7 @@ def print_rich_table(
|
||||
else:
|
||||
table.add_row(*row)
|
||||
|
||||
console = Console()
|
||||
console = Console(
|
||||
width=200 if "pytest" in sys.modules else None,
|
||||
)
|
||||
console.print(table)
|
||||
|
||||
Reference in New Issue
Block a user