diff --git a/silkaj/commands.py b/silkaj/commands.py index 2fcb797d04624b4932f26914bc8512d2ef16e67e..587d14343bcb3f9cb1d6e4cd812d41e67d7d51b7 100644 --- a/silkaj/commands.py +++ b/silkaj/commands.py @@ -21,14 +21,14 @@ import jsonschema from click import command, option, argument, IntRange from os import system from collections import OrderedDict -from tabulate import tabulate from operator import itemgetter from asyncio import sleep from _socket import gaierror from duniterpy.api import bma -from silkaj.tools import coroutine +from silkaj import tui +from silkaj.tools import coroutine, CurrencySymbol from silkaj.wot_tools import identity_of from silkaj.network_tools import ( best_endpoint_address, @@ -36,7 +36,6 @@ from silkaj.network_tools import ( ClientInstance, ) from silkaj.blockchain_tools import HeadBlock -from silkaj.tools import CurrencySymbol from silkaj.constants import ASYNC_SLEEP, ALL, DATE, HOUR @@ -125,6 +124,7 @@ def display_diffi(current, diffi): d["Π diffi"] = power(match_pattern(d["level"])[1]) d["Σ diffi"] = d.pop("level") system("cls||clear") + table = tui.create_table(style="columns").set_cols_dtype(["t", "t", "t", "i"]) print( "Current block: n°{0}, generated on the {1}\n\ Generation of next block n°{2} possible by at least {3}/{4} members\n\ @@ -136,9 +136,7 @@ Common Proof-of-Work difficulty level: {5}, hash starting with `{6}`\n{7}".forma len(diffi["levels"]), current["powMin"], match_pattern(int(current["powMin"]))[0], - tabulate( - sorted_diffi, headers="keys", tablefmt="orgtbl", stralign="center" - ), + tui.fill_table_from_dict_list(table, sorted_diffi), ) ) @@ -194,12 +192,8 @@ async def list_blocks(number, detailed): ) if detailed or number <= 30: sorted_list = sorted(issuers, key=itemgetter("block"), reverse=True) - print( - "\n" - + tabulate( - sorted_list, headers="keys", tablefmt="orgtbl", stralign="center" - ) - ) + table = tui.create_table(style="columns") + print("\n" + tui.fill_table_from_dict_list(table, sorted_list)) else: list_issued = list() for issuer in issuers: @@ -217,16 +211,10 @@ async def list_blocks(number, detailed): for issued in list_issued: issued["percent"] = issued["blocks"] / number * 100 sorted_list = sorted(list_issued, key=itemgetter("blocks"), reverse=True) + table = tui.create_table(style="columns") print( "from {0} issuers\n{1}".format( - len(list_issued), - tabulate( - sorted_list, - headers="keys", - tablefmt="orgtbl", - floatfmt=".1f", - stralign="center", - ), + len(list_issued), tui.fill_table_from_dict_list(table, sorted_list) ) )