Skip to content
Snippets Groups Projects
Commit ad958fe9 authored by Moul's avatar Moul
Browse files

[mod] #194: money/tui: Use f-string

parent 89f6b9de
No related branches found
No related tags found
1 merge request!195#194, #376: Use f-string and sys.exit()
......@@ -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]),
......
......@@ -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):
......
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