From 85941cb6e4f1ec6821af5db83f2ded6a092ff6a5 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Tue, 18 Jan 2022 09:10:57 +0000 Subject: [PATCH] minor help notes cleanups --- mmgen/help.py | 25 +++++++++++++++++++++++++ mmgen/main_addrgen.py | 7 +++---- mmgen/main_passgen.py | 7 ++----- mmgen/main_seedjoin.py | 2 +- mmgen/main_txbump.py | 4 +++- mmgen/main_txdo.py | 4 +++- mmgen/main_txsign.py | 4 +++- mmgen/main_wallet.py | 2 +- 8 files changed, 41 insertions(+), 14 deletions(-) diff --git a/mmgen/help.py b/mmgen/help.py index 352fe257..718f76c7 100755 --- a/mmgen/help.py +++ b/mmgen/help.py @@ -39,6 +39,31 @@ def help_notes_func(proto,po,k): class help_notes: + def password_formats(): + from .passwdlist import PasswordList + pwi_fs = '{:8} {:1} {:26} {:<7} {:<7} {}' + return '\n '.join( + [pwi_fs.format('Code','','Description','Min Len','Max Len','Default Len')] + + [pwi_fs.format(k,'-',v.desc,v.min_len,v.max_len,v.dfl_len) for k,v in PasswordList.pw_info.items()] + ) + + def dfl_mmtype(): + from .addr import MMGenAddrType + return "'{}' or '{}'".format( + proto.dfl_mmtype, + MMGenAddrType.mmtypes[proto.dfl_mmtype].name ) + + def address_types(): + from .addr import MMGenAddrType + return '\n '.join([ + "'{}','{:<12} - {}".format( k, v.name+"'", v.desc ) + for k,v in MMGenAddrType.mmtypes.items() + ]) + + def fmt_codes(): + from .wallet import Wallet + return '\n '.join( Wallet.format_fmt_codes().splitlines() ) + def coin_id(): return proto.coin_id diff --git a/mmgen/main_addrgen.py b/mmgen/main_addrgen.py index 6049c7a9..28932a6a 100755 --- a/mmgen/main_addrgen.py +++ b/mmgen/main_addrgen.py @@ -106,7 +106,7 @@ FMT CODES: 'code': { 'options': lambda proto,help_notes,s: s.format( seed_lens=', '.join(map(str,g.seed_lens)), - dmat="'{}' or '{}'".format(proto.dfl_mmtype,MMGenAddrType.mmtypes[proto.dfl_mmtype].name), + dmat=help_notes('dfl_mmtype'), kgs=help_notes('keygen_backends'), coin_id=help_notes('coin_id'), pnm=g.proj_name, @@ -118,9 +118,8 @@ FMT CODES: n_sw=help_notes('subwallet')+'\n\n', n_pw=help_notes('passwd')+'\n\n', n_bw=help_notes('brainwallet'), - n_fmt='\n '.join(Wallet.format_fmt_codes().splitlines()), - n_at='\n '.join(["'{}','{:<12} - {}".format( - k,v.name+"'",v.desc) for k,v in MMGenAddrType.mmtypes.items()]) + n_fmt=help_notes('fmt_codes'), + n_at=help_notes('address_types'), ) } } diff --git a/mmgen/main_passgen.py b/mmgen/main_passgen.py index 10516233..c533d68a 100755 --- a/mmgen/main_passgen.py +++ b/mmgen/main_passgen.py @@ -29,7 +29,6 @@ from .wallet import Wallet from .obj import MMGenPWIDString pwi = PasswordList.pw_info -pwi_fs = '{:8} {:1} {:26} {:<7} {:<7} {}' opts_data = { 'sets': [('print_checksum',True,'quiet',True)], @@ -126,10 +125,8 @@ FMT CODES: fs="', '".join(MMGenPWIDString.forbidden), n_pw=help_notes('passwd'), n_bw=help_notes('brainwallet'), - pfi='\n '.join( - [pwi_fs.format('Code','','Description','Min Len','Max Len','Default Len')] + - [pwi_fs.format(k,'-',v.desc,v.min_len,v.max_len,v.dfl_len) for k,v in pwi.items()]), - n_fmt='\n '.join(Wallet.format_fmt_codes().splitlines()) + pfi=help_notes('password_formats'), + n_fmt=help_notes('fmt_codes'), ) } } diff --git a/mmgen/main_seedjoin.py b/mmgen/main_seedjoin.py index eec8c899..771c363b 100755 --- a/mmgen/main_seedjoin.py +++ b/mmgen/main_seedjoin.py @@ -84,7 +84,7 @@ FMT CODES: g=g, ), 'notes': lambda help_notes,s: s.format( - f='\n '.join(Wallet.format_fmt_codes().splitlines()), + f=help_notes('fmt_codes'), n_pw=help_notes('passwd'), ) } diff --git a/mmgen/main_txbump.py b/mmgen/main_txbump.py index 5f042b55..e6d5d292 100755 --- a/mmgen/main_txbump.py +++ b/mmgen/main_txbump.py @@ -76,6 +76,8 @@ opts_data = { Seed source files must have the canonical extensions listed in the 'FileExt' column below: +FMT CODES: + {f} """ }, @@ -92,7 +94,7 @@ column below: 'notes': lambda help_notes,s: s.format( help_notes('fee'), help_notes('txsign'), - f='\n '.join(Wallet.format_fmt_codes().splitlines())) + f=help_notes('fmt_codes')), } } diff --git a/mmgen/main_txdo.py b/mmgen/main_txdo.py index e88b6c83..f4f8a633 100755 --- a/mmgen/main_txdo.py +++ b/mmgen/main_txdo.py @@ -88,6 +88,8 @@ opts_data = { Seed source files must have the canonical extensions listed in the 'FileExt' column below: +FMT CODES: + {f} """ }, @@ -107,7 +109,7 @@ column below: help_notes('txcreate'), help_notes('fee'), help_notes('txsign'), - f='\n '.join(Wallet.format_fmt_codes().splitlines())) + f=help_notes('fmt_codes')), } } diff --git a/mmgen/main_txsign.py b/mmgen/main_txsign.py index ba3e4844..1463a5b4 100755 --- a/mmgen/main_txsign.py +++ b/mmgen/main_txsign.py @@ -73,6 +73,8 @@ opts_data = { Seed source files must have the canonical extensions listed in the 'FileExt' column below: +FMT CODES: + {f} """ }, @@ -88,7 +90,7 @@ column below: cu=proto.coin), 'notes': lambda help_notes,s: s.format( help_notes('txsign'), - f='\n '.join(Wallet.format_fmt_codes().splitlines())) + f=help_notes('fmt_codes')), } } diff --git a/mmgen/main_wallet.py b/mmgen/main_wallet.py index a8e3255f..4fd17329 100755 --- a/mmgen/main_wallet.py +++ b/mmgen/main_wallet.py @@ -134,7 +134,7 @@ FMT CODES: g=g, ), 'notes': lambda help_notes,s: s.format( - f='\n '.join(Wallet.format_fmt_codes().splitlines()), + f=help_notes('fmt_codes'), n_ss=('',help_notes('seedsplit')+'\n\n')[do_ss_note], n_sw=('',help_notes('subwallet')+'\n\n')[do_sw_note], n_pw=help_notes('passwd'),