From b01e825fc458d1f87170c440d119c93700c7ee8d Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 6 May 2023 15:14:05 +0000 Subject: [PATCH] type(self).__name__ -> self.name --- mmgen/proto/eth/tx/new.py | 4 ++-- mmgen/proto/xmr/rpc.py | 4 ++-- mmgen/rpc.py | 5 +++-- mmgen/xmrwallet.py | 2 +- test/test_py_d/ts_autosign.py | 2 +- test/test_py_d/ts_base.py | 1 + 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/mmgen/proto/eth/tx/new.py b/mmgen/proto/eth/tx/new.py index 323ba120..dcdd5c35 100755 --- a/mmgen/proto/eth/tx/new.py +++ b/mmgen/proto/eth/tx/new.py @@ -41,7 +41,7 @@ class New(Base,TxBase.New): if self.cfg.contract_data: m = "'--contract-data' option may not be used with token transaction" - assert not 'Token' in type(self).__name__, m + assert not 'Token' in self.name, m with open(self.cfg.contract_data) as fp: self.usr_contract_data = HexStr(fp.read().strip()) self.disable_fee_check = True @@ -81,7 +81,7 @@ class New(Base,TxBase.New): async def process_cmd_args(self,cmd_args,ad_f,ad_w): lc = len(cmd_args) - if lc == 0 and self.usr_contract_data and not 'Token' in type(self).__name__: + if lc == 0 and self.usr_contract_data and not 'Token' in self.name: return if lc != 1: die(1,f'{lc} output{suf(lc)} specified, but Ethereum transactions must have exactly one') diff --git a/mmgen/proto/xmr/rpc.py b/mmgen/proto/xmr/rpc.py index 53d2c0a1..59f03abe 100755 --- a/mmgen/proto/xmr/rpc.py +++ b/mmgen/proto/xmr/rpc.py @@ -75,7 +75,7 @@ class MoneroRPCClient(RPCClient): self.daemon_version = None def call(self,method,*params,**kwargs): - assert params == (), f'{type(self).__name__}.call() accepts keyword arguments only' + assert params == (), f'{self.name}.call() accepts keyword arguments only' return self.process_http_resp(self.backend.run_noasync( payload = {'id': 0, 'jsonrpc': '2.0', 'method': method, 'params': kwargs }, timeout = 3600, # allow enough time to sync ≈1,000,000 blocks @@ -83,7 +83,7 @@ class MoneroRPCClient(RPCClient): )) def call_raw(self,method,*params,**kwargs): - assert params == (), f'{type(self).__name__}.call() accepts keyword arguments only' + assert params == (), f'{self.name}.call() accepts keyword arguments only' return self.process_http_resp(self.backend.run_noasync( payload = kwargs, timeout = self.timeout, diff --git a/mmgen/rpc.py b/mmgen/rpc.py index b55029e4..ca7b9bcf 100755 --- a/mmgen/rpc.py +++ b/mmgen/rpc.py @@ -266,6 +266,7 @@ class RPCClient(MMGenObject): def __init__(self,cfg,host,port,test_connection=True): self.cfg = cfg + self.name = type(self).__name__ # aiohttp workaround, and may speed up RPC performance overall on some systems: if gc.platform == 'win' and host == 'localhost': @@ -275,8 +276,8 @@ class RPCClient(MMGenObject): if not self.cfg.debug_rpc: dmsg_rpc = dmsg_rpc_backend = noop - dmsg_rpc(f'=== {type(self).__name__}.__init__() debug ===') - dmsg_rpc(f' cls [{type(self).__name__}] host [{host}] port [{port}]\n') + dmsg_rpc(f'=== {self.name}.__init__() debug ===') + dmsg_rpc(f' cls [{self.name}] host [{host}] port [{port}]\n') if test_connection: import socket diff --git a/mmgen/xmrwallet.py b/mmgen/xmrwallet.py index 200f278b..78275bc4 100755 --- a/mmgen/xmrwallet.py +++ b/mmgen/xmrwallet.py @@ -494,7 +494,7 @@ class MoneroWalletOutputsFile: def get_wallet_fn(self,fn): assert fn.name.endswith(f'.{self.ext}'), ( - f'{type(self).__name__}: filename does not end with {"."+self.ext!r}' + f'{self.name}: filename does not end with {"."+self.ext!r}' ) return fn.parent / fn.name[:-(len(self.ext)+self.ext_offset+1)] diff --git a/test/test_py_d/ts_autosign.py b/test/test_py_d/ts_autosign.py index 79f1ca60..8d87cbe1 100755 --- a/test/test_py_d/ts_autosign.py +++ b/test/test_py_d/ts_autosign.py @@ -89,7 +89,7 @@ class TestSuiteAutosignBase(TestSuiteBase): return if gc.platform == 'win': - die(1,f'Test {type(self).__name__} not supported for Windows platform') + die(1,f'Test {self.name} not supported for Windows platform') self.network_ids = [c+'_tn' for c in self.daemon_coins] + self.daemon_coins diff --git a/test/test_py_d/ts_base.py b/test/test_py_d/ts_base.py index 133d291f..cb73c97c 100755 --- a/test/test_py_d/ts_base.py +++ b/test/test_py_d/ts_base.py @@ -38,6 +38,7 @@ class TestSuiteBase: def __init__(self,trunner,cfgs,spawn): if hasattr(self,'tr'): # init will be called multiple times for classes with multiple inheritance return + self.name = type(self).__name__ self.proto = cfg._proto self.tr = trunner self.cfgs = cfgs