Skip to content
Snippets Groups Projects
Commit fdcc418d authored by matograine's avatar matograine
Browse files

[enh] #203 remove tabulate from commands.py

parent 2d99d16f
No related branches found
No related tags found
No related merge requests found
Pipeline #11965 failed
......@@ -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)
)
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment