From 9c603be62b8bf5ab7c177b3631ac14f8dce1b171 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 26 Oct 2019 11:38:23 +0000 Subject: [PATCH] minor fixes and changes --- mmgen/globalvars.py | 1 - mmgen/util.py | 10 +++++----- test/unit_tests_d/ut_baseconv.py | 6 +++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/mmgen/globalvars.py b/mmgen/globalvars.py index 2077f6a0..68232318 100755 --- a/mmgen/globalvars.py +++ b/mmgen/globalvars.py @@ -152,7 +152,6 @@ class g(object): 'hidden_incog_input_params','in_fmt' ) incompatible_opts = ( - ('base32','hex'), # mmgen-passgen ('bob','alice'), ('quiet','verbose'), ('label','keep_label'), diff --git a/mmgen/util.py b/mmgen/util.py index 4a74674e..84fb98d9 100755 --- a/mmgen/util.py +++ b/mmgen/util.py @@ -346,14 +346,14 @@ class baseconv(object): @classmethod def get_pad(cls,pad,seed_pad_func): """ - 'pad' argument to applicable baseconv methods must be either None, 'seed' or an integer. + 'pad' argument to baseconv conversion methods must be either None, 'seed' or an integer. If None, output of minimum (but never zero) length will be produced. - If 'seed', output length will be mapped from input length using seed_pad_lens. + If 'seed', output length will be mapped from input length using data in seed_pad_lens. If an integer, it refers to the minimum allowable *string length* of the output. """ if pad == None: return 0 - elif isinstance(pad,int) and type(pad) != bool: + elif type(pad) == int: return pad elif pad == 'seed': return seed_pad_func() @@ -363,7 +363,7 @@ class baseconv(object): @classmethod def tohex(cls,words_arg,wl_id,pad=None): - "convert string or list data of base specified by 'wl_id' to hex string" + "convert string or list data of base 'wl_id' to hex string" words = words_arg if isinstance(words_arg,(list,tuple)) else tuple(words_arg.strip()) @@ -392,7 +392,7 @@ class baseconv(object): @classmethod def fromhex(cls,hexstr,wl_id,pad=None,tostr=False): - "convert hex string to list or string data of base specified by 'wl_id'" + "convert hex string to list or string data of base 'wl_id'" if wl_id in ('mmgen','tirosh','bip39'): assert tostr == False,"'tostr' must be False for '{}'".format(wl_id) diff --git a/test/unit_tests_d/ut_baseconv.py b/test/unit_tests_d/ut_baseconv.py index 177a6549..4796e96b 100755 --- a/test/unit_tests_d/ut_baseconv.py +++ b/test/unit_tests_d/ut_baseconv.py @@ -120,7 +120,7 @@ class unit_test(object): for (hexstr,pad),ret_chk in data: ret = baseconv.fromhex(hexstr,wl_id=base,pad=pad,tostr=True) if pad != 'seed': - assert len(ret) >= (pad or 0), perr.format(ret,pad) + assert len(ret) >= (pad or 0), perr.format(ret,pad or 0) assert ret == ret_chk, rerr.format(ret,ret_chk) vmsg(fs.format(h=hexstr,r=ret,p=str(pad))) # msg("(('{h}',{p}),'{r}'),".format(h=hexstr,r=ret,c=ret_chk,p=pad)) @@ -137,9 +137,9 @@ class unit_test(object): pad = len(hexstr) ret = baseconv.tohex(ret_chk,wl_id=base,pad=pad) if pad == None: - assert int(ret,16) == int(hexstr,16), rerr.format(ret,ret_chk) + assert int(ret,16) == int(hexstr,16), rerr.format(int(ret,16),int(hexstr,16)) else: - assert ret == hexstr, rerr.format(ret,ret_chk) + assert ret == hexstr, rerr.format(ret,hexstr) vmsg(fs.format(h=ret_chk,r=ret,p=str(pad))) # msg("(('{h}',{p}),'{r}'),".format(h=hexstr,r=ret_chk,c=ret_chk,p=pad))