minor cleanups

This commit is contained in:
The MMGen Project 2023-10-18 12:11:49 +00:00
commit 3524ee0932
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
9 changed files with 20 additions and 36 deletions

View file

@ -19,7 +19,7 @@ examples/coin-daemon-info.py:
# Testing mode:
#
# 1) From the MMGen repository root, start the mainnet test suite daemons as follows
# (note that openethereum is the default testing daemon for ETH):
# (note that Geth is the default testing daemon for ETH):
#
# test/start-coin-daemons.py btc ltc eth
#

View file

@ -172,13 +172,13 @@ class CoinAddr(HiliteStr,InitErrors,MMGenObject):
return self._parsed
@classmethod
def fmtc(cls,s,width,**kwargs):
return super().fmtc( s=s[:width-2]+'..' if len(s) > width else s, width=width, **kwargs )
def fmtc(cls,s,width,color=False):
return super().fmtc( s=s[:width-2]+'..' if len(s) > width else s, width=width, color=color )
def fmt(self,width,**kwargs):
def fmt(self,width,color=False):
return (
super().fmtc( s=self[:width-2]+'..', width=width, **kwargs ) if len(self) > width else
super().fmt( width=width, **kwargs )
super().fmtc( s=self[:width-2]+'..', width=width, color=color ) if len(self) > width else
super().fmt( width=width, color=color )
)
def is_coin_addr(proto,s):

View file

@ -20,9 +20,7 @@
contrib.license: Copyright notice and text of GPLv3
"""
from ..cfg import gc
warning = f"""
warning = """
{gc.proj_name} Copyright (C) {gc.Cdates} by {gc.author} {gc.email}. This
program comes with ABSOLUTELY NO WARRANTY. This is free software, and
you are welcome to redistribute it under certain conditions.

View file

@ -20,7 +20,7 @@
mn_entry.py - Mnemonic user entry methods for the MMGen suite
"""
import time
import sys,time
from .util import msg,msg_r,fmt,fmt_list,capfirst,die,ascii_lowercase
from .term import get_char,get_char_raw
@ -297,8 +297,7 @@ class MnemonicEntry:
lo = idx + 1
def get_cls_by_entry_mode(self,entry_mode):
import mmgen.mn_entry
return getattr( mmgen.mn_entry, 'MnEntryMode'+capfirst(entry_mode) )
return getattr(sys.modules[__name__], 'MnEntryMode' + capfirst(entry_mode))
def choose_entry_mode(self):
msg('Choose an entry mode:\n')
@ -430,6 +429,5 @@ def mn_entry(cfg,wl_id,entry_mode=None):
me.bconv = getattr(importlib.import_module(f'mmgen.{me.modname}'),me.modname)(wl_id)
me.wl = me.bconv.digits
if entry_mode:
import mmgen.mn_entry
me.em = getattr( mmgen.mn_entry, 'MnEntryMode'+capfirst(entry_mode) )(me)
me.em = getattr(sys.modules[__name__], 'MnEntryMode' + capfirst(entry_mode))(me)
return me

View file

@ -186,7 +186,7 @@ class coin_msg:
yield res
hdr_data = {
'message': ('Message:', lambda v: grnbg(v) ),
'message': ('Message:', grnbg ),
'network': ('Network:', lambda v: v.replace('_',' ').upper() ),
'msghash_type': ('Message Hash Type:', lambda v: v ),
'addrlists': ('Address Ranges:', lambda v: fmt_list(v,fmt='bare') ),

View file

@ -284,15 +284,15 @@ class Int(int,Hilite,InitErrors):
except Exception as e:
return cls.init_fail(e,n)
def fmt(self,**kwargs):
return super().fmtc(self.__str__(),**kwargs)
@classmethod
def fmtc(cls,s,**kwargs):
return super().fmtc(s.__str__(),**kwargs)
def fmtc(cls,s,width,color=False):
return super().fmtc(str(s), width=width, color=color)
def fmt(self,width,color=False):
return super().fmtc(str(self), width=width, color=color)
def hl(self,**kwargs):
return super().colorize(self.__str__(),**kwargs)
return super().colorize(str(self), **kwargs)
class NonNegativeInt(Int):
min_val = 0

View file

@ -139,7 +139,8 @@ def do_license_msg(cfg,immed=False):
return
import mmgen.contrib.license as gpl
msg(gpl.warning)
from mmgen.cfg import gc
msg(gpl.warning.format(gc=gc))
from .term import get_char
prompt = "Press 'w' for conditions and warranty info, or 'c' to continue: "

View file

@ -130,7 +130,7 @@ def format_elapsed_hr(t,now=None,cached={}):
if not e in cached:
abs_e = abs(e)
cached[e] = ' '.join(
'{} {}{}'.format(n,desc,suf(n)) for desc,n in (
f'{n} {desc}{suf(n)}' for desc,n in (
('day', abs_e // 86400),
('hour', abs_e // 3600 % 24),
('minute', abs_e // 60 % 60),

View file

@ -46,19 +46,6 @@ disable = [
"function-redefined",
"method-hidden",
]
# Disable these too for mostly quiet output without --errors-only:
# "missing-function-docstring",
# "missing-class-docstring",
# "import-outside-toplevel",
# "multiple-imports",
# "wrong-import-position",
# "protected-access",
# "invalid-name",
# "too-few-public-methods",
# "super-init-not-called",
# "unnecessary-lambda-assignment",
# "attribute-defined-outside-init",
# "fixme",
[tool.pylint.miscellaneous]
notes = ["FIXME", "TODO", "DEBUG", "WIP"]