From fbd71fba77a6b1398bdadea39bab6fc7943ddcbf Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sun, 13 Nov 2022 15:36:34 +0000 Subject: [PATCH] tracking wallet classes: whitespace, cleanup; test.py: minor fix --- mmgen/proto/eth/tw/unspent.py | 7 +++---- mmgen/tw/addresses.py | 16 ++++++++-------- mmgen/tw/txhistory.py | 4 ++-- mmgen/tw/unspent.py | 32 ++++++++++++++++---------------- mmgen/tw/view.py | 1 + test/test.py | 22 +++++++++++----------- 6 files changed, 41 insertions(+), 41 deletions(-) diff --git a/mmgen/proto/eth/tw/unspent.py b/mmgen/proto/eth/tw/unspent.py index 17f8c2ae..2969aee7 100755 --- a/mmgen/proto/eth/tw/unspent.py +++ b/mmgen/proto/eth/tw/unspent.py @@ -39,7 +39,6 @@ class EthereumTwUnspentOutputs(EthereumTwView,TwUnspentOutputs): valid_attrs = {'txid','vout','amt','amt2','comment','twmmid','addr','confs','skip'} invalid_attrs = {'proto'} - token_cls = False has_age = False can_group = False hdr_lbl = 'tracked accounts' @@ -77,8 +76,8 @@ Actions: [q]uit view, [p]rint to file, pager [v]iew, [w]ide view, 'num': max(2,len(str(len(data)))+1), 'mmid': max(len(d.twmmid.disp) for d in data) if self.show_mmid else 0, 'amt': self.disp_prec + 5, - 'amt2': self.disp_prec + 5 if self.token_cls else 0, - 'spc': (5 if self.show_mmid else 3) + self.token_cls, # 5(3) spaces in fs + 'amt2': self.disp_prec + 5 if self.has_amt2 else 0, + 'spc': (5 if self.show_mmid else 3) + self.has_amt2, # 5(3) spaces in fs 'txid': 0, 'vout': 0, 'block': 0, @@ -115,7 +114,7 @@ Actions: [q]uit view, [p]rint to file, pager [v]iew, [w]ide view, class EthereumTokenTwUnspentOutputs(EthereumTwUnspentOutputs): prompt_fs = 'Total to spend: {} {}\n\n' - token_cls = True + has_amt2 = True async def __init__(self,proto,*args,**kwargs): await super().__init__(proto,*args,**kwargs) diff --git a/mmgen/tw/addresses.py b/mmgen/tw/addresses.py index 830e042e..672e63f7 100755 --- a/mmgen/tw/addresses.py +++ b/mmgen/tw/addresses.py @@ -175,11 +175,11 @@ class TwAddresses(TwView): yield '' yield fs.format( n = str(n) + ')', - m = d.twmmid.fmt(width=cw.mmid,color=color), + m = d.twmmid.fmt( width=cw.mmid, color=color ), u = yes if d.recvd else no, - a = d.addr.fmt(color=color,width=cw.addr), - c = d.comment.fmt(width=cw.comment,color=color,nullrepl='-'), - A = d.amt.fmt(color=color,prec=self.disp_prec), + a = d.addr.fmt( color=color, width=cw.addr ), + c = d.comment.fmt( width=cw.comment, color=color, nullrepl='-' ), + A = d.amt.fmt( color=color, prec=self.disp_prec ), d = self.age_disp( d, self.age_fmt ) ) @@ -204,11 +204,11 @@ class TwAddresses(TwView): yield '' yield fs.format( n = str(n) + ')', - m = d.twmmid.fmt(width=cw.mmid,color=color), + m = d.twmmid.fmt( width=cw.mmid, color=color ), u = yes if d.recvd else no, - a = d.addr.fmt(color=color,width=cw.addr), - c = d.comment.fmt(width=cw.comment,color=color,nullrepl='-'), - A = d.amt.fmt(color=color,prec=self.disp_prec), + a = d.addr.fmt( color=color, width=cw.addr ), + c = d.comment.fmt( width=cw.comment, color=color, nullrepl='-' ), + A = d.amt.fmt( color=color, prec=self.disp_prec ), b = self.age_disp( d, 'block' ), D = self.age_disp( d, 'date_time' ), ).rstrip() diff --git a/mmgen/tw/txhistory.py b/mmgen/tw/txhistory.py index d739764f..96361e77 100755 --- a/mmgen/tw/txhistory.py +++ b/mmgen/tw/txhistory.py @@ -139,8 +139,8 @@ class TwTxHistory(TwView): b = d.blockheight_disp(color=color), D = d.txdate_disp( 'date_time' ), t = d.txid_disp( width=None, color=color ), - A = d.amt_disp(True).hl( color=color ), - B = d.amt_disp(False).hl( color=color ), + 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 ), N = d.nOutputs, diff --git a/mmgen/tw/unspent.py b/mmgen/tw/unspent.py index 7f546768..a50c0c7b 100755 --- a/mmgen/tw/unspent.py +++ b/mmgen/tw/unspent.py @@ -170,15 +170,15 @@ class TwUnspentOutputs(TwView): yield fs.format( n = str(n+1) + ')', t = (CoinTxID.fmtc('|' + '.'*(cw.txid-1),color=color) if d.skip == 'txid' - else d.txid.truncate(width=cw.txid,color=color)) if cw.txid else None, - v = ' ' + d.vout.fmt(width=cw.vout-1,color=color) if cw.vout else None, - a = type(d.addr).fmtc('|' + '.'*(cw.addr-1),width=cw.addr,color=color) if d.skip == 'addr' - else d.addr.fmt(width=cw.addr,color=color), - m = (MMGenID.fmtc('.'*cw.mmid,color=color) if d.skip == 'addr' - else d.twmmid.fmt(width=cw.mmid,color=color)) if cw.mmid else None, - c = d.comment.fmt(width=cw.comment,color=color,nullrepl='-') if cw.comment else None, - A = d.amt.fmt(color=color,prec=self.disp_prec), - B = d.amt2.fmt(color=color,prec=self.disp_prec) if cw.amt2 else None, + else d.txid.truncate( width=cw.txid, color=color )) if cw.txid else None, + v = ' ' + d.vout.fmt( width=cw.vout-1, color=color ) if cw.vout else None, + a = type(d.addr).fmtc( '|' + '.'*(cw.addr-1), width=cw.addr, color=color ) if d.skip == 'addr' + else d.addr.fmt( width=cw.addr, color=color ), + m = (MMGenID.fmtc( '.'*cw.mmid, color=color ) if d.skip == 'addr' + else d.twmmid.fmt( width=cw.mmid, color=color )) if cw.mmid else None, + c = d.comment.fmt( width=cw.comment, color=color, nullrepl='-' ) if cw.comment else None, + A = d.amt.fmt( color=color, prec=self.disp_prec ), + B = d.amt2.fmt( color=color, prec=self.disp_prec ) if cw.amt2 else None, d = self.age_disp(d,self.age_fmt), ) @@ -199,15 +199,15 @@ class TwUnspentOutputs(TwView): for n,d in enumerate(data): yield fs.format( n = str(n+1) + ')', - t = d.txid.fmt(color=color) if cw.txid else None, - v = ' ' + d.vout.fmt(width=cw.vout-1,color=color) if cw.vout else None, - a = d.addr.fmt(width=cw.addr,color=color), - m = d.twmmid.fmt(width=cw.mmid,color=color), - A = d.amt.fmt(color=color,prec=self.disp_prec), - B = d.amt2.fmt(color=color,prec=self.disp_prec) if cw.amt2 else None, + t = d.txid.fmt( color=color ) if cw.txid else None, + v = ' ' + d.vout.fmt( width=cw.vout-1, color=color ) if cw.vout else None, + a = d.addr.fmt( width=cw.addr, color=color ), + m = d.twmmid.fmt( width=cw.mmid, color=color ), + A = d.amt.fmt( color=color, prec=self.disp_prec ), + B = d.amt2.fmt( color=color, prec=self.disp_prec ) if cw.amt2 else None, b = self.age_disp(d,'block'), D = self.age_disp(d,'date_time'), - c = d.comment.fmt(width=cw.comment,color=color,nullrepl='-'), + c = d.comment.fmt( width=cw.comment, color=color, nullrepl='-' ), ).rstrip() def display_total(self): diff --git a/mmgen/tw/view.py b/mmgen/tw/view.py index ed6762ef..b6003396 100755 --- a/mmgen/tw/view.py +++ b/mmgen/tw/view.py @@ -51,6 +51,7 @@ class TwView(MMGenObject,metaclass=AsyncInit): print_header = '' has_wallet = True + has_amt2 = False dates_set = False cols = None reverse = False diff --git a/test/test.py b/test/test.py index 854dbc02..9bbb2c65 100755 --- a/test/test.py +++ b/test/test.py @@ -578,15 +578,22 @@ class TestSuiteRunner(object): self.ts.extra_spawn_args + args ) - for i in args: + qargs = ['{q}{}{q}'.format( a, q = "'" if ' ' in a else '' ) for a in args] + cmd_disp = ' '.join(qargs).replace('\\','/') # for mingw + + if opt.log: + self.log_fd.write('[{}][{}:{}] {}\n'.format( + proto.coin.lower(), + self.ts.group_name, + self.ts.test_name, + cmd_disp)) + + for i in args: # die only after writing log entry if not isinstance(i,str): die(2,'Error: missing input files in cmd line?:\nName: {}\nCmdline: {!r}'.format( self.ts.test_name, args )) - qargs = ['{q}{}{q}'.format( a, q = "'" if ' ' in a else '' ) for a in args] - cmd_disp = ' '.join(qargs).replace('\\','/') # for mingw - if not no_msg: t_pfx = '' if opt.no_timings else f'[{time.time() - self.start_time:08.2f}] ' if opt.verbose or opt.print_cmdline or opt.exact_output: @@ -603,13 +610,6 @@ class TestSuiteRunner(object): if msg_only: return - if opt.log: - self.log_fd.write('[{}][{}:{}] {}\n'.format( - proto.coin.lower(), - self.ts.group_name, - self.ts.test_name, - cmd_disp)) - # NB: the `pexpect_spawn` arg enables hold_protect and send_delay while the corresponding cmdline # option does not. For performance reasons, this is the desired behavior. For full emulation of # the user experience with hold protect enabled, specify --buf-keypress or --demo.