tw.view: minor cleanups, whitespace
This commit is contained in:
parent
95ef7abd1f
commit
a575a03e1a
5 changed files with 46 additions and 27 deletions
|
|
@ -19,5 +19,5 @@ from .view import MoneroTwView
|
|||
class MoneroTwUnspentOutputs(MoneroTwView, TwAddresses):
|
||||
|
||||
hdr_lbl = 'spendable accounts'
|
||||
desc = 'address balances'
|
||||
desc = 'address balances'
|
||||
include_empty = False
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ class TwAddresses(TwView):
|
|||
|
||||
return addrs
|
||||
|
||||
async def gen_data(self, rpc_data, lbl_id):
|
||||
def gen_data(self, rpc_data, lbl_id):
|
||||
return (
|
||||
self.TwAddress(
|
||||
self.proto,
|
||||
|
|
@ -167,8 +167,7 @@ class TwAddresses(TwView):
|
|||
is_used = data['is_used'],
|
||||
date = 0,
|
||||
skip = '')
|
||||
for twmmid, data in rpc_data.items()
|
||||
)
|
||||
for twmmid, data in rpc_data.items())
|
||||
|
||||
def filter_data(self):
|
||||
if self.usr_addr_list:
|
||||
|
|
@ -177,8 +176,7 @@ class TwAddresses(TwView):
|
|||
return (d for d in self.data if
|
||||
(self.all_labels and d.comment) or
|
||||
(self.showused == 2 and d.is_used) or
|
||||
(not (d.is_used and not self.showused) and (d.amt or self.showempty))
|
||||
)
|
||||
(not (d.is_used and not self.showused) and (d.amt or self.showempty)))
|
||||
|
||||
def get_column_widths(self, data, *, wide, interactive):
|
||||
|
||||
|
|
@ -260,8 +258,13 @@ class TwAddresses(TwView):
|
|||
if not self.dates_set:
|
||||
bc = self.rpc.blockcount + 1
|
||||
caddrs = [addr for addr in addrs if addr.confs]
|
||||
hashes = await self.rpc.gathered_call('getblockhash', [(n,) for n in [bc - a.confs for a in caddrs]])
|
||||
dates = [d['time'] for d in await self.rpc.gathered_call('getblockheader', [(h,) for h in hashes])]
|
||||
hashes = await self.rpc.gathered_call(
|
||||
'getblockhash',
|
||||
[(n,) for n in [bc - a.confs for a in caddrs]])
|
||||
dates = [d['time']
|
||||
for d in await self.rpc.gathered_call(
|
||||
'getblockheader',
|
||||
[(h,) for h in hashes])]
|
||||
for idx, addr in enumerate(caddrs):
|
||||
addr.date = dates[idx]
|
||||
self.dates_set = True
|
||||
|
|
|
|||
|
|
@ -43,7 +43,8 @@ class TwTxHistory(TwView):
|
|||
|
||||
async def __init__(self, cfg, proto, *, sinceblock=0):
|
||||
await super().__init__(cfg, proto)
|
||||
self.sinceblock = NonNegativeInt(sinceblock if sinceblock >= 0 else self.rpc.blockcount + sinceblock)
|
||||
self.sinceblock = NonNegativeInt(
|
||||
sinceblock if sinceblock >= 0 else self.rpc.blockcount + sinceblock)
|
||||
|
||||
@property
|
||||
def no_rpcdata_errmsg(self):
|
||||
|
|
@ -131,9 +132,11 @@ class TwTxHistory(TwView):
|
|||
n = str(n) + ')',
|
||||
t = d.txid_disp(width=cw.txid, color=color) if hasattr(cw, 'txid') else None,
|
||||
d = d.age_disp(self.age_fmt, width=self.age_w, color=color),
|
||||
i = d.vouts_disp('inputs', width=cw.inputs, color=color, addr_view_pref=self.addr_view_pref),
|
||||
i = d.vouts_disp(
|
||||
'inputs', width=cw.inputs, color=color, addr_view_pref=self.addr_view_pref),
|
||||
A = d.amt_disp(self.show_total_amt).fmt(cw.iwidth, prec=self.disp_prec, color=color),
|
||||
o = d.vouts_disp('outputs', width=cw.outputs, color=color, addr_view_pref=self.addr_view_pref),
|
||||
o = d.vouts_disp(
|
||||
'outputs', width=cw.outputs, color=color, addr_view_pref=self.addr_view_pref),
|
||||
c = d.comment.fmt2(cw.comment, color=color, nullrepl='-'))
|
||||
|
||||
def gen_detail_display(self, data, cw, fs, color, fmt_method):
|
||||
|
|
@ -161,10 +164,11 @@ class TwTxHistory(TwView):
|
|||
A = d.amt_disp(show_total_amt=True).hl(color=color),
|
||||
B = d.amt_disp(show_total_amt=False).hl(color=color),
|
||||
f = d.fee_disp(color=color),
|
||||
i = d.vouts_list_disp('inputs', color=color, indent=' '*8, addr_view_pref=self.addr_view_pref),
|
||||
i = d.vouts_list_disp(
|
||||
'inputs', color=color, indent=' '*8, addr_view_pref=self.addr_view_pref),
|
||||
N = d.nOutputs,
|
||||
o = d.vouts_list_disp('outputs', color=color, indent=' '*8, addr_view_pref=self.addr_view_pref),
|
||||
)
|
||||
o = d.vouts_list_disp(
|
||||
'outputs', color=color, indent=' '*8, addr_view_pref=self.addr_view_pref))
|
||||
|
||||
sort_disp = {
|
||||
'age': 'Age',
|
||||
|
|
@ -174,8 +178,9 @@ class TwTxHistory(TwView):
|
|||
'txid': 'TxID'}
|
||||
|
||||
sort_funcs = {
|
||||
'age': lambda i: '{:010}.{:010}'.format(0xffffffff - abs(i.confirmations), i.time_received or 0),
|
||||
'blockheight': lambda i: 0 - abs(i.confirmations), # old/altcoin daemons return no 'blockheight' field
|
||||
'age': lambda i: '{:010}.{:010}'.format(
|
||||
0xffffffff - abs(i.confirmations), i.time_received or 0),
|
||||
'blockheight': lambda i: 0 - abs(i.confirmations), # old/altcoin daemons lack 'blockheight' field
|
||||
'amt': lambda i: i.wallet_outputs_total,
|
||||
'total_amt': lambda i: i.outputs_total,
|
||||
'txid': lambda i: i.txid}
|
||||
|
|
|
|||
|
|
@ -182,8 +182,7 @@ class TwUnspentOutputs(TwView):
|
|||
self.nice_addr_w if show_mmid else {}
|
||||
) | self.txid_nice_w,
|
||||
wide = wide,
|
||||
interactive = interactive,
|
||||
)
|
||||
interactive = interactive)
|
||||
|
||||
def squeezed_col_hdr(self, cw, fs, color):
|
||||
return fs.format(
|
||||
|
|
@ -225,8 +224,7 @@ class TwUnspentOutputs(TwView):
|
|||
c = d.comment.fmt2(cw.comment, color=color, nullrepl='-') if cw.comment else None,
|
||||
A = d.amt.fmt(cw.iwidth, color=color, prec=self.disp_prec),
|
||||
B = d.amt2.fmt(cw.iwidth2, color=color, prec=self.disp_prec) if cw.amt2 else None,
|
||||
d = self.age_disp(d, self.age_fmt),
|
||||
)
|
||||
d = self.age_disp(d, self.age_fmt))
|
||||
|
||||
def gen_detail_display(self, data, cw, fs, color, fmt_method):
|
||||
|
||||
|
|
@ -255,7 +253,9 @@ class TwUnspentOutputs(TwView):
|
|||
if not self.dates_set:
|
||||
# 'blocktime' differs from 'time', is same as getblockheader['time']
|
||||
dates = [o.get('blocktime', 0)
|
||||
for o in await self.rpc.gathered_icall('gettransaction', [(o.txid, True, False) for o in us])]
|
||||
for o in await self.rpc.gathered_icall(
|
||||
'gettransaction',
|
||||
[(o.txid, True, False) for o in us])]
|
||||
for idx, o in enumerate(us):
|
||||
o.date = dates[idx]
|
||||
self.dates_set = True
|
||||
|
|
|
|||
|
|
@ -314,9 +314,13 @@ class TwView(MMGenObject, metaclass=AsyncInit):
|
|||
return _term_dimensions(cols, ts.height)
|
||||
if sys.stdout.isatty():
|
||||
if self.cfg.columns and cols < min_cols:
|
||||
die(1, '\n'+fmt(self.twidth_diemsg.format(self.cfg.columns, self.desc, min_cols), indent=' '))
|
||||
die(1, '\n'+fmt(
|
||||
self.twidth_diemsg.format(self.cfg.columns, self.desc, min_cols),
|
||||
indent = ' '))
|
||||
else:
|
||||
m, dim = (self.twidth_errmsg, min_cols) if cols < min_cols else (self.theight_errmsg, min_lines)
|
||||
m, dim = (
|
||||
(self.twidth_errmsg, min_cols) if cols < min_cols else
|
||||
(self.theight_errmsg, min_lines))
|
||||
get_char_raw(CUR_HOME + ERASE_ALL + fmt(m.format(self.desc, dim), append=''))
|
||||
user_resized = True
|
||||
else:
|
||||
|
|
@ -422,8 +426,13 @@ class TwView(MMGenObject, metaclass=AsyncInit):
|
|||
|
||||
def gen_hdr(spc):
|
||||
|
||||
Blue, Green = (blue, green) if color else (nocolor, nocolor)
|
||||
Yes, No, All = (green('yes'), red('no'), yellow('all')) if color else ('yes', 'no', 'all')
|
||||
if color:
|
||||
Blue, Green = (blue, green)
|
||||
Yes, No, All = (green('yes'), red('no'), yellow('all'))
|
||||
else:
|
||||
Blue, Green = (nocolor, nocolor)
|
||||
Yes, No, All = ('yes', 'no', 'all')
|
||||
|
||||
sort_info = ' '.join(self.sort_info())
|
||||
|
||||
def fmt_filter(k):
|
||||
|
|
@ -784,8 +793,10 @@ class TwView(MMGenObject, metaclass=AsyncInit):
|
|||
await asyncio.sleep(3)
|
||||
parent.oneshot_msg = red('Label for {desc} could not be {action}'.format(
|
||||
desc = desc,
|
||||
action = 'edited' if cur_comment and comment else 'added' if comment else 'removed'
|
||||
))
|
||||
action =
|
||||
'edited' if cur_comment and comment else
|
||||
'added' if comment else
|
||||
'removed'))
|
||||
return False
|
||||
|
||||
entry = parent.disp_data[idx-1]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue