tw.view: skip rstrip() for screen formatting
This commit is contained in:
parent
0c4728b3fe
commit
e7a60184ed
4 changed files with 18 additions and 13 deletions
|
|
@ -193,7 +193,7 @@ class TwAddresses(TwView):
|
|||
c = 'Comment',
|
||||
A = 'Balance',
|
||||
b = 'Block',
|
||||
D = 'Date/Time' ).rstrip()
|
||||
D = 'Date/Time' )
|
||||
|
||||
yes,no = (red('Yes '),green('No ')) if color else ('Yes ','No ')
|
||||
id_save = data[0].al_id
|
||||
|
|
@ -210,8 +210,7 @@ class TwAddresses(TwView):
|
|||
c = d.comment.fmt( width=cw.comment, color=color, nullrepl='-' ),
|
||||
A = d.amt.fmt( color=color, iwidth=cw.iwidth, prec=self.disp_prec ),
|
||||
b = self.age_disp( d, 'block' ),
|
||||
D = self.age_disp( d, 'date_time' ),
|
||||
).rstrip()
|
||||
D = self.age_disp( d, 'date_time' ))
|
||||
|
||||
async def set_dates(self,addrs):
|
||||
if not self.dates_set:
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ class TwTxHistory(TwView):
|
|||
i = 'Inputs',
|
||||
A = 'Amt({})'.format('TX' if self.show_total_amt else 'Wallet'),
|
||||
o = 'Outputs',
|
||||
c = 'Comment' ).rstrip()
|
||||
c = 'Comment' )
|
||||
|
||||
for n,d in enumerate(data,1):
|
||||
yield fs.format(
|
||||
|
|
@ -117,7 +117,7 @@ class TwTxHistory(TwView):
|
|||
i = d.vouts_disp( 'inputs', width=cw.inputs, color=color ),
|
||||
A = d.amt_disp(self.show_total_amt).fmt( iwidth=cw.iwidth, prec=self.disp_prec, color=color ),
|
||||
o = d.vouts_disp( 'outputs', width=cw.outputs, color=color ),
|
||||
c = d.comment.fmt( width=cw.comment, color=color, nullrepl='-' ) ).rstrip()
|
||||
c = d.comment.fmt( width=cw.comment, color=color, nullrepl='-' ) )
|
||||
|
||||
def gen_detail_display(self,data,cw,hdr_fs,fs,color):
|
||||
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ class TwUnspentOutputs(TwView):
|
|||
B = 'Amt({})'.format(self.proto.coin),
|
||||
b = 'Block',
|
||||
D = 'Date/Time',
|
||||
c = 'Comment' ).rstrip()
|
||||
c = 'Comment' )
|
||||
|
||||
for n,d in enumerate(data):
|
||||
yield fs.format(
|
||||
|
|
@ -207,8 +207,7 @@ class TwUnspentOutputs(TwView):
|
|||
B = d.amt2.fmt( color=color, iwidth=cw.iwidth2, 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='-' ),
|
||||
).rstrip()
|
||||
c = d.comment.fmt( width=cw.comment, color=color, nullrepl='-' ))
|
||||
|
||||
def display_total(self):
|
||||
msg('\nTotal unspent: {} {} ({} output{})'.format(
|
||||
|
|
|
|||
|
|
@ -317,7 +317,7 @@ class TwView(MMGenObject,metaclass=AsyncInit):
|
|||
min(7,max(len(str(getattr(d,k).to_integral_value())) for d in data)) + 1 + self.disp_prec
|
||||
for k in self.amt_keys}
|
||||
|
||||
async def format(self,display_type,color=True,cached=False,interactive=False):
|
||||
async def format(self,display_type,color=True,cached=False,interactive=False,for_printing=False):
|
||||
|
||||
if not cached:
|
||||
|
||||
|
|
@ -342,11 +342,18 @@ class TwView(MMGenObject,metaclass=AsyncInit):
|
|||
else:
|
||||
cw = hdr_fs = fs = None
|
||||
|
||||
if for_printing:
|
||||
color = False
|
||||
|
||||
self._display_data[display_type] = '{a}{b}\n{c}\n'.format(
|
||||
a = self.header(color),
|
||||
b = self.subheader(color),
|
||||
c = dt.item_separator.join(getattr(self,dt.fmt_method)(data,cw,hdr_fs,fs,color=color))
|
||||
if data else (nocolor,yellow)[color]('[no data for requested parameters]')
|
||||
c = (
|
||||
dt.item_separator.join(
|
||||
(l.rstrip() for l in getattr(self,dt.fmt_method)(data,cw,hdr_fs,fs,color=color)))
|
||||
if for_printing else
|
||||
dt.item_separator.join(getattr(self,dt.fmt_method)(data,cw,hdr_fs,fs,color=color))
|
||||
) if data else (nocolor,yellow)[color]('[no data for requested parameters]')
|
||||
)
|
||||
|
||||
return self._display_data[display_type] + ('' if interactive else self.footer(color))
|
||||
|
|
@ -430,11 +437,11 @@ class TwView(MMGenObject,metaclass=AsyncInit):
|
|||
msg('')
|
||||
from ..fileutil import write_data_to_file
|
||||
from ..exception import UserNonConfirmation
|
||||
hdr = getattr(parent.display_type,output_type).print_header.format(parent.cols)
|
||||
print_hdr = getattr(parent.display_type,output_type).print_header.format(parent.cols)
|
||||
try:
|
||||
write_data_to_file(
|
||||
outfile = outfile,
|
||||
data = hdr + await parent.format(display_type=output_type,color=False),
|
||||
data = print_hdr + await parent.format(display_type=output_type,for_printing=True),
|
||||
desc = f'{parent.desc} listing' )
|
||||
except UserNonConfirmation as e:
|
||||
parent.oneshot_msg = yellow(f'File {outfile!r} not overwritten by user request\n\n')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue