pylint integration: minor compatibility changes
This commit is contained in:
parent
f2bf16bbdb
commit
055759f02a
14 changed files with 30 additions and 9 deletions
|
|
@ -243,14 +243,14 @@ def write_data_to_file(
|
|||
# not atomic, but better than nothing
|
||||
# if cmp_data is empty, file can be either empty or non-existent
|
||||
if check_data:
|
||||
d = ''
|
||||
try:
|
||||
with open(outfile,('r','rb')[bool(binary)]) as fp:
|
||||
d = fp.read()
|
||||
except:
|
||||
d = ''
|
||||
finally:
|
||||
if d != cmp_data:
|
||||
die(3,f'{desc} in file {outfile!r} has been altered by some other program! Aborting file write')
|
||||
pass
|
||||
if d != cmp_data:
|
||||
die(3,f'{desc} in file {outfile!r} has been altered by some other program! Aborting file write')
|
||||
|
||||
# To maintain portability, always open files in binary mode
|
||||
# If 'binary' option not set, encode/decode data before writing and after reading
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ class Completed(Base,TxBase.Completed):
|
|||
|
||||
def __init__(self,*args,**kwargs):
|
||||
|
||||
self.txobj = {}
|
||||
|
||||
super().__init__(*args,**kwargs)
|
||||
|
||||
self.gas = self.proto.coin_amt(self.dfl_gas,'wei')
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ class CoinProtocol(MMGenObject):
|
|||
base_proto_coin = None
|
||||
base_coin = None
|
||||
is_fork_of = None
|
||||
chain_names = None
|
||||
networks = ('mainnet','testnet','regtest')
|
||||
|
||||
def __init__(self,cfg,coin,name,network,tokensym=None,need_amt=False):
|
||||
|
|
@ -86,11 +87,11 @@ class CoinProtocol(MMGenObject):
|
|||
from .util import die
|
||||
die(2,f'Command {gc.prog_name!r} not supported for coin {self.coin}')
|
||||
|
||||
if hasattr(self,'chain_names'):
|
||||
if self.chain_names:
|
||||
self.chain_name = self.chain_names[0] # first chain name is default
|
||||
else:
|
||||
self.chain_name = self.network
|
||||
self.chain_names = [self.network]
|
||||
self.chain_name = self.network
|
||||
|
||||
if self.tokensym:
|
||||
assert self.name.startswith('Ethereum'), 'CoinProtocol.Base_chk1'
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ pyversion: Python version string operations
|
|||
|
||||
class PythonVersion(str):
|
||||
|
||||
major = 0
|
||||
minor = 0
|
||||
|
||||
def __new__(cls,arg=None):
|
||||
if isinstance(arg,PythonVersion):
|
||||
return arg
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ from struct import pack,unpack
|
|||
|
||||
class Sha2:
|
||||
'Implementation based on the pseudocode at https://en.wikipedia.org/wiki/SHA-2'
|
||||
K = None
|
||||
K = ()
|
||||
|
||||
@classmethod
|
||||
def initConstants(cls):
|
||||
|
|
@ -71,7 +71,7 @@ class Sha2:
|
|||
def __init__(self,message,preprocess=True):
|
||||
'Use preprocess=False for Sha256Compress'
|
||||
assert isinstance(message,(bytes,bytearray,list)),'message must be of type bytes, bytearray or list'
|
||||
if self.K is None:
|
||||
if not self.K:
|
||||
type(self).initConstants()
|
||||
self.H = list(self.H_init)
|
||||
self.M = message
|
||||
|
|
|
|||
|
|
@ -60,8 +60,8 @@ class MMGenTxFile(MMGenObject):
|
|||
from ..fileutil import get_data_from_file
|
||||
tx_data = get_data_from_file( tx.cfg, infile, tx.desc+' data', quiet=quiet_open )
|
||||
|
||||
desc = 'data'
|
||||
try:
|
||||
desc = 'data'
|
||||
if len(tx_data) > tx.cfg.max_tx_file_size:
|
||||
die('MaxFileSizeExceeded',
|
||||
f'Transaction file size exceeds limit ({tx.cfg.max_tx_file_size} bytes)')
|
||||
|
|
|
|||
|
|
@ -76,6 +76,13 @@ xmrwallet_uarg_info = (
|
|||
r'(?:[^:]+):(?:\d+)'
|
||||
)
|
||||
|
||||
# required to squelch pylint:
|
||||
def fmt_amt(amt):
|
||||
return str(amt)
|
||||
|
||||
def hl_amt(amt):
|
||||
return str(amt)
|
||||
|
||||
class XMRWalletAddrSpec(HiliteStr,InitErrors,MMGenObject):
|
||||
color = 'cyan'
|
||||
width = 0
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ def test_color():
|
|||
init_color()
|
||||
gmsg("\nParsed terminfo 'colors' values:")
|
||||
|
||||
from mmgen.color import orange
|
||||
for t,c in (('rxvt',8),('xterm',8),('rxvt-unicode',88),('screen-256color',256),('xterm-256color',256)):
|
||||
ret = get_terminfo_colors(t)
|
||||
if ret is None:
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ class TestKeccak(TestHashFunc):
|
|||
pass
|
||||
|
||||
class TestSha2(TestHashFunc):
|
||||
desc = 'sha2'
|
||||
|
||||
def __init__(self):
|
||||
from mmgen.sha2 import Sha256,Sha512
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import include.test_init
|
|||
|
||||
# for objtest, violate MMGen Project best practices and allow use of the dev tools
|
||||
# in production code:
|
||||
from mmgen.devtools import pmsg
|
||||
if not os.getenv('MMGEN_DEVTOOLS'):
|
||||
from mmgen.devinit import init_dev
|
||||
init_dev()
|
||||
|
|
|
|||
|
|
@ -369,6 +369,8 @@ def set_restore_term_at_exit():
|
|||
|
||||
class CmdGroupMgr:
|
||||
|
||||
dpy_data = None
|
||||
|
||||
from test.test_py_d.cfg import cmd_groups_dfl,cmd_groups_extra
|
||||
|
||||
cmd_groups = cmd_groups_dfl.copy()
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ test.unit_tests_d.ut_devtools: devtools unit tests for the MMGen suite
|
|||
|
||||
import os,json
|
||||
from mmgen.util import msg
|
||||
from mmgen.devtools import print_diff,get_ndiff,print_stack_trace,pmsg_r,pmsg,Pmsg
|
||||
from . import unit_tests_base
|
||||
|
||||
textA = """
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ test.unit_tests_d.ut_tx: TX unit tests for the MMGen suite
|
|||
|
||||
import os,re
|
||||
|
||||
from mmgen.devtools import get_diff,get_ndiff
|
||||
from mmgen.tx import NewTX,CompletedTX
|
||||
from mmgen.tx.file import MMGenTxFile
|
||||
from mmgen.daemon import CoinDaemon
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import os,json
|
|||
|
||||
from mmgen.color import purple,cyan
|
||||
from mmgen.util import msg,Msg,Msg_r
|
||||
from mmgen.devtools import Pmsg
|
||||
from mmgen.protocol import init_proto
|
||||
from mmgen.tx import CompletedTX
|
||||
from mmgen.proto.btc.tx.base import DeserializeTX
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue