diff --git a/mmgen/addrlist.py b/mmgen/addrlist.py index eaced94e..377bced4 100755 --- a/mmgen/addrlist.py +++ b/mmgen/addrlist.py @@ -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): diff --git a/mmgen/cfg.py b/mmgen/cfg.py index c3960b0d..cbc62450 100755 --- a/mmgen/cfg.py +++ b/mmgen/cfg.py @@ -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, diff --git a/mmgen/devinit.py b/mmgen/devinit.py index d6c40eaf..64f33626 100755 --- a/mmgen/devinit.py +++ b/mmgen/devinit.py @@ -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 diff --git a/mmgen/main.py b/mmgen/main.py index ef9db1b5..a6469e09 100755 --- a/mmgen/main.py +++ b/mmgen/main.py @@ -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 diff --git a/mmgen/main_addrgen.py b/mmgen/main_addrgen.py index f7e60386..d44f8aec 100755 --- a/mmgen/main_addrgen.py +++ b/mmgen/main_addrgen.py @@ -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, diff --git a/mmgen/objmethods.py b/mmgen/objmethods.py index fb3731d1..540f7920 100755 --- a/mmgen/objmethods.py +++ b/mmgen/objmethods.py @@ -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'] diff --git a/mmgen/proto/btc/tx/base.py b/mmgen/proto/btc/tx/base.py index 75e8a977..67ddf5ef 100755 --- a/mmgen/proto/btc/tx/base.py +++ b/mmgen/proto/btc/tx/base.py @@ -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 diff --git a/mmgen/proto/btc/tx/bump.py b/mmgen/proto/btc/tx/bump.py index 545ec133..93f8445c 100755 --- a/mmgen/proto/btc/tx/bump.py +++ b/mmgen/proto/btc/tx/bump.py @@ -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' diff --git a/mmgen/proto/btc/tx/completed.py b/mmgen/proto/btc/tx/completed.py index e5f18b30..184c425b 100755 --- a/mmgen/proto/btc/tx/completed.py +++ b/mmgen/proto/btc/tx/completed.py @@ -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' diff --git a/mmgen/proto/btc/tx/new.py b/mmgen/proto/btc/tx/new.py index e1bf9320..a341b313 100755 --- a/mmgen/proto/btc/tx/new.py +++ b/mmgen/proto/btc/tx/new.py @@ -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: ' diff --git a/mmgen/proto/btc/tx/online.py b/mmgen/proto/btc/tx/online.py index 5da30753..218636e5 100755 --- a/mmgen/proto/btc/tx/online.py +++ b/mmgen/proto/btc/tx/online.py @@ -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): diff --git a/mmgen/proto/btc/tx/signed.py b/mmgen/proto/btc/tx/signed.py index 4e93844c..38fc29de 100755 --- a/mmgen/proto/btc/tx/signed.py +++ b/mmgen/proto/btc/tx/signed.py @@ -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): diff --git a/mmgen/proto/btc/tx/status.py b/mmgen/proto/btc/tx/status.py index 4c9a5c31..4752635a 100755 --- a/mmgen/proto/btc/tx/status.py +++ b/mmgen/proto/btc/tx/status.py @@ -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): diff --git a/mmgen/proto/btc/tx/unsigned.py b/mmgen/proto/btc/tx/unsigned.py index 8454c863..5218c91c 100755 --- a/mmgen/proto/btc/tx/unsigned.py +++ b/mmgen/proto/btc/tx/unsigned.py @@ -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' diff --git a/mmgen/proto/eth/tx/base.py b/mmgen/proto/eth/tx/base.py index f6d66a56..4e161df2 100755 --- a/mmgen/proto/eth/tx/base.py +++ b/mmgen/proto/eth/tx/base.py @@ -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): diff --git a/mmgen/proto/eth/tx/bump.py b/mmgen/proto/eth/tx/bump.py index 944600a5..5d0e2f13 100755 --- a/mmgen/proto/eth/tx/bump.py +++ b/mmgen/proto/eth/tx/bump.py @@ -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 diff --git a/mmgen/proto/eth/tx/completed.py b/mmgen/proto/eth/tx/completed.py index 47d8550e..06354f49 100755 --- a/mmgen/proto/eth/tx/completed.py +++ b/mmgen/proto/eth/tx/completed.py @@ -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): diff --git a/mmgen/proto/eth/tx/new.py b/mmgen/proto/eth/tx/new.py index 7552f9f1..6ee21d1c 100755 --- a/mmgen/proto/eth/tx/new.py +++ b/mmgen/proto/eth/tx/new.py @@ -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' diff --git a/mmgen/proto/eth/tx/online.py b/mmgen/proto/eth/tx/online.py index e7876bc1..ff6a7c53 100755 --- a/mmgen/proto/eth/tx/online.py +++ b/mmgen/proto/eth/tx/online.py @@ -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): diff --git a/mmgen/proto/eth/tx/signed.py b/mmgen/proto/eth/tx/signed.py index d823038e..1ce2dc07 100755 --- a/mmgen/proto/eth/tx/signed.py +++ b/mmgen/proto/eth/tx/signed.py @@ -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): diff --git a/mmgen/proto/eth/tx/status.py b/mmgen/proto/eth/tx/status.py index ed937886..d8826120 100755 --- a/mmgen/proto/eth/tx/status.py +++ b/mmgen/proto/eth/tx/status.py @@ -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): diff --git a/mmgen/proto/eth/tx/unsigned.py b/mmgen/proto/eth/tx/unsigned.py index 1efd6a0d..7f21ebd0 100755 --- a/mmgen/proto/eth/tx/unsigned.py +++ b/mmgen/proto/eth/tx/unsigned.py @@ -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' diff --git a/mmgen/protocol.py b/mmgen/protocol.py index 782f9567..ca5f58c5 100755 --- a/mmgen/protocol.py +++ b/mmgen/protocol.py @@ -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 diff --git a/mmgen/term.py b/mmgen/term.py index d7c9058b..006221aa 100755 --- a/mmgen/term.py +++ b/mmgen/term.py @@ -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) ) diff --git a/mmgen/tool/help.py b/mmgen/tool/help.py index 5154f2fb..98b5b8f4 100755 --- a/mmgen/tool/help.py +++ b/mmgen/tool/help.py @@ -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 diff --git a/mmgen/ui.py b/mmgen/ui.py index 026adf95..11f5ccad 100755 --- a/mmgen/ui.py +++ b/mmgen/ui.py @@ -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 diff --git a/mmgen/util.py b/mmgen/util.py index 85c8919a..ce41e14b 100755 --- a/mmgen/util.py +++ b/mmgen/util.py @@ -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',[]) diff --git a/mmgen/wallet/enc.py b/mmgen/wallet/enc.py index 38f4720d..e8ca1653 100755 --- a/mmgen/wallet/enc.py +++ b/mmgen/wallet/enc.py @@ -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) diff --git a/test/overlay/fakemods/mmgen/tw/view.py b/test/overlay/fakemods/mmgen/tw/view.py index f2bec610..afb381f6 100644 --- a/test/overlay/fakemods/mmgen/tw/view.py +++ b/test/overlay/fakemods/mmgen/tw/view.py @@ -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 *