From 77f4fd245d2e520b995f934416d20dab3f00471d Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Mon, 27 Mar 2023 10:48:18 +0000 Subject: [PATCH] minor fixes, cleanups, whitespace --- mmgen/cfg.py | 4 +--- mmgen/data/mmgen.cfg | 6 +++--- mmgen/opts.py | 10 +++++++--- mmgen/proto/btc/rpc.py | 7 ++++++- mmgen/proto/eth/rpc.py | 8 +++++++- test/include/common.py | 2 +- test/test.py | 2 +- 7 files changed, 26 insertions(+), 13 deletions(-) diff --git a/mmgen/cfg.py b/mmgen/cfg.py index dbaef5dd..c04e4aed 100755 --- a/mmgen/cfg.py +++ b/mmgen/cfg.py @@ -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 diff --git a/mmgen/data/mmgen.cfg b/mmgen/data/mmgen.cfg index 7b4d8a30..0312e8c4 100644 --- a/mmgen/data/mmgen.cfg +++ b/mmgen/data/mmgen.cfg @@ -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 diff --git a/mmgen/opts.py b/mmgen/opts.py index e0dc6090..dc646278 100755 --- a/mmgen/opts.py +++ b/mmgen/opts.py @@ -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 === # diff --git a/mmgen/proto/btc/rpc.py b/mmgen/proto/btc/rpc.py index a8327eb4..be0ab4f9 100755 --- a/mmgen/proto/btc/rpc.py +++ b/mmgen/proto/btc/rpc.py @@ -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 diff --git a/mmgen/proto/eth/rpc.py b/mmgen/proto/eth/rpc.py index 452a179f..b2796e4e 100755 --- a/mmgen/proto/eth/rpc.py +++ b/mmgen/proto/eth/rpc.py @@ -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) diff --git a/test/include/common.py b/test/include/common.py index 042885a1..a8c28828 100755 --- a/test/include/common.py +++ b/test/include/common.py @@ -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 diff --git a/test/test.py b/test/test.py index 7fe3c3df..37f2119e 100755 --- a/test/test.py +++ b/test/test.py @@ -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'))