tw.view: new squeezed_format_line, detail_format_line methods
This commit is contained in:
parent
2632786800
commit
9800e67dea
4 changed files with 37 additions and 35 deletions
|
|
@ -40,9 +40,11 @@ class TwAddresses(TwView):
|
|||
|
||||
class squeezed(TwView.display_type.squeezed):
|
||||
cols = ('num','mmid','used','addr','comment','amt','date')
|
||||
fmt_method = 'gen_display'
|
||||
|
||||
class detail(TwView.display_type.detail):
|
||||
cols = ('num','mmid','used','addr','comment','amt','block','date_time')
|
||||
fmt_method = 'gen_display'
|
||||
|
||||
class TwAddress(MMGenListItem):
|
||||
valid_attrs = {'twmmid','addr','al_id','confs','comment','amt','recvd','date','skip'}
|
||||
|
|
@ -176,7 +178,29 @@ class TwAddresses(TwView):
|
|||
b = 'Block',
|
||||
D = 'Date/Time' )
|
||||
|
||||
def gen_squeezed_display(self,data,cw,fs,color):
|
||||
def squeezed_format_line(self,n,d,cw,fs,color,yes,no):
|
||||
return fs.format(
|
||||
n = str(n) + ')',
|
||||
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, iwidth=cw.iwidth, prec=self.disp_prec ),
|
||||
d = self.age_disp( d, self.age_fmt )
|
||||
)
|
||||
|
||||
def detail_format_line(self,n,d,cw,fs,color,yes,no):
|
||||
return fs.format(
|
||||
n = str(n) + ')',
|
||||
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, iwidth=cw.iwidth, prec=self.disp_prec ),
|
||||
b = self.age_disp( d, 'block' ),
|
||||
D = self.age_disp( d, 'date_time' ))
|
||||
|
||||
def gen_display(self,data,cw,fs,color,fmt_method):
|
||||
|
||||
yes,no = (red('Yes '),green('No ')) if color else ('Yes ','No ')
|
||||
id_save = data[0].al_id
|
||||
|
|
@ -185,34 +209,7 @@ class TwAddresses(TwView):
|
|||
if id_save != d.al_id:
|
||||
id_save = d.al_id
|
||||
yield ''
|
||||
yield fs.format(
|
||||
n = str(n) + ')',
|
||||
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, iwidth=cw.iwidth, prec=self.disp_prec ),
|
||||
d = self.age_disp( d, self.age_fmt )
|
||||
)
|
||||
|
||||
def gen_detail_display(self,data,cw,fs,color):
|
||||
|
||||
yes,no = (red('Yes '),green('No ')) if color else ('Yes ','No ')
|
||||
id_save = data[0].al_id
|
||||
|
||||
for n,d in enumerate(data,1):
|
||||
if id_save != d.al_id:
|
||||
id_save = d.al_id
|
||||
yield ''
|
||||
yield fs.format(
|
||||
n = str(n) + ')',
|
||||
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, iwidth=cw.iwidth, prec=self.disp_prec ),
|
||||
b = self.age_disp( d, 'block' ),
|
||||
D = self.age_disp( d, 'date_time' ))
|
||||
yield fmt_method(n,d,cw,fs,color,yes,no)
|
||||
|
||||
async def set_dates(self,addrs):
|
||||
if not self.dates_set:
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ class TwTxHistory(TwView):
|
|||
|
||||
return '\n'.join(gen()) + '\n\n'
|
||||
|
||||
def gen_squeezed_display(self,data,cw,fs,color):
|
||||
def gen_squeezed_display(self,data,cw,fs,color,fmt_method):
|
||||
|
||||
for n,d in enumerate(data,1):
|
||||
yield fs.format(
|
||||
|
|
@ -135,7 +135,7 @@ class TwTxHistory(TwView):
|
|||
o = d.vouts_disp( 'outputs', width=cw.outputs, color=color ),
|
||||
c = d.comment.fmt( width=cw.comment, color=color, nullrepl='-' ) )
|
||||
|
||||
def gen_detail_display(self,data,cw,fs,color):
|
||||
def gen_detail_display(self,data,cw,fs,color,fmt_method):
|
||||
|
||||
fs = fmt("""
|
||||
{n}
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ class TwUnspentOutputs(TwView):
|
|||
D = 'Date/Time',
|
||||
c = 'Comment' )
|
||||
|
||||
def gen_squeezed_display(self,data,cw,fs,color):
|
||||
def gen_squeezed_display(self,data,cw,fs,color,fmt_method):
|
||||
|
||||
for n,d in enumerate(data):
|
||||
yield fs.format(
|
||||
|
|
@ -196,7 +196,7 @@ class TwUnspentOutputs(TwView):
|
|||
d = self.age_disp(d,self.age_fmt),
|
||||
)
|
||||
|
||||
def gen_detail_display(self,data,cw,fs,color):
|
||||
def gen_detail_display(self,data,cw,fs,color,fmt_method):
|
||||
|
||||
for n,d in enumerate(data):
|
||||
yield fs.format(
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ class TwView(MMGenObject,metaclass=AsyncInit):
|
|||
class squeezed:
|
||||
detail = False
|
||||
fmt_method = 'gen_squeezed_display'
|
||||
line_fmt_method = 'squeezed_format_line'
|
||||
hdr_fmt_method = 'squeezed_col_hdr'
|
||||
need_column_widths = True
|
||||
item_separator = '\n'
|
||||
|
|
@ -47,6 +48,7 @@ class TwView(MMGenObject,metaclass=AsyncInit):
|
|||
class detail:
|
||||
detail = True
|
||||
fmt_method = 'gen_detail_display'
|
||||
line_fmt_method = 'detail_format_line'
|
||||
hdr_fmt_method = 'detail_col_hdr'
|
||||
need_column_widths = True
|
||||
item_separator = '\n'
|
||||
|
|
@ -56,8 +58,8 @@ class TwView(MMGenObject,metaclass=AsyncInit):
|
|||
|
||||
class print:
|
||||
color = False
|
||||
def do(method,data,cw,fs,color):
|
||||
return [l.rstrip() for l in method(data,cw,fs,color)]
|
||||
def do(method,data,cw,fs,color,fmt_method):
|
||||
return [l.rstrip() for l in method(data,cw,fs,color,fmt_method)]
|
||||
|
||||
has_wallet = True
|
||||
has_amt2 = False
|
||||
|
|
@ -121,6 +123,9 @@ class TwView(MMGenObject,metaclass=AsyncInit):
|
|||
Please resize your screen to at least {} characters and hit any key:
|
||||
"""
|
||||
|
||||
squeezed_format_line = None
|
||||
detail_format_line = None
|
||||
|
||||
def __new__(cls,proto,*args,**kwargs):
|
||||
return MMGenObject.__new__(proto.base_proto_subclass(cls,cls.mod_subpath))
|
||||
|
||||
|
|
@ -357,9 +362,9 @@ class TwView(MMGenObject,metaclass=AsyncInit):
|
|||
|
||||
def get_body(method):
|
||||
if line_processing:
|
||||
return lp_cls.do(method,data,cw,fs,color)
|
||||
return lp_cls.do(method,data,cw,fs,color,getattr(self,dt.line_fmt_method))
|
||||
else:
|
||||
return method(data,cw,fs,color)
|
||||
return method(data,cw,fs,color,getattr(self,dt.line_fmt_method))
|
||||
|
||||
self._display_data[display_type] = '{a}{b}\n{c}{d}\n'.format(
|
||||
a = self.header(color),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue