From 24cdd980379d94d9a5de2a1860531c499c9d32db Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Thu, 10 Feb 2022 12:51:42 +0000 Subject: [PATCH] relocate modules: txfile -> tx.file, txsign -> tx.sign --- mmgen/main_autosign.py | 2 +- mmgen/main_txbump.py | 2 +- mmgen/main_txdo.py | 2 +- mmgen/main_txsign.py | 2 +- mmgen/tx/__init__.py | 2 +- mmgen/tx/completed.py | 4 ++-- mmgen/{txfile.py => tx/file.py} | 18 +++++++++--------- mmgen/{txsign.py => tx/sign.py} | 18 +++++++++--------- test/test_py_d/ts_ref_altcoin.py | 2 +- test/unit_tests_d/ut_tx.py | 2 +- 10 files changed, 27 insertions(+), 27 deletions(-) rename mmgen/{txfile.py => tx/file.py} (94%) rename mmgen/{txsign.py => tx/sign.py} (93%) diff --git a/mmgen/main_autosign.py b/mmgen/main_autosign.py index f2cbe9c5..f4e5c194 100755 --- a/mmgen/main_autosign.py +++ b/mmgen/main_autosign.py @@ -138,7 +138,7 @@ if opt.mnemonic_fmt: from .wallet import Wallet from .tx import UnsignedTX -from .txsign import txsign +from .tx.sign import txsign from .protocol import init_proto from .rpc import rpc_init diff --git a/mmgen/main_txbump.py b/mmgen/main_txbump.py index 084314ee..e7cab13e 100755 --- a/mmgen/main_txbump.py +++ b/mmgen/main_txbump.py @@ -107,7 +107,7 @@ from .fileutil import check_infile check_infile(tx_file) from .tx import * -from .txsign import * +from .tx.sign import * seed_files = get_seed_files(opt,cmd_args) if (cmd_args or opt.send) else None diff --git a/mmgen/main_txdo.py b/mmgen/main_txdo.py index d85cc0d3..867e71c1 100755 --- a/mmgen/main_txdo.py +++ b/mmgen/main_txdo.py @@ -117,7 +117,7 @@ FMT CODES: cmd_args = opts.init(opts_data) from .tx import NewTX,OnlineSignedTX -from .txsign import * +from .tx.sign import * seed_files = get_seed_files(opt,cmd_args) diff --git a/mmgen/main_txsign.py b/mmgen/main_txsign.py index c95c9431..9542f99e 100755 --- a/mmgen/main_txsign.py +++ b/mmgen/main_txsign.py @@ -108,7 +108,7 @@ for i in infiles: if not opt.info and not opt.terse_info: do_license_msg(immed=True) -from .txsign import * +from .tx.sign import * tx_files = get_tx_files(opt,infiles) seed_files = get_seed_files(opt,infiles) diff --git a/mmgen/tx/__init__.py b/mmgen/tx/__init__.py index 2e6f60b5..7cc20688 100755 --- a/mmgen/tx/__init__.py +++ b/mmgen/tx/__init__.py @@ -32,7 +32,7 @@ def _get_cls_info(clsname,modname,args,kwargs): elif 'data' in kwargs: proto = kwargs['data']['proto'] elif 'filename' in kwargs: - from ..txfile import MMGenTxFile + from .file import MMGenTxFile proto = MMGenTxFile.get_proto( kwargs['filename'], quiet_open=True ) elif clsname == 'Base': proto = None diff --git a/mmgen/tx/completed.py b/mmgen/tx/completed.py index 570ddddf..ec32aded 100755 --- a/mmgen/tx/completed.py +++ b/mmgen/tx/completed.py @@ -31,7 +31,7 @@ class Completed(Base): self.__dict__ = data self.name = type(self).__name__ else: - from ..txfile import MMGenTxFile + from .file import MMGenTxFile MMGenTxFile(self).parse(filename,quiet_open=quiet_open) self.check_serialized_integrity() @@ -49,7 +49,7 @@ class Completed(Base): @property def file(self): - from ..txfile import MMGenTxFile + from .file import MMGenTxFile return MMGenTxFile(self) @classmethod diff --git a/mmgen/txfile.py b/mmgen/tx/file.py similarity index 94% rename from mmgen/txfile.py rename to mmgen/tx/file.py index 0527bc78..12cb24e5 100755 --- a/mmgen/txfile.py +++ b/mmgen/tx/file.py @@ -17,11 +17,11 @@ # along with this program. If not, see . """ -txfile.py: Transaction file operations for the MMGen suite +tx.file: Transaction file operations for the MMGen suite """ -from .common import * -from .obj import MMGenObject,HexStr,MMGenTxID,CoinTxID,MMGenTxLabel +from ..common import * +from ..obj import MMGenObject,HexStr,MMGenTxID,CoinTxID,MMGenTxLabel class MMGenTxFile(MMGenObject): @@ -54,7 +54,7 @@ class MMGenTxFile(MMGenObject): }[desc] return io_list( parent=tx, data=[io(tx.proto,**e) for e in d] ) - from .fileutil import get_data_from_file + from ..fileutil import get_data_from_file tx_data = get_data_from_file(infile,tx.desc+' data',quiet=quiet_open) try: @@ -78,7 +78,7 @@ class MMGenTxFile(MMGenObject): c = tx_data.pop(-1) if c != '-': desc = 'encoded comment (not base58)' - from .baseconv import baseconv + from ..baseconv import baseconv comment = baseconv('b58').tobytes(c).decode() assert comment != False,'invalid comment' desc = 'comment' @@ -100,7 +100,7 @@ class MMGenTxFile(MMGenObject): desc = 'chain token in metadata' tx.chain = metadata.pop(0).lower() if len(metadata) == 5 else 'mainnet' - from .protocol import CoinProtocol,init_proto + from ..protocol import CoinProtocol,init_proto network = CoinProtocol.Base.chain_name_to_network(coin,tx.chain) desc = 'initialization of protocol' @@ -175,7 +175,7 @@ class MMGenTxFile(MMGenObject): ] if tx.label: - from .baseconv import baseconv + from ..baseconv import baseconv lines.append(baseconv('b58').frombytes(tx.label.encode(),tostr=True)) if tx.coin_txid: @@ -205,7 +205,7 @@ class MMGenTxFile(MMGenObject): if not self.fmt_data: self.fmt_data = self.format() - from .fileutil import write_data_to_file + from ..fileutil import write_data_to_file write_data_to_file( outfile = self.filename, data = self.fmt_data, @@ -217,7 +217,7 @@ class MMGenTxFile(MMGenObject): @classmethod def get_proto(cls,filename,quiet_open=False): - from .tx import BaseTX + from . import BaseTX tmp_tx = BaseTX() cls(tmp_tx).parse(filename,metadata_only=True,quiet_open=quiet_open) return tmp_tx.proto diff --git a/mmgen/txsign.py b/mmgen/tx/sign.py similarity index 93% rename from mmgen/txsign.py rename to mmgen/tx/sign.py index 7fd02333..d484e6f8 100755 --- a/mmgen/txsign.py +++ b/mmgen/tx/sign.py @@ -17,14 +17,14 @@ # along with this program. If not, see . """ -txsign: Sign a transaction generated by 'mmgen-txcreate' +tx.sign: Sign a transaction generated by 'mmgen-txcreate' """ -from .common import * -from .obj import MMGenList -from .addr import MMGenAddrType -from .addrlist import AddrIdxList,KeyAddrList -from .wallet import Wallet,get_wallet_extensions,get_wallet_cls +from ..common import * +from ..obj import MMGenList +from ..addr import MMGenAddrType +from ..addrlist import AddrIdxList,KeyAddrList +from ..wallet import Wallet,get_wallet_extensions,get_wallet_cls saved_seeds = {} @@ -109,7 +109,7 @@ def _pop_matching_fns(args,cmplist): # strips found args return list(reversed([args.pop(args.index(a)) for a in reversed(args) if get_extension(a) in cmplist])) def get_tx_files(opt,args): - from .tx.unsigned import Unsigned + from .unsigned import Unsigned ret = _pop_matching_fns(args,[Unsigned.ext]) if not ret: die(1,'You must specify a raw transaction file!') @@ -118,7 +118,7 @@ def get_tx_files(opt,args): def get_seed_files(opt,args): # favor unencrypted seed sources first, as they don't require passwords ret = _pop_matching_fns( args, get_wallet_extensions('unenc') ) - from .filename import find_file_in_dir + from ..filename import find_file_in_dir wf = find_file_in_dir(get_wallet_cls('mmgen'),g.data_dir) # Make this the first encrypted ss in the list if wf: ret.append(wf) @@ -134,7 +134,7 @@ def get_keyaddrlist(proto,opt): def get_keylist(proto,opt): if opt.keys_from_file: - from .fileutil import get_lines_from_file + from ..fileutil import get_lines_from_file return get_lines_from_file(opt.keys_from_file,'key-address data',trim_comments=True) return None diff --git a/test/test_py_d/ts_ref_altcoin.py b/test/test_py_d/ts_ref_altcoin.py index 7f7bf665..209dc13c 100755 --- a/test/test_py_d/ts_ref_altcoin.py +++ b/test/test_py_d/ts_ref_altcoin.py @@ -86,7 +86,7 @@ class TestSuiteRefAltcoin(TestSuiteRef,TestSuiteBase): """ self.write_to_tmpfile(pwfile,dfl_wpasswd) passfile = joinpath(self.tmpdir,pwfile) - from mmgen.txfile import MMGenTxFile + from mmgen.tx.file import MMGenTxFile src = TestSuiteRef.sources['ref_tx_file'] for coin,files in src.items(): if coin == 'mm1': diff --git a/test/unit_tests_d/ut_tx.py b/test/unit_tests_d/ut_tx.py index 5ee13e99..b5f05796 100755 --- a/test/unit_tests_d/ut_tx.py +++ b/test/unit_tests_d/ut_tx.py @@ -7,7 +7,7 @@ import re from mmgen.common import * from mmgen.tx import NewTX,CompletedTX -from mmgen.txfile import MMGenTxFile +from mmgen.tx.file import MMGenTxFile from mmgen.daemon import CoinDaemon from mmgen.protocol import init_proto