From 389629365254a71917f0615b1281f7fb40f75f3d Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Tue, 4 Apr 2023 16:04:10 +0000 Subject: [PATCH] minor cleanups --- examples/halving-calculator.py | 6 ++++-- test/misc/get_passphrase.py | 7 +++++-- test/misc/input_func.py | 10 +++++++++- test/misc/utf8_output.py | 13 +++++-------- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/examples/halving-calculator.py b/examples/halving-calculator.py index d366a749..51374208 100755 --- a/examples/halving-calculator.py +++ b/examples/halving-calculator.py @@ -17,7 +17,7 @@ import time import mmgen.opts as opts from mmgen.util import async_run -cfg = opts.init({ +opts_data = { 'text': { 'desc': 'Estimate date of next block subsidy halving', 'usage':'[opts]', @@ -37,7 +37,9 @@ A more full-featured version of this program can be found in the mmgen-node-tools repository. """ } -}) +} + +cfg = opts.init(opts_data) def date(t): return '{}-{:02}-{:02} {:02}:{:02}:{:02}'.format(*time.gmtime(t)[:6]) diff --git a/test/misc/get_passphrase.py b/test/misc/get_passphrase.py index 6563d851..8c8341b1 100755 --- a/test/misc/get_passphrase.py +++ b/test/misc/get_passphrase.py @@ -7,7 +7,7 @@ sys.path[0] = os.curdir from mmgen.common import * -cfg = opts.init({ +opts_data = { 'text': { 'desc': '', 'usage': '', @@ -18,7 +18,10 @@ cfg = opts.init({ -L, --label=l d -m, --keep-label e """ - }},init_opts={'color':True}) + } +} + +cfg = opts.init( opts_data, init_opts={'color':True} ) def crypto(): desc = 'test data' diff --git a/test/misc/input_func.py b/test/misc/input_func.py index 7866be96..a874c3ac 100755 --- a/test/misc/input_func.py +++ b/test/misc/input_func.py @@ -7,7 +7,15 @@ sys.path[0] = os.curdir from mmgen.common import * -cfg = opts.init({'text': { 'desc': '', 'usage':'', 'options':'-e, --echo-passphrase foo' }}) +opts_data = { + 'text': { + 'desc': '', + 'usage':'', + 'options':'-e, --echo-passphrase foo', + } +} + +cfg = opts.init(opts_data) cmd_args = cfg._args diff --git a/test/misc/utf8_output.py b/test/misc/utf8_output.py index 887e501b..aa09c6a5 100755 --- a/test/misc/utf8_output.py +++ b/test/misc/utf8_output.py @@ -1,11 +1,5 @@ #!/usr/bin/env python3 -from mmgen.common import * - -cfg = opts.init() - -from mmgen.util import msg - text = { 'gr': 'Greek text: {}'.format(''.join(map(chr,list(range(913,939))))), 'ru': 'Russian text: {}'.format(''.join(map(chr,list(range(1040,1072))))), @@ -13,7 +7,10 @@ text = { 'jp': 'Japanese text: {}'.format('必要なのは、信用ではなく暗号化された証明に基づく電子取引システムであり、') } -if not cfg._args or not cfg._args[0] in text: +import sys +from mmgen.util import msg,die + +if len(sys.argv) != 2 or not sys.argv[1] in text: die(2,'argument must be one of {}'.format(list(text.keys()))) -msg(text[cfg._args[0]]) +msg(text[sys.argv[1]])