pylint: branch logic
This commit is contained in:
parent
70bc4ffa8f
commit
02ff2dd94a
11 changed files with 18 additions and 34 deletions
|
|
@ -51,8 +51,7 @@ def parse_version_bytes(vb_hex):
|
|||
for e in chainparams_data[f'bip-{bipnum}'].values():
|
||||
if vb_hex in (e.vb_pub, e.vb_prv):
|
||||
return (bipnum, e)
|
||||
else:
|
||||
raise ValueError(f'0x{vb_hex}: unrecognized extended key version bytes')
|
||||
raise ValueError(f'0x{vb_hex}: unrecognized extended key version bytes')
|
||||
|
||||
def compress_pubkey(pubkey_bytes):
|
||||
# see: proto.secp256k1.keygen.pubkey_format()
|
||||
|
|
|
|||
|
|
@ -543,13 +543,13 @@ class Config(Lockable):
|
|||
for name,val in ((k,v) for k,v in os.environ.items() if k.startswith('MMGEN_')):
|
||||
if name == 'MMGEN_DEBUG_ALL':
|
||||
continue
|
||||
elif name in self._env_opts:
|
||||
if name in self._env_opts:
|
||||
if val: # ignore empty string values; string value of '0' or 'false' sets variable to False
|
||||
disable = name.startswith('MMGEN_DISABLE_')
|
||||
gname = name[(6,14)[disable]:].lower()
|
||||
if gname in self._uopts: # don’t touch attr if already set by user
|
||||
continue
|
||||
elif hasattr(self,gname):
|
||||
if hasattr(self,gname):
|
||||
setattr(
|
||||
self,
|
||||
gname,
|
||||
|
|
|
|||
|
|
@ -380,8 +380,7 @@ class Crypto:
|
|||
if pw == pw_chk:
|
||||
self.util.vmsg('Passphrases match')
|
||||
break
|
||||
else:
|
||||
msg('Passphrases do not match. Try again.')
|
||||
msg('Passphrases do not match. Try again.')
|
||||
else:
|
||||
die(2,f'User failed to duplicate passphrase in {gc.passwd_max_tries} attempts')
|
||||
|
||||
|
|
|
|||
|
|
@ -239,8 +239,7 @@ class Daemon(Lockable):
|
|||
if self.state == req_state:
|
||||
return True
|
||||
time.sleep(0.2)
|
||||
else:
|
||||
die(2,f'Wait for state {req_state!r} timeout exceeded for {self.desc} (port {self.bind_port})')
|
||||
die(2,f'Wait for state {req_state!r} timeout exceeded for {self.desc} (port {self.bind_port})')
|
||||
|
||||
@classmethod
|
||||
def get_exec_version_str(cls):
|
||||
|
|
|
|||
|
|
@ -39,8 +39,7 @@ def truncate_str(s,width): # width = screen width
|
|||
return s[:n-1] + ('',' ')[
|
||||
unicodedata.east_asian_width(ch) in ('F','W')
|
||||
and n + wide_count == width + 1]
|
||||
else:
|
||||
raise ValueError('string requires no truncating')
|
||||
raise ValueError('string requires no truncating')
|
||||
|
||||
class Hilite:
|
||||
|
||||
|
|
|
|||
|
|
@ -119,9 +119,8 @@ class EthereumTwCtl(TwCtl):
|
|||
del r[k]
|
||||
self.write()
|
||||
return ret
|
||||
else:
|
||||
msg(f'Address {addr!r} not found in {self.data_root_desc!r} section of tracking wallet')
|
||||
return None
|
||||
msg(f'Address {addr!r} not found in {self.data_root_desc!r} section of tracking wallet')
|
||||
return None
|
||||
|
||||
@write_mode
|
||||
async def set_label(self,coinaddr,lbl):
|
||||
|
|
@ -130,28 +129,22 @@ class EthereumTwCtl(TwCtl):
|
|||
d['comment'] = lbl.comment
|
||||
self.write()
|
||||
return True
|
||||
else:
|
||||
msg(f'Address {coinaddr!r} not found in {self.data_root_desc!r} section of tracking wallet')
|
||||
return False
|
||||
msg(f'Address {coinaddr!r} not found in {self.data_root_desc!r} section of tracking wallet')
|
||||
return False
|
||||
|
||||
async def addr2sym(self,req_addr):
|
||||
for addr in self.data['tokens']:
|
||||
if addr == req_addr:
|
||||
return self.data['tokens'][addr]['params']['symbol']
|
||||
else:
|
||||
return None
|
||||
|
||||
async def sym2addr(self,sym):
|
||||
for addr in self.data['tokens']:
|
||||
if self.data['tokens'][addr]['params']['symbol'] == sym.upper():
|
||||
return addr
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_token_param(self,token,param):
|
||||
if token in self.data['tokens']:
|
||||
return self.data['tokens'][token]['params'].get(param)
|
||||
return None
|
||||
|
||||
@property
|
||||
def sorted_list(self):
|
||||
|
|
|
|||
|
|
@ -40,8 +40,7 @@ class mainnet(mainnet):
|
|||
for v in self.wif_ver_bytes.values():
|
||||
if key_data[:len(v)] == v:
|
||||
return len(v)
|
||||
else:
|
||||
raise ValueError('Invalid WIF version number')
|
||||
raise ValueError('Invalid WIF version number')
|
||||
|
||||
def get_addr_len(self,addr_fmt):
|
||||
return (20,64)[addr_fmt in ('zcash_z','viewkey')]
|
||||
|
|
|
|||
|
|
@ -194,8 +194,8 @@ class SubSeedList(MMGenObject):
|
|||
else:
|
||||
self.data[length][sid] = (idx,nonce)
|
||||
return last_sid == sid
|
||||
else: # must exit here, as this could leave self.data in inconsistent state
|
||||
die( 'SubSeedNonceRangeExceeded', 'add_subseed(): nonce range exceeded' )
|
||||
# must exit here, as this could leave self.data in inconsistent state
|
||||
die('SubSeedNonceRangeExceeded', 'add_subseed(): nonce range exceeded')
|
||||
|
||||
for idx in SubSeedIdxRange(first_idx,last_idx).iterate():
|
||||
match1 = add_subseed(idx,'long')
|
||||
|
|
|
|||
|
|
@ -279,8 +279,7 @@ class TwAddresses(TwView):
|
|||
for e in self.data:
|
||||
if e.addr == coinaddr:
|
||||
return bool(e.recvd)
|
||||
else: # addr not in tracking wallet
|
||||
return None
|
||||
return None # addr not in tracking wallet
|
||||
|
||||
def get_change_address(self, al_id, bot=None, top=None, exclude=None):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -103,14 +103,13 @@ class TxInfo:
|
|||
msg('')
|
||||
if reply == '' or reply in 'Nn':
|
||||
break
|
||||
elif reply in 'YyVvTt':
|
||||
if reply in 'YyVvTt':
|
||||
self.view(
|
||||
pager = reply in 'Vv',
|
||||
pause = pause,
|
||||
terse = reply in 'Tt' )
|
||||
break
|
||||
else:
|
||||
msg('Invalid reply')
|
||||
msg('Invalid reply')
|
||||
|
||||
def view(self,pager=False,pause=True,terse=False):
|
||||
o = self.format(terse=terse)
|
||||
|
|
|
|||
|
|
@ -93,8 +93,7 @@ def int2bytespec(n,spec,fmt,print_sym=True,strip=False,add_space=False):
|
|||
for k,v in bytespec_map:
|
||||
if k == spec:
|
||||
return v
|
||||
else:
|
||||
die(1,f'{spec!r}: unrecognized bytespec')
|
||||
die(1,f'{spec!r}: unrecognized bytespec')
|
||||
|
||||
ret = f'{n/spec2int(spec):{fmt}f}'
|
||||
if strip:
|
||||
|
|
@ -116,8 +115,7 @@ def parse_bytespec(nbytes):
|
|||
if k == m.group(2):
|
||||
from decimal import Decimal
|
||||
return int(Decimal(m.group(1)) * v)
|
||||
else:
|
||||
msg("Valid byte specifiers: '{}'".format("' '".join([i[0] for i in bytespec_map])))
|
||||
msg("Valid byte specifiers: '{}'".format("' '".join([i[0] for i in bytespec_map])))
|
||||
elif '.' in nbytes:
|
||||
raise ValueError('fractional bytes not allowed')
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue