mmgen-wallet/test/overlay/__init__.py

67 lines
1.8 KiB
Python
Raw Normal View History

2021-10-10 20:18:14 +00:00
import sys,os,shutil
2022-02-03 20:40:41 +00:00
def get_overlay_dir(repo_root):
return os.path.join(repo_root,'test','overlay','tree')
def overlay_setup(repo_root):
def process_srcdir(d):
relpath = d.split('.')
srcdir = os.path.join(repo_root,*relpath)
destdir = os.path.join(overlay_dir,*relpath)
fakemod_dir = os.path.join(fakemod_root,*(relpath[1:]))
os.makedirs(destdir)
for fn in os.listdir(srcdir):
if (
fn.endswith('.py') or
d == 'mmgen.data' or
d == 'mmgen.proto.secp256k1' and fn.startswith('secp256k1')
):
if os.path.exists(os.path.join(fakemod_dir,fn)):
2021-10-10 20:18:14 +00:00
make_link(
os.path.join(fakemod_dir,fn),
os.path.join(destdir,fn) )
2021-10-13 20:44:43 +00:00
# link_fn = fn.removesuffix('.py') + '_orig.py' # Python 3.9
link_fn = fn[:-3] + '_orig.py'
else:
link_fn = fn
2021-10-10 20:18:14 +00:00
make_link(
os.path.join(srcdir,fn),
os.path.join(destdir,link_fn) )
2022-02-03 20:40:41 +00:00
overlay_dir = get_overlay_dir(repo_root)
2021-10-10 20:18:14 +00:00
if not os.path.exists(os.path.join(overlay_dir,'mmgen','main.py')):
2022-06-11 16:11:01 +00:00
fakemod_root = os.path.join(repo_root,'test','overlay','fakemods')
make_link = os.symlink if sys.platform == 'linux' else shutil.copy2
2021-10-10 20:18:14 +00:00
sys.stderr.write('Setting up overlay tree\n')
2021-10-13 20:44:43 +00:00
shutil.rmtree(overlay_dir,ignore_errors=True)
for d in (
'mmgen',
'mmgen.contrib',
2022-02-03 20:40:42 +00:00
'mmgen.data',
'mmgen.proto',
'mmgen.proto.bch',
'mmgen.proto.btc',
'mmgen.proto.btc.tx',
'mmgen.proto.btc.tw',
'mmgen.proto.etc',
'mmgen.proto.eth',
'mmgen.proto.eth.pyethereum',
'mmgen.proto.eth.rlp',
'mmgen.proto.eth.rlp.sedes',
'mmgen.proto.eth.tx',
'mmgen.proto.eth.tw',
'mmgen.proto.ltc',
'mmgen.proto.secp256k1',
'mmgen.proto.xmr',
'mmgen.proto.zec',
2022-02-03 20:40:42 +00:00
'mmgen.share',
'mmgen.tool',
'mmgen.tx',
'mmgen.tw',
2022-02-10 12:51:42 +00:00
'mmgen.wallet',
'mmgen.wordlist' ):
process_srcdir(d)
return overlay_dir