use relative imports wherever possible
This commit is contained in:
parent
a5766aae1d
commit
66f318b4ef
29 changed files with 51 additions and 54 deletions
|
|
@ -405,8 +405,8 @@ class AddrList(MMGenObject): # Address info for a single seed ID
|
|||
@property
|
||||
def file(self):
|
||||
if not hasattr(self,'_file'):
|
||||
import mmgen.addrfile as mod
|
||||
self._file = getattr( mod, type(self).__name__.replace('List','File') )(self)
|
||||
from . import addrfile
|
||||
self._file = getattr( addrfile, type(self).__name__.replace('List','File') )(self)
|
||||
return self._file
|
||||
|
||||
class KeyAddrList(AddrList):
|
||||
|
|
|
|||
|
|
@ -406,7 +406,7 @@ class Config(Lockable):
|
|||
assert cfg is None, (
|
||||
'Config(): ‘cfg’ cannot be used simultaneously with ' +
|
||||
'‘opts_data’, ‘parsed_opts’ or ‘process_opts’' )
|
||||
from mmgen.opts import UserOpts
|
||||
from .opts import UserOpts
|
||||
UserOpts(
|
||||
cfg = self,
|
||||
opts_data = opts_data,
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ devtools_funcs = {
|
|||
}
|
||||
|
||||
def devtools_call(funcname,*args,**kwargs):
|
||||
import mmgen.devtools
|
||||
return getattr(mmgen.devtools,funcname)(*args,**kwargs)
|
||||
from . import devtools
|
||||
return getattr(devtools,funcname)(*args,**kwargs)
|
||||
|
||||
def MMGenObject_call(methodname,*args,**kwargs):
|
||||
from .devtools import MMGenObjectMethods
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ def launch(mod,package='mmgen'):
|
|||
errmsg = repr(e.args[0])
|
||||
|
||||
from collections import namedtuple
|
||||
from mmgen.color import nocolor,yellow,red
|
||||
from .color import nocolor,yellow,red
|
||||
|
||||
_o = namedtuple('exit_data',['color','exit_val','fs'])
|
||||
d = {
|
||||
|
|
@ -76,6 +76,6 @@ def launch(mod,package='mmgen'):
|
|||
|
||||
except SystemExit as e:
|
||||
if os.getenv('MMGEN_EXEC_WRAPPER') and e.code != 0:
|
||||
from mmgen.color import red
|
||||
from .color import red
|
||||
sys.stdout.write(red(f'{type(e).__name__}: {e}\n'))
|
||||
raise
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@ mmgen-addrgen: Generate a series or range of addresses from an MMGen
|
|||
deterministic wallet
|
||||
"""
|
||||
|
||||
import mmgen.addrlist
|
||||
|
||||
from . import addrlist
|
||||
from .cfg import gc,Config
|
||||
from .addr import MMGenAddrType
|
||||
from .wallet import Wallet
|
||||
|
|
@ -141,7 +140,7 @@ if cfg.keygen_backend:
|
|||
from .keygen import check_backend
|
||||
check_backend( cfg, proto, cfg.keygen_backend, cfg.type )
|
||||
|
||||
idxs = mmgen.addrlist.AddrIdxList( fmt_str=cfg._args.pop() )
|
||||
idxs = addrlist.AddrIdxList( fmt_str=cfg._args.pop() )
|
||||
|
||||
from .fileutil import get_seed_file
|
||||
sf = get_seed_file(cfg,1)
|
||||
|
|
@ -158,7 +157,7 @@ if cfg.no_addresses:
|
|||
elif cfg.viewkeys:
|
||||
gen_clsname = 'ViewKeyAddrList'
|
||||
|
||||
al = getattr( mmgen.addrlist, gen_clsname )(
|
||||
al = getattr( addrlist, gen_clsname )(
|
||||
cfg = cfg,
|
||||
proto = proto,
|
||||
seed = ss_seed,
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ objmethods: Mixin classes for MMGen data objects
|
|||
"""
|
||||
|
||||
import unicodedata
|
||||
import mmgen.color as color_mod
|
||||
from . import color as color_mod
|
||||
|
||||
if 'MMGenObjectDevTools' in __builtins__: # added to builtins by devinit.init_dev()
|
||||
MMGenObject = __builtins__['MMGenObjectDevTools']
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ proto.btc.tx.base: Bitcoin base transaction class
|
|||
|
||||
from collections import namedtuple
|
||||
|
||||
import mmgen.tx.base as TxBase
|
||||
from ....tx import base as TxBase
|
||||
from ....obj import MMGenList,HexStr
|
||||
from ....util import msg,make_chksum_6,die,pp_fmt
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@
|
|||
proto.btc.tx.bump: Bitcoin transaction bump class
|
||||
"""
|
||||
|
||||
import mmgen.tx.bump as TxBase
|
||||
from ....tx import bump as TxBase
|
||||
from ....util import msg
|
||||
from .new import New
|
||||
from .completed import Completed
|
||||
from ....util import msg
|
||||
|
||||
class Bump(Completed,New,TxBase.Bump):
|
||||
desc = 'fee-bumped transaction'
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@
|
|||
proto.btc.tx.completed: Bitcoin completed transaction class
|
||||
"""
|
||||
|
||||
import mmgen.tx.completed as TxBase
|
||||
from .base import Base,scriptPubKey2addr
|
||||
from ....tx import completed as TxBase
|
||||
from ....obj import HexStr
|
||||
from ....util import msg,die
|
||||
from .base import Base,scriptPubKey2addr
|
||||
|
||||
class Completed(Base,TxBase.Completed):
|
||||
fn_fee_unit = 'satoshi'
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@
|
|||
proto.btc.tx.new: Bitcoin new transaction class
|
||||
"""
|
||||
|
||||
import mmgen.tx.new as TxBase
|
||||
from .base import Base
|
||||
from ....tx import new as TxBase
|
||||
from ....obj import MMGenTxID
|
||||
from ....util import msg,fmt,make_chksum_6,die
|
||||
from .base import Base
|
||||
|
||||
class New(Base,TxBase.New):
|
||||
usr_fee_prompt = 'Enter transaction fee: '
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ proto.btc.tx.online: Bitcoin online signed transaction class
|
|||
|
||||
import sys
|
||||
|
||||
import mmgen.tx.online as TxBase
|
||||
from .signed import Signed
|
||||
from ....tx import online as TxBase
|
||||
from ....util import msg,ymsg,rmsg,die
|
||||
from .signed import Signed
|
||||
|
||||
class OnlineSigned(Signed,TxBase.OnlineSigned):
|
||||
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@
|
|||
proto.btc.tx.signed: Bitcoin signed transaction class
|
||||
"""
|
||||
|
||||
import mmgen.tx.signed as TxBase
|
||||
from .completed import Completed
|
||||
from ....tx import signed as TxBase
|
||||
from ....util import fmt,die
|
||||
from .completed import Completed
|
||||
|
||||
class Signed(Completed,TxBase.Signed):
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ proto.btc.tx.status: Bitcoin transaction status class
|
|||
|
||||
import time
|
||||
|
||||
import mmgen.tx.status as TxBase
|
||||
from ....tx import status as TxBase
|
||||
from ....util import msg,suf,die,secs_to_dhms
|
||||
|
||||
class Status(TxBase.Status):
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@
|
|||
proto.btc.tx.unsigned: Bitcoin unsigned transaction class
|
||||
"""
|
||||
|
||||
import mmgen.tx.unsigned as TxBase
|
||||
from .completed import Completed
|
||||
from ....tx import unsigned as TxBase
|
||||
from ....obj import CoinTxID,MMGenDict
|
||||
from ....util import msg,msg_r,ymsg,suf,die
|
||||
from .completed import Completed
|
||||
|
||||
class Unsigned(Completed,TxBase.Unsigned):
|
||||
desc = 'unsigned transaction'
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ proto.eth.tx.base: Ethereum base transaction class
|
|||
|
||||
from collections import namedtuple
|
||||
|
||||
import mmgen.tx.base as TxBase
|
||||
from ....tx import base as TxBase
|
||||
from ....obj import HexStr,Int
|
||||
|
||||
class Base(TxBase.Base):
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ proto.eth.tx.bump: Ethereum transaction bump class
|
|||
|
||||
from decimal import Decimal
|
||||
|
||||
import mmgen.tx.bump as TxBase
|
||||
from ....tx import bump as TxBase
|
||||
from .completed import Completed,TokenCompleted
|
||||
from .new import New,TokenNew
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
proto.eth.tx.completed: Ethereum completed transaction class
|
||||
"""
|
||||
|
||||
import mmgen.tx.completed as TxBase
|
||||
from ....tx import completed as TxBase
|
||||
from .base import Base,TokenBase
|
||||
|
||||
class Completed(Base,TxBase.Completed):
|
||||
|
|
|
|||
|
|
@ -14,13 +14,13 @@ proto.eth.tx.new: Ethereum new transaction class
|
|||
|
||||
import json
|
||||
|
||||
import mmgen.tx.new as TxBase
|
||||
from .base import Base,TokenBase
|
||||
from ....tx import new as TxBase
|
||||
from ....obj import Int,ETHNonce,MMGenTxID,Str,HexStr
|
||||
from ....util import msg,is_int,is_hex_str,make_chksum_6,suf,die
|
||||
from ....tw.ctl import TwCtl
|
||||
from ....addr import is_mmgen_id,is_coin_addr
|
||||
from ..contract import Token
|
||||
from .base import Base,TokenBase
|
||||
|
||||
class New(Base,TxBase.New):
|
||||
desc = 'transaction'
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@
|
|||
proto.eth.tx.online: Ethereum online signed transaction class
|
||||
"""
|
||||
|
||||
import mmgen.tx.online as TxBase
|
||||
from .signed import Signed,TokenSigned
|
||||
from .. import erigon_sleep
|
||||
from ....util import msg,rmsg,die
|
||||
from ....tx import online as TxBase
|
||||
from .. import erigon_sleep
|
||||
from .signed import Signed,TokenSigned
|
||||
|
||||
class OnlineSigned(Signed,TxBase.OnlineSigned):
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@
|
|||
proto.eth.tx.signed: Ethereum signed transaction class
|
||||
"""
|
||||
|
||||
import mmgen.tx.signed as TxBase
|
||||
from .completed import Completed,TokenCompleted
|
||||
from ....tx import signed as TxBase
|
||||
from ....obj import Str,CoinTxID,ETHNonce,HexStr
|
||||
from ....addr import CoinAddr,TokenAddr
|
||||
from .completed import Completed,TokenCompleted
|
||||
|
||||
class Signed(Completed,TxBase.Signed):
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
proto.eth.tx.status: Ethereum transaction status class
|
||||
"""
|
||||
|
||||
import mmgen.tx.status as TxBase
|
||||
from ....tx import status as TxBase
|
||||
from ....util import msg,die,suf,capfirst
|
||||
|
||||
class Status(TxBase.Status):
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ proto.eth.tx.unsigned: Ethereum unsigned transaction class
|
|||
|
||||
import json
|
||||
|
||||
import mmgen.tx.unsigned as TxBase
|
||||
from .completed import Completed,TokenCompleted
|
||||
from ..contract import Token
|
||||
from ....tx import unsigned as TxBase
|
||||
from ....util import msg,msg_r
|
||||
from ....obj import Str,CoinTxID,ETHNonce,Int,HexStr
|
||||
from ....addr import CoinAddr,TokenAddr
|
||||
from ..contract import Token
|
||||
from .completed import Completed,TokenCompleted
|
||||
|
||||
class Unsigned(Completed,TxBase.Unsigned):
|
||||
desc = 'unsigned transaction'
|
||||
|
|
|
|||
|
|
@ -101,8 +101,8 @@ class CoinProtocol(MMGenObject):
|
|||
self.keccak_256 = get_keccak(cfg)
|
||||
|
||||
if need_amt:
|
||||
import mmgen.amt
|
||||
self.coin_amt = getattr(mmgen.amt,self.coin_amt)
|
||||
from . import amt
|
||||
self.coin_amt = getattr(amt,self.coin_amt)
|
||||
self.max_tx_fee = self.coin_amt(self.max_tx_fee) if hasattr(self,'max_tx_fee') else None
|
||||
else:
|
||||
self.coin_amt = None
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ def init_term(cfg,noecho=False):
|
|||
|
||||
term.init(noecho=noecho)
|
||||
|
||||
import mmgen.term as self
|
||||
from . import term as self
|
||||
for var in ('get_char','get_char_raw','kb_hold_protect','get_terminal_size'):
|
||||
setattr( self, var, getattr(term,var) )
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
tool.help: Help screen routines for the 'mmgen-tool' utility
|
||||
"""
|
||||
|
||||
from mmgen import main_tool
|
||||
from .. import main_tool
|
||||
|
||||
from .common import tool_cmd_base
|
||||
|
||||
|
|
|
|||
|
|
@ -138,8 +138,8 @@ def do_license_msg(cfg,immed=False):
|
|||
if cfg.quiet or cfg.no_license or cfg.yes or not cfg.stdin_tty:
|
||||
return
|
||||
|
||||
import mmgen.contrib.license as gpl
|
||||
from mmgen.cfg import gc
|
||||
from .contrib import license as gpl
|
||||
from .cfg import gc
|
||||
msg(gpl.warning.format(gc=gc))
|
||||
|
||||
from .term import get_char
|
||||
|
|
|
|||
|
|
@ -163,8 +163,8 @@ def die(ev,s='',stdout=False):
|
|||
else:
|
||||
raise MMGenError(ev,s,stdout)
|
||||
elif isinstance(ev,str):
|
||||
import mmgen.exception
|
||||
raise getattr(mmgen.exception,ev)(s)
|
||||
from . import exception
|
||||
raise getattr(exception,ev)(s)
|
||||
else:
|
||||
raise ValueError(f'{ev}: exit value must be string or int instance')
|
||||
|
||||
|
|
@ -396,10 +396,8 @@ class oneshot_warning:
|
|||
def do(self,wcls,div,fmt_args,reverse):
|
||||
|
||||
def do_warning():
|
||||
import mmgen.color
|
||||
message = getattr(wcls,'message')
|
||||
color = getattr( mmgen.color, getattr(wcls,'color') )
|
||||
msg(color('WARNING: ' + message.format(*fmt_args)))
|
||||
from . import color
|
||||
msg(getattr(color, getattr(wcls,'color'))('WARNING: ' + getattr(wcls,'message').format(*fmt_args)))
|
||||
|
||||
if not hasattr(wcls,'data'):
|
||||
setattr(wcls,'data',[])
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ from .base import wallet
|
|||
class wallet(wallet):
|
||||
|
||||
def __init__(self,*args,**kwargs):
|
||||
from mmgen.crypto import Crypto
|
||||
from ..crypto import Crypto
|
||||
self.crypto = Crypto(self.cfg)
|
||||
super().__init__(*args,**kwargs)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import os as overlay_fake_os
|
||||
import mmgen.tw.view_orig as overlay_fake_orig_mod
|
||||
from . import view_orig as overlay_fake_orig_mod
|
||||
|
||||
from .view_orig import *
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue