From 086948287446dfb45d2353e06f80e43c000d25dd Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Tue, 23 Sep 2025 09:20:53 +0000 Subject: [PATCH] assignment expressions (3 files) --- mmgen/cfgfile.py | 6 ++---- mmgen/proto/vm/tx/new.py | 3 +-- mmgen/util2.py | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/mmgen/cfgfile.py b/mmgen/cfgfile.py index 9fef1bdf..c220f6e8 100755 --- a/mmgen/cfgfile.py +++ b/mmgen/cfgfile.py @@ -79,11 +79,9 @@ class cfg_file: def get_lines(self): def gen_lines(): for lineno, line in enumerate(self.data, 1): - line = strip_comment(line) - if line == '': + if (line := strip_comment(line)) == '': continue - m = re.fullmatch(r'(\w+)(\s+)(.*)', line) - if m: + if m := re.fullmatch(r'(\w+)(\s+)(.*)', line): yield self.line_data(m[1], m[3], lineno, None) else: die('CfgFileParseError', f'Parse error in file {self.fn!r}, line {lineno}') diff --git a/mmgen/proto/vm/tx/new.py b/mmgen/proto/vm/tx/new.py index 335f21b2..fb8e9b3e 100755 --- a/mmgen/proto/vm/tx/new.py +++ b/mmgen/proto/vm/tx/new.py @@ -69,8 +69,7 @@ class New: def get_unspent_nums_from_user(self, unspent): from ....ui import line_input while True: - reply = line_input(self.cfg, 'Enter an account to spend from: ').strip() - if reply: + if reply := line_input(self.cfg, 'Enter an account to spend from: ').strip(): if not is_int(reply): msg('Account number must be an integer') elif int(reply) < 1: diff --git a/mmgen/util2.py b/mmgen/util2.py index d97a37c3..ef16e3d1 100755 --- a/mmgen/util2.py +++ b/mmgen/util2.py @@ -120,8 +120,8 @@ def int2bytespec(n, spec, fmt, *, print_sym=True, strip=False, add_space=False): + ((' ' if add_space else '') + spec if print_sym else '')) def parse_bytespec(nbytes): - m = re.match(r'([0123456789.]+)(.*)', nbytes) - if m: + + if m := re.match(r'([0123456789.]+)(.*)', nbytes): if m.group(2): for k, v in bytespec_map: if k == m.group(2):