Browse Source

type(self).__name__ -> self.name

The MMGen Project 1 year ago
parent
commit
b01e825fc4

+ 2 - 2
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')

+ 2 - 2
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,

+ 3 - 2
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

+ 1 - 1
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)]
 

+ 1 - 1
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
 

+ 1 - 0
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