From ad958fe902825b42c009eafe362edb58ac4bd808 Mon Sep 17 00:00:00 2001 From: Moul <moul@moul.re> Date: Sun, 26 Sep 2021 13:28:02 +0200 Subject: [PATCH] [mod] #194: money/tui: Use f-string --- silkaj/money.py | 4 ++-- silkaj/tui.py | 19 ++++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/silkaj/money.py b/silkaj/money.py index b23f9ad3..d030a661 100644 --- a/silkaj/money.py +++ b/silkaj/money.py @@ -138,7 +138,7 @@ def get_sources(pubkey): listinput = list() amount = 0 for source in sources["sources"]: - if source["conditions"] == "SIG(" + pubkey + ")": + if source["conditions"] == f"SIG({pubkey})": listinput.append( InputSource( amount=source["amount"], @@ -161,7 +161,7 @@ def get_sources(pubkey): identifier = pending["hash"] for i, output in enumerate(pending["outputs"]): outputsplited = output.split(":") - if outputsplited[2] == "SIG(" + pubkey + ")": + if outputsplited[2] == f"SIG({pubkey})": inputgenerated = InputSource( amount=int(outputsplited[0]), base=int(outputsplited[1]), diff --git a/silkaj/tui.py b/silkaj/tui.py index 985c9745..eaecea32 100644 --- a/silkaj/tui.py +++ b/silkaj/tui.py @@ -27,15 +27,12 @@ def display_amount(tx, message, amount, ud_value, currency_symbol): """ Displays an amount in unit and relative reference. """ - amount_UD = round((amount / ud_value), 2) + UD_amount = str(round((amount / ud_value), 2)) + unit_amount = str(amount / 100) tx.append( [ - message + " (unit|relative)", - "{unit_amount} {currency_symbol} | {UD_amount} UD {currency_symbol}".format( - unit_amount=str(amount / 100), - currency_symbol=currency_symbol, - UD_amount=str(amount_UD), - ), + f"{message} (unit|relative)", + f"{unit_amount} {currency_symbol} | {UD_amount} UD {currency_symbol}", ] ) @@ -44,10 +41,10 @@ def display_pubkey(tx, message, pubkey): """ Displays a pubkey and the eventually associated id. """ - tx.append([message + " (pubkey:checksum)", display_pubkey_and_checksum(pubkey)]) + tx.append([f"{message} (pubkey:checksum)", display_pubkey_and_checksum(pubkey)]) id = wot_tools.is_member(pubkey) if id: - tx.append([message + " (id)", id["uid"]]) + tx.append([f"{message} (id)", id["uid"]]) def display_pubkey_and_checksum( @@ -58,8 +55,8 @@ def display_pubkey_and_checksum( returns `length` first chars of pubkey and checksum in short form. `length` defaults to SHORT_PUBKEY_SIZE. """ - short_pubkey = pubkey[:length] + "…" if short else pubkey - return short_pubkey + ":" + ct.gen_checksum(pubkey) + short_pubkey = f"{pubkey[:length]}…" if short else pubkey + return f"{short_pubkey}:{ct.gen_checksum(pubkey)}" def send_doc_confirmation(document_name): -- GitLab