function rename: base_proto_tw_subclass() -> base_proto_subclass()
This commit is contained in:
parent
4b41093ce9
commit
ef13359519
7 changed files with 17 additions and 14 deletions
|
|
@ -20,7 +20,7 @@
|
|||
addrdata.py: MMGen AddrData and related classes
|
||||
"""
|
||||
|
||||
from .util import vmsg,base_proto_tw_subclass,fmt,die
|
||||
from .util import vmsg,base_proto_subclass,fmt,die
|
||||
from .base_obj import AsyncInit
|
||||
from .obj import MMGenObject,MMGenDict,get_obj
|
||||
from .addr import MMGenID,AddrListID
|
||||
|
|
@ -69,7 +69,7 @@ class AddrData(MMGenObject):
|
|||
class TwAddrData(AddrData,metaclass=AsyncInit):
|
||||
|
||||
def __new__(cls,proto,*args,**kwargs):
|
||||
return MMGenObject.__new__(base_proto_tw_subclass(cls,proto,'common'))
|
||||
return MMGenObject.__new__(base_proto_subclass(cls,proto,'tw','common'))
|
||||
|
||||
async def __init__(self,proto,wallet=None):
|
||||
from .rpc import rpc_init
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ def make_args_list(tw,al,batch,rescan):
|
|||
async def main():
|
||||
from .tw.ctl import TrackingWallet
|
||||
if opt.token_addr:
|
||||
proto.tokensym = 'foo' # hack to trigger 'Token' in base_proto_tw_subclass()
|
||||
proto.tokensym = 'foo' # hack to trigger 'Token' in base_proto_subclass()
|
||||
|
||||
tw = await TrackingWallet(
|
||||
proto = proto,
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ twaddrs: Tracking wallet listaddresses class for the MMGen suite
|
|||
"""
|
||||
|
||||
from ..color import green
|
||||
from ..util import msg,die,base_proto_tw_subclass
|
||||
from ..util import msg,die,base_proto_subclass
|
||||
from ..base_obj import AsyncInit
|
||||
from ..obj import MMGenDict,TwComment
|
||||
from ..addr import CoinAddr,MMGenID
|
||||
|
|
@ -30,7 +30,7 @@ from .common import TwCommon
|
|||
class TwAddrList(MMGenDict,TwCommon,metaclass=AsyncInit):
|
||||
|
||||
def __new__(cls,proto,*args,**kwargs):
|
||||
return MMGenDict.__new__(base_proto_tw_subclass(cls,proto,'addrs'),*args,**kwargs)
|
||||
return MMGenDict.__new__(base_proto_subclass(cls,proto,'tw','addrs'),*args,**kwargs)
|
||||
|
||||
def raw_list(self):
|
||||
return [((k if k.type == 'mmgen' else 'Non-MMGen'),self[k]['addr'],self[k]['amt']) for k in self]
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ twbal: Tracking wallet getbalance class for the MMGen suite
|
|||
"""
|
||||
|
||||
from ..color import red,green
|
||||
from ..util import base_proto_tw_subclass
|
||||
from ..util import base_proto_subclass
|
||||
from ..base_obj import AsyncInit
|
||||
from ..objmethods import MMGenObject
|
||||
from ..rpc import rpc_init
|
||||
|
|
@ -29,7 +29,7 @@ from ..rpc import rpc_init
|
|||
class TwGetBalance(MMGenObject,metaclass=AsyncInit):
|
||||
|
||||
def __new__(cls,proto,*args,**kwargs):
|
||||
return MMGenObject.__new__(base_proto_tw_subclass(cls,proto,'bal'))
|
||||
return MMGenObject.__new__(base_proto_subclass(cls,proto,'tw','bal'))
|
||||
|
||||
async def __init__(self,proto,minconf,quiet):
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ twctl: Tracking wallet control class for the MMGen suite
|
|||
"""
|
||||
|
||||
from ..globalvars import g
|
||||
from ..util import msg,dmsg,write_mode,base_proto_tw_subclass,die
|
||||
from ..util import msg,dmsg,write_mode,base_proto_subclass,die
|
||||
from ..base_obj import AsyncInit
|
||||
from ..objmethods import MMGenObject
|
||||
from ..obj import TwComment,get_obj
|
||||
|
|
@ -38,7 +38,7 @@ class TrackingWallet(MMGenObject,metaclass=AsyncInit):
|
|||
importing = False
|
||||
|
||||
def __new__(cls,proto,*args,**kwargs):
|
||||
return MMGenObject.__new__(base_proto_tw_subclass(cls,proto,'ctl'))
|
||||
return MMGenObject.__new__(base_proto_subclass(cls,proto,'tw','ctl'))
|
||||
|
||||
async def __init__(self,proto,mode='r',token_addr=None):
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ from ..util import (
|
|||
fmt,
|
||||
keypress_confirm,
|
||||
line_input,
|
||||
base_proto_tw_subclass
|
||||
base_proto_subclass
|
||||
)
|
||||
from ..base_obj import AsyncInit
|
||||
from ..objmethods import MMGenObject
|
||||
|
|
@ -45,7 +45,7 @@ from .common import TwCommon,TwMMGenID,get_tw_label
|
|||
class TwUnspentOutputs(MMGenObject,TwCommon,metaclass=AsyncInit):
|
||||
|
||||
def __new__(cls,proto,*args,**kwargs):
|
||||
return MMGenObject.__new__(base_proto_tw_subclass(cls,proto,'unspent'))
|
||||
return MMGenObject.__new__(base_proto_subclass(cls,proto,'tw','unspent'))
|
||||
|
||||
txid_w = 64
|
||||
print_hdr_fs = '{a} (block #{b}, {c} UTC)\n{d}Sort order: {e}\n{f}\n\nTotal {g}: {h}\n'
|
||||
|
|
|
|||
|
|
@ -650,18 +650,21 @@ def get_subclasses(cls,names=False):
|
|||
yield j
|
||||
return tuple((c.__name__ for c in gen(cls)) if names else gen(cls))
|
||||
|
||||
def base_proto_tw_subclass(cls,proto,modname):
|
||||
def base_proto_subclass(cls,proto,subdir,modname):
|
||||
"""
|
||||
magic module loading and class selection
|
||||
"""
|
||||
modname = f'mmgen.base_proto.{proto.base_proto.lower()}.tw.{modname}'
|
||||
modpath = 'mmgen.base_proto.{}.{}{}'.format(
|
||||
proto.base_proto.lower(),
|
||||
subdir + '.' if subdir else '',
|
||||
modname )
|
||||
clsname = (
|
||||
proto.mod_clsname
|
||||
+ ('Token' if proto.tokensym else '')
|
||||
+ cls.__name__ )
|
||||
|
||||
import importlib
|
||||
return getattr(importlib.import_module(modname),clsname)
|
||||
return getattr(importlib.import_module(modpath),clsname)
|
||||
|
||||
# decorator for TrackingWallet
|
||||
def write_mode(orig_func):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue