minor fixes, cleanups, whitespace

This commit is contained in:
The MMGen Project 2023-03-27 10:48:18 +00:00
commit 77f4fd245d
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
7 changed files with 26 additions and 13 deletions

View file

@ -47,7 +47,7 @@ class CfgFile(object):
message = '{} not found at {!r}'
def __init__(self):
self.fn = os.path.join(self.fn_dir,self.fn_base)
self.fn = os.path.join(g.data_dir_root,self.fn_base)
try:
with open(self.fn) as fp:
self.data = fp.read().splitlines()
@ -172,7 +172,6 @@ class CfgFileSample(CfgFile):
class CfgFileUsr(CfgFile):
desc = 'user configuration file'
warn_missing = False
fn_dir = g.data_dir_root
write_ok = True
def __init__(self):
@ -201,7 +200,6 @@ class CfgFileSampleUsr(CfgFileSample):
desc = 'sample configuration file'
warn_missing = False
fn_base = g.proj_name.lower() + '.cfg.sample'
fn_dir = g.data_dir_root
write_ok = True
chksum = None
write_metadata = True

View file

@ -1,9 +1,9 @@
# Configuration file for the MMGen suite
# Everything following a '#' is ignored.
##################
## User options ##
##################
#####################
## General options ##
#####################
# Uncomment to enable the curses-like scrolling UI for tracking wallet views
# scroll true

View file

@ -344,8 +344,8 @@ def init(
if opt.data_dir:
g.data_dir_root = os.path.normpath(os.path.abspath(opt.data_dir))
elif os.getenv('MMGEN_TEST_SUITE'):
from test.include.common import get_data_dir
g.data_dir_root = get_data_dir()
from test.include.common import get_test_data_dir
g.data_dir_root = get_test_data_dir()
else:
g.data_dir_root = os.path.join(g.home_dir,'.'+g.proj_name.lower())
@ -410,7 +410,11 @@ def init(
if g.bob or g.alice or g.carol or g.prog_name == 'mmgen-regtest':
g.regtest_user = 'bob' if g.bob else 'alice' if g.alice else 'carol' if g.carol else None
g.regtest = True
g.data_dir = os.path.join(g.data_dir_root,'regtest',g.coin.lower(),(g.regtest_user or 'none'))
g.data_dir = os.path.join(
g.data_dir_root,
'regtest',
g.coin.lower(),
(g.regtest_user or 'none') )
# === end global var initialization === #

View file

@ -103,7 +103,12 @@ class BitcoinRPCClient(RPCClient,metaclass=AsyncInit):
has_auth_cookie = True
wallet_path = '/'
async def __init__(self,proto,daemon,backend,ignore_wallet):
async def __init__(
self,
proto,
daemon,
backend,
ignore_wallet ):
self.proto = proto
self.daemon = daemon

View file

@ -35,7 +35,13 @@ class CallSigs:
class EthereumRPCClient(RPCClient,metaclass=AsyncInit):
async def __init__(self,proto,daemon,backend,ignore_wallet):
async def __init__(
self,
proto,
daemon,
backend,
ignore_wallet ):
self.proto = proto
self.daemon = daemon
self.call_sigs = getattr(CallSigs,daemon.id,None)

View file

@ -87,7 +87,7 @@ def getrandstr(num_chars,no_space=False):
n,m = (94,33) if no_space else (95,32)
return ''.join( chr(i % n + m) for i in list(getrand(num_chars)) )
def get_data_dir():
def get_test_data_dir():
return os.path.join('test','data_dir' + ('','')[bool(os.getenv('MMGEN_DEBUG_UTF8'))])
# Windows uses non-UTF8 encodings in filesystem, so use raw bytes here

View file

@ -173,7 +173,7 @@ po = opts.init(opts_data,parse_only=True)
from test.include.common import *
from test.test_py_d.common import *
data_dir = get_data_dir() # include/common.py
data_dir = get_test_data_dir() # include/common.py
# step 1: delete data_dir symlink in ./test;
opt.resuming = any(k in po.user_opts for k in ('resume','resume_after'))