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

[enh] #203 remove tabulate from money.py

  * import tui module
parent 370a842e
No related branches found
No related tags found
No related merge requests found
......@@ -16,9 +16,9 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
"""
from click import command, argument, pass_context, echo
from tabulate import tabulate
from silkaj import wot_tools as wt
from silkaj import tui
from silkaj.network_tools import ClientInstance
from silkaj.blockchain_tools import HeadBlock
from silkaj.tools import CurrencySymbol, message_exit, coroutine
......@@ -28,7 +28,6 @@ from silkaj.crypto_tools import (
check_pubkey_format,
validate_checksum,
)
from silkaj.tui import display_amount, display_pubkey_and_checksum
from duniterpy.api.bma import tx, blockchain
from duniterpy.documents.transaction import InputSource
......@@ -54,7 +53,7 @@ async def cmd_amount(ctx, pubkeys):
print(f"ERROR: pubkey {inputPubkey} has a wrong format")
elif pubkey in pubkeys_list:
message_exit(
f"ERROR: pubkey {display_pubkey_and_checksum(pubkey)} was specified many times"
f"ERROR: pubkey {tui.display_pubkey_and_checksum(pubkey)} was specified many times"
)
pubkeys_list.append(pubkey)
if wrong_pubkeys:
......@@ -90,7 +89,7 @@ async def show_amount_from_pubkey(label, inputs_balance):
# if `pubkey` is a pubkey, get pubkey:checksum and uid
if label != "Total":
member = await wt.is_member(label)
label = display_pubkey_and_checksum(label)
label = tui.display_pubkey_and_checksum(label)
# display balance table
display = list()
display.append(["Balance of pubkey", label])
......@@ -99,22 +98,25 @@ async def show_amount_from_pubkey(label, inputs_balance):
display.append(["User identifier", member["uid"]])
if totalAmountInput - balance != 0:
display_amount(display, "Blockchain", balance, ud_value, currency_symbol)
display_amount(
tui.display_amount(display, "Blockchain", balance, ud_value, currency_symbol)
tui.display_amount(
display,
"Pending transaction",
(totalAmountInput - balance),
ud_value,
currency_symbol,
)
display_amount(display, "Total amount", totalAmountInput, ud_value, currency_symbol)
tui.display_amount(
display, "Total amount", totalAmountInput, ud_value, currency_symbol
)
display.append(
[
"Total relative to M/N",
"{0} x M/N".format(round(totalAmountInput / average, 2)),
]
)
echo(tabulate(display, tablefmt="fancy_grid"))
table = tui.create_table()
echo(tui.vert_table(table, display))
async def get_average():
......
......@@ -52,9 +52,9 @@ def test_balance():
silkaj + ["--gtest", "balance", "3dnbnYY9i2bHMQUGyFp5GVvJ2wBkVpus31cDJA5cfRpj"]
).decode()
assert (
" Balance of pubkey 3dnbnYY9i2bHMQUGyFp5GVvJ2wBkVpus31cDJA5cfRpj:EyF │"
"| Balance of pubkey | 3dnbnYY9i2bHMQUGyFp5GVvJ2wBkVpus31cDJA5cfRpj: |"
in output
)
assert " Total amount (unit|relative) " in output
assert "| Total amount (unit|relative) |" in output
assert "UD ĞTest" in output
assert "Total relative to M/N" in output
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