lint, whitespace

This commit is contained in:
MMGen@trixie 2025-10-01 15:26:41 +00:00 committed by The MMGen Project
commit 4d1f4577a7
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
7 changed files with 19 additions and 18 deletions

View file

@ -361,7 +361,7 @@ class BlocksInfo:
if p.debug: msg(repr(self.range_data(first,last,from_tip,nblocks,step)))
if nblocks:
if first == None:
if first is None:
first = self.tip - nblocks + 1
last = first + nblocks - 1

View file

@ -52,7 +52,7 @@ class PollDisplay:
count += 1
async def process_input():
if self.input == None:
if self.input is None:
sys.exit(1)
elif self.input == 'q':
msg('')

View file

@ -33,7 +33,7 @@ def timespec2secs(ts):
mul = { 's': 1, 'm': 60, 'h': 60*60, 'd': 60*60*24 }
pat = r'^([0-9]+)([smhd]*)$'
m = re.match(pat,ts)
if m == None:
if m is None:
die(2,"'%s': invalid time specifier" % ts)
a,b = m.groups()
return int(a) * (mul[b] if b else 1)

View file

@ -19,13 +19,13 @@ mmgen_node_tools.Ticker: Display price information for cryptocurrency and other
# Possible alternatives:
# - https://min-api.cryptocompare.com/data/pricemultifull?fsyms=BTC,LTC&tsyms=USD,EUR
import sys,os,re,time,datetime,json,yaml,random
from subprocess import run,PIPE,CalledProcessError
import sys, os, re, time, datetime, json, yaml, random
from subprocess import run, PIPE, CalledProcessError
from decimal import Decimal
from collections import namedtuple
from mmgen.color import red,yellow,green,blue,orange,gray
from mmgen.util import msg,msg_r,Msg,Msg_r,die,Die,suf,fmt,fmt_list,fmt_dict,list_gen
from mmgen.color import red, yellow, green, blue, orange, gray
from mmgen.util import msg, msg_r, Msg, Msg_r, die, fmt, fmt_list, fmt_dict, list_gen
from mmgen.ui import do_pager
homedir = os.getenv('HOME')
@ -89,9 +89,11 @@ class DataSource:
msg('')
from .Misc import curl_exit_codes
msg(red(curl_exit_codes[e.returncode]))
msg(red('Command line:\n {}'.format( ' '.join((repr(i) if ' ' in i else i) for i in e.cmd) )))
msg(red('Command line:\n {}'.format(
' '.join((repr(i) if ' ' in i else i) for i in e.cmd))))
from mmgen.exception import MMGenCalledProcessError
raise MMGenCalledProcessError(f'Subprocess returned non-zero exit status {e.returncode}')
raise MMGenCalledProcessError(
f'Subprocess returned non-zero exit status {e.returncode}')
def get_data(self):
@ -327,15 +329,16 @@ class DataSource:
def postprocess_data(self,data):
def gen():
keys = set()
for key,val in data.items():
d = {}
for key, val in data.items():
if m := re.match(r"\('(.*?)', datetime\.date\((.*)\)\)$",key):
date = '{}-{:>02}-{:>02}'.format(*m[2].split(', '))
if (sym := m[1]) in keys:
d[date] = val
else:
keys.add(sym)
d = {date:val}
yield (sym,d)
d = {date: val}
yield (sym, d)
return dict(gen())
def assets_list_gen(cfg_in):
@ -936,7 +939,7 @@ class Ticker:
def fmt_row(self,d,amt=None,amt_fmt=None):
def fmt_pct(n):
return gray(' --') if n == None else (red,green)[n>=0](f'{n:+7.2f}')
return gray(' --') if n is None else (red,green)[n>=0](f'{n:+7.2f}')
p = self.prices[d['id']]

View file

@ -20,7 +20,6 @@ mmgen_node_tools.Util: utility functions for MMGen node tools
"""
import time
from mmgen.util import suf
def get_hms(t=None,utc=False,no_secs=False):
secs = t or time.time()

View file

@ -14,7 +14,7 @@ mmnode-addrbal: Get balances for arbitrary addresses in the blockchain
import sys
from mmgen.obj import CoinTxID,Int
from mmgen.obj import CoinTxID
from mmgen.cfg import Config
from mmgen.util import msg,Msg,die,suf,make_timestr,async_run
from mmgen.color import red

View file

@ -21,7 +21,6 @@ mmnode-halving-calculator: Estimate date(s) of future block subsidy halving(s)
"""
import time
from decimal import Decimal
from mmgen.cfg import Config
from mmgen.util import async_run
@ -148,8 +147,8 @@ async def main():
b = 'BLOCK',
c = 'DATE',
d = '',
e = f'BDI (mins)',
f = f'SUBSIDY ({proto.coin})',
e = 'BDI (mins)',
f = 'SUBSIDY ({proto.coin})',
g = f'MINED ({proto.coin})',
h = f'TOTAL MINED ({proto.coin})'
)