tw: remove trailing space when saving output to file

This commit is contained in:
The MMGen Project 2023-09-25 13:25:01 +00:00
commit 0a15625e83
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 10 additions and 6 deletions

View file

@ -91,7 +91,7 @@ class TwGetBalance(MMGenObject,metaclass=AsyncInit):
lbl = 'Wallet',
w = col1_w + iwidth_adj,
cols = ' '.join(v.format(minconf=self.minconf).ljust(iwidths[k]+add_w)
for k,v in self.conf_cols.items()) )
for k,v in self.conf_cols.items()) ).rstrip()
from ..addr import MMGenID
for label in sorted(self.data.keys()):
@ -99,7 +99,7 @@ class TwGetBalance(MMGenObject,metaclass=AsyncInit):
lbl = yellow((label + ' ' + self.proto.coin).ljust(col1_w)) if label == 'TOTAL'
else MMGenID.hlc( (label+':').ljust(col1_w), color=color ),
cols = ' '.join(make_col(label,col) for col in self.conf_cols)
)
).rstrip()
for k,v in self.data.items():
if k == 'TOTAL':
@ -107,4 +107,4 @@ class TwGetBalance(MMGenObject,metaclass=AsyncInit):
if v['spendable']:
yield red(f'Warning: this wallet contains PRIVATE KEYS for {k} outputs!')
return '\n'.join(gen_output()).rstrip()
return '\n'.join(gen_output())

View file

@ -69,7 +69,7 @@ class TwJSON:
cls = json_encoder,
sort_keys = True,
separators = None if pretty else (',', ':'),
indent = 4 if pretty else None )
indent = 4 if pretty else None ) + ('\n' if pretty else '')
def make_chksum(self,data):
return make_chksum_8( self.json_dump(data).encode() ).lower()

View file

@ -23,6 +23,7 @@ tw.view: base class for tracking wallet view classes
import sys,time,asyncio
from collections import namedtuple
from ..cfg import gc,gv
from ..objmethods import Hilite,InitErrors,MMGenObject
from ..obj import get_obj,MMGenIdx,MMGenList
from ..color import nocolor,yellow,green,red,blue
@ -412,7 +413,8 @@ class TwView(MMGenObject,metaclass=AsyncInit):
yield ''
if data and dt.colhdr_fmt_method:
yield getattr(self,dt.colhdr_fmt_method)(cw,hdr_fs,color)
col_hdr = getattr(self,dt.colhdr_fmt_method)(cw,hdr_fs,color)
yield col_hdr.rstrip() if line_processing == 'print' else col_hdr
def get_body(method):
if line_processing:
@ -441,6 +443,9 @@ class TwView(MMGenObject,metaclass=AsyncInit):
[(nocolor,yellow)[color](self.nodata_msg.ljust(self.term_width))] )
)
if not gv.stdout.isatty():
line_processing = 'print'
dt = getattr(self.display_type,display_type)
if self.use_cached:
@ -515,7 +520,6 @@ class TwView(MMGenObject,metaclass=AsyncInit):
for k in self.scroll_keys['vi']:
assert k not in self.key_mappings, f'{k!r} is in key_mappings'
self.key_mappings.update(self.scroll_keys['vi'])
from ..cfg import gc
self.key_mappings.update(self.scroll_keys[gc.platform])
return self.key_mappings