Browse Source

a few minor fixes and cleanups

The MMGen Project 4 years ago
parent
commit
5a5f88b75d
4 changed files with 24 additions and 25 deletions
  1. 4 4
      README.md
  2. 8 8
      mmgen/base_obj.py
  3. 10 11
      mmgen/tool.py
  4. 2 2
      test/tooltest2.py

+ 4 - 4
README.md

@@ -34,7 +34,7 @@ to all your crypto assets.  The seed can be stored in many different formats:
 as a password-encrypted wallet (the default), as a one-line base58 or
 hexadecimal seed file, as formatted “dieroll base6” data, as an Electrum-based
 or BIP39 mnemonic seed phrase, as a brainwallet passphrase, or as “incognito
-data” hideable within random data in a file or block device.  Conversion between
+data” hideable within random data in a file or block device.  Conversion among
 all formats is supported.
 
 ***mmgen-txcreate running in a terminal window***
@@ -60,9 +60,9 @@ found in contemporary English poetry.  The high emotional impact of these words
 makes seed phrases easy to memorize.  Curiously, only 861 of them are shared by
 the more prosaic 2048-word [BIP39 wordlist][bw] used in most wallets today.
 
-Beginning with version 0.12.0, BIP39 mnemonic format is also supported, allowing
-you to use MMGen as a master wallet for other wallets supporting that widespread
-standard.
+Beginning with version 0.12.0, the BIP39 mnemonic format is also supported,
+allowing you to use MMGen as a master wallet for other wallets supporting that
+widespread standard.
 
 #### A brief overview of MMGen’s unique feature set:
 

+ 8 - 8
mmgen/base_obj.py

@@ -25,9 +25,9 @@ class AttrCtrl:
 	After instance is locked, forbid setting any attribute if the attribute is not present
 	in either the class or instance dict.
 
-	If _use_class_attr is True, ensure that attribute's type matches that of the class
-	attribute, unless the class attribute is set to None, in which case no type checking
-	is performed.
+	Ensure that attribute's type matches that of the instance attribute, or the class
+	attribute, if _use_class_attr is True.  If the instance or class attribute is set
+	to None, no type checking is performed.
 	"""
 	_lock = False
 	_use_class_attr = False
@@ -61,12 +61,12 @@ class AttrCtrl:
 class Lockable(AttrCtrl):
 	"""
 	After instance is locked, its attributes become read-only, with the following exceptions:
-	  - if the attribute's name is in _set_ok, attr can be set once after locking, if unset
-	  - if the attribute's name is in _reset_ok, read-only restrictions are bypassed and only
+	  - if an attribute's name is in _set_ok, it can be set once after locking, if unset
+	  - if an attribute's name is in _reset_ok, read-only restrictions are bypassed and only
 	    AttrCtrl checking is performed
 
-	To determine whether an attribute is set, it's matched against either None or the class attribute,
-	if _use_class_attr is True
+	An attribute is considered unset if its value is None, or if it is present in the instance
+	__dict__, if _use_class_attr is True.
 	"""
 	_set_ok = ()
 	_reset_ok = ()
@@ -83,6 +83,6 @@ class Lockable(AttrCtrl):
 					raise AttributeError(
 						f'attribute {name!r} of {type(self).__name__} object is already set,'
 						+ ' and resetting is forbidden' )
-			# name is in (_set_ok + _reset_ok) -- allow name to be in both lists
+			# else name is in (_set_ok + _reset_ok) -- allow name to be in both lists
 
 		return AttrCtrl.__setattr__(self,name,value)

+ 10 - 11
mmgen/tool.py

@@ -637,20 +637,20 @@ class MMGenToolCmdFile(MMGenToolCmds):
 	"utilities for viewing/checking MMGen address and transaction files"
 
 	def _file_chksum(self,mmgen_addrfile,objname):
-		verbose = opt.verbose
-		opt.verbose = False
-		opt.yes = True
-		opt.quiet = True
-		from .addr import AddrList,KeyAddrList,PasswordList
-		ret = locals()[objname](self.proto,mmgen_addrfile)
+		verbose,yes,quiet = [bool(i) for i in (opt.verbose,opt.yes,opt.quiet)]
+		opt.verbose,opt.yes,opt.quiet = (False,True,True)
+		ret = globals()[objname](self.proto,mmgen_addrfile)
+		opt.verbose,opt.yes,opt.quiet = (verbose,yes,quiet)
 		if verbose:
 			if ret.al_id.mmtype.name == 'password':
-				fs = 'Passwd fmt:  {}\nPasswd len:  {}\nID string:   {}'
-				msg(fs.format(capfirst(ret.pw_info[ret.pw_fmt].desc),ret.pw_len,ret.pw_id_str))
+				msg('Passwd fmt:  {}\nPasswd len:  {}\nID string:   {}'.format(
+					capfirst(ret.pw_info[ret.pw_fmt].desc),
+					ret.pw_len,
+					ret.pw_id_str ))
 			else:
 				msg(f'Base coin:   {ret.base_coin} {capfirst(ret.network)}')
-				msg('MMType:      {}'.format(capfirst(ret.al_id.mmtype.name)))
-			msg('List length: {}'.format(len(ret.data)))
+				msg(f'MMType:      {capfirst(ret.al_id.mmtype.name)}')
+			msg(    f'List length: {len(ret.data)}')
 		return ret.chksum
 
 	def addrfile_chksum(self,mmgen_addrfile:str):
@@ -1112,7 +1112,6 @@ class MMGenToolCmdMonero(MMGenToolCmds):
 			g.accept_defaults = g.accept_defaults or op.accept_defaults
 			from .protocol import init_proto
 			proto = init_proto('xmr',network='mainnet')
-			from .addr import AddrList
 			al = KeyAddrList(proto,infile)
 			data = [d for d in al.data if addrs == '' or d.idx in AddrIdxList(addrs)]
 			dl = len(data)

+ 2 - 2
test/tooltest2.py

@@ -700,7 +700,7 @@ tests = {
 			'zec_mainnet': [
 				( ['test/ref/zcash/98831F3A-ZEC-C[1,31-33,500-501,1010-1011].addrs'],'903E 7225 DD86 6E01'),
 				( ['test/ref/zcash/98831F3A-ZEC-Z[1,31-33,500-501,1010-1011].addrs'], '9C7A 72DC 3D4A B3AF',
-					['--type=zcash_z'], 'opt.type = "zcash_z"' ),
+					['--type=zcash_z'], 'zcash_z' ),
 			],
 			'xmr_mainnet': [
 				( ['test/ref/monero/98831F3A-XMR-M[1,31-33,500-501,1010-1011].addrs'],'4369 0253 AC2C 0E38'), ],
@@ -733,7 +733,7 @@ tests = {
 				( ['test/ref/zcash/98831F3A-ZEC-C[1,31-33,500-501,1010-1011].akeys.mmenc'],
 				'F05A 5A5C 0C8E 2617', kafile_opts ),
 				( ['test/ref/zcash/98831F3A-ZEC-Z[1,31-33,500-501,1010-1011].akeys.mmenc'], '6B87 9B2D 0D8D 8D1E',
-					kafile_opts + ['--type=zcash_z'], 'opt.type = "zcash_z"' ),
+					kafile_opts + ['--type=zcash_z'], 'zcash_z' ),
 			],
 			'xmr_mainnet': [
 				( ['test/ref/monero/98831F3A-XMR-M[1,31-33,500-501,1010-1011].akeys.mmenc'],