From 11c2a0b08c52f11c569ec31bbac76788faedbdff Mon Sep 17 00:00:00 2001 From: Sourcery AI <> Date: Tue, 8 Mar 2022 00:55:23 +0000 Subject: [PATCH] 'Refactored by Sourcery' --- pybitblock/nodeconnection.py | 84 ++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 38 deletions(-) diff --git a/pybitblock/nodeconnection.py b/pybitblock/nodeconnection.py index 7d2db97..e16c103 100644 --- a/pybitblock/nodeconnection.py +++ b/pybitblock/nodeconnection.py @@ -175,11 +175,11 @@ def locallistpeersQQ(): hash = s['pub_key'] rh = Robohash(hash) rh.assemble(roboset='set1') - if not os.path.isfile(str(hash + ".png")): - with open(hash +".png", "wb") as f: - rh.img.save(f, format="png") + if not os.path.isfile(str(f'{hash}.png')): + with open(f'{hash}.png', "wb") as f: + rh.img.save(f, format="png") - img_path = open(hash +".png", "rb") + img_path = open(f'{hash}.png', "rb") img = Image.open(img_path) h = 1 @@ -189,7 +189,7 @@ def locallistpeersQQ(): img_arr = np.asarray(img) h,w,c = img_arr.shape - img_path = open(hash +".png", "rb") + img_path = open(f'{hash}.png', "rb") img = Image.open(img_path) h = 1 @@ -215,7 +215,7 @@ def locallistpeersQQ(): rh = Robohash(hash) rh.assemble(roboset='set1') - img_path = open(hash +".png", "rb") + img_path = open(f'{hash}.png', "rb") img = Image.open(img_path) h = 20 @@ -398,11 +398,11 @@ def locallistchannels(): hash = s['remote_pubkey'] rh = Robohash(hash) rh.assemble(roboset='set1') - if not os.path.isfile(str(hash + ".png")): - with open(hash +".png", "wb") as f: - rh.img.save(f, format="png") + if not os.path.isfile(str(f'{hash}.png')): + with open(f'{hash}.png', "wb") as f: + rh.img.save(f, format="png") - img_path = open(hash +".png", "rb") + img_path = open(f'{hash}.png', "rb") img = Image.open(img_path) h = 1 @@ -412,7 +412,7 @@ def locallistchannels(): img_arr = np.asarray(img) h,w,c = img_arr.shape - img_path = open(hash +".png", "rb") + img_path = open(f'{hash}.png', "rb") img = Image.open(img_path) h = 1 @@ -438,7 +438,7 @@ def locallistchannels(): rh = Robohash(hash) rh.assemble(roboset='set1') - img_path = open(hash +".png", "rb") + img_path = open(f'{hash}.png', "rb") img = Image.open(img_path) h = 20 @@ -485,11 +485,11 @@ def localgetinfo(): hash = d['identity_pubkey'] rh = Robohash(hash) rh.assemble(roboset='set1') - if not os.path.isfile(str(hash + ".png")): - with open(hash +".png", "wb") as f: - rh.img.save(f, format="png") + if not os.path.isfile(str(f'{hash}.png')): + with open(f'{hash}.png', "wb") as f: + rh.img.save(f, format="png") - img_path = open(hash +".png", "rb") + img_path = open(f'{hash}.png', "rb") img = Image.open(img_path) h = 20 @@ -499,7 +499,7 @@ def localgetinfo(): img_arr = np.asarray(img) h,w,c = img_arr.shape - img_path = open(hash +".png", "rb") + img_path = open(f'{hash}.png', "rb") img = Image.open(img_path) h = 20 @@ -656,7 +656,11 @@ def localkeysend(): amount = input("\nAmount in sats: ") else: break - os.system("""lncli sendpayment --keysend --d=""" + node + " --amt=" + amount + """ --final_cltv_delta=40""") + os.system( + f"""lncli sendpayment --keysend --d={node} --amt={amount}""" + + """ --final_cltv_delta=40""" + ) + input("\nContinue...") except: pass @@ -892,16 +896,20 @@ def getnewinvoice(): } if amount == "": r = requests.post( - url, - headers=headers, verify=cert_path, - json={"memo": memo + " -PyBLOCK"}, - ) + url, + headers=headers, + verify=cert_path, + json={"memo": f'{memo} -PyBLOCK'}, + ) + else: r = requests.post( - url, - headers=headers, verify=cert_path, - json={"value": amount, "memo": memo + " -PyBLOCK"}, - ) + url, + headers=headers, + verify=cert_path, + json={"value": amount, "memo": f'{memo} -PyBLOCK'}, + ) + a = r.json() print("\033[1;30;47m") @@ -1079,11 +1087,11 @@ def getinfo(): hash = a['identity_pubkey'] rh = Robohash(hash) rh.assemble(roboset='set1') - if not os.path.isfile(str(hash + ".png")): - with open(hash +".png", "wb") as f: - rh.img.save(f, format="png") + if not os.path.isfile(str(f'{hash}.png')): + with open(f'{hash}.png', "wb") as f: + rh.img.save(f, format="png") - img_path = open(hash +".png", "rb") + img_path = open(f'{hash}.png', "rb") img = Image.open(img_path) h = 20 @@ -1093,7 +1101,7 @@ def getinfo(): img_arr = np.asarray(img) h,w,c = img_arr.shape - img_path = open(hash +".png", "rb") + img_path = open(f'{hash}.png', "rb") img = Image.open(img_path) h = 20 @@ -1132,7 +1140,7 @@ def getinfo(): #--------------------------------- NYMs ----------------------------------- def get_ansi_color_code(r, g, b): - if r == g and g == b: + if r == g == b: if r < 8: return 16 if r > 248: @@ -1166,11 +1174,11 @@ def channels(): hash = s['remote_pubkey'] rh = Robohash(hash) rh.assemble(roboset='set1') - if not os.path.isfile(str(hash + ".png")): - with open(hash +".png", "wb") as f: - rh.img.save(f, format="png") + if not os.path.isfile(str(f'{hash}.png')): + with open(f'{hash}.png', "wb") as f: + rh.img.save(f, format="png") - img_path = open(hash +".png", "rb") + img_path = open(f'{hash}.png', "rb") img = Image.open(img_path) h = 1 @@ -1180,7 +1188,7 @@ def channels(): img_arr = np.asarray(img) h,w,c = img_arr.shape - img_path = open(hash +".png", "rb") + img_path = open(f'{hash}.png', "rb") img = Image.open(img_path) h = 1 @@ -1206,7 +1214,7 @@ def channels(): rh = Robohash(hash) rh.assemble(roboset='set1') - img_path = open(hash +".png" , "rb") + img_path = open(f'{hash}.png', "rb") img = Image.open(img_path) h = 20