mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Extract rich_table print to utils
This commit is contained in:
parent
2d8470b254
commit
768a51cb9b
|
@ -15,6 +15,7 @@ from freqtrade.exchange import list_available_exchanges, market_is_active
|
|||
from freqtrade.misc import parse_db_uri_for_logging, plural
|
||||
from freqtrade.resolvers import ExchangeResolver, StrategyResolver
|
||||
from freqtrade.types.valid_exchanges_type import ValidExchangesType
|
||||
from freqtrade.util import print_rich_table
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -77,19 +78,6 @@ 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:
|
||||
names = [s["name"] for s in objs]
|
||||
objs_to_print = [
|
||||
|
@ -292,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(summary_str, headers, tabular_data)
|
||||
elif not (
|
||||
args.get("print_one_column", False)
|
||||
or args.get("list_pairs_print_json", False)
|
||||
|
|
|
@ -15,6 +15,7 @@ from freqtrade.util.formatters import decimals_per_coin, fmt_coin, round_value
|
|||
from freqtrade.util.ft_precise import FtPrecise
|
||||
from freqtrade.util.measure_time import MeasureTime
|
||||
from freqtrade.util.periodic_cache import PeriodicCache
|
||||
from freqtrade.util.rich_tables import print_rich_table
|
||||
from freqtrade.util.template_renderer import render_template, render_template_with_fallback # noqa
|
||||
|
||||
|
||||
|
@ -36,4 +37,5 @@ __all__ = [
|
|||
"round_value",
|
||||
"fmt_coin",
|
||||
"MeasureTime",
|
||||
"print_rich_table",
|
||||
]
|
||||
|
|
17
freqtrade/util/rich_tables.py
Normal file
17
freqtrade/util/rich_tables.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from typing import Any, Dict, List
|
||||
|
||||
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:
|
||||
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)
|
Loading…
Reference in New Issue
Block a user