Browse Source

minor cleanups

The MMGen Project 1 year ago
parent
commit
3524ee0932
9 changed files with 20 additions and 36 deletions
  1. 1 1
      examples/coin-daemon-info.py
  2. 5 5
      mmgen/addr.py
  3. 1 3
      mmgen/contrib/license.py
  4. 3 5
      mmgen/mn_entry.py
  5. 1 1
      mmgen/msg.py
  6. 6 6
      mmgen/obj.py
  7. 2 1
      mmgen/ui.py
  8. 1 1
      mmgen/util2.py
  9. 0 13
      pyproject.toml

+ 1 - 1
examples/coin-daemon-info.py

@@ -19,7 +19,7 @@ examples/coin-daemon-info.py:
 #  Testing mode:
 #  Testing mode:
 #
 #
 #   1) From the MMGen repository root, start the mainnet test suite daemons as follows
 #   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
 #       test/start-coin-daemons.py btc ltc eth
 #
 #

+ 5 - 5
mmgen/addr.py

@@ -172,13 +172,13 @@ class CoinAddr(HiliteStr,InitErrors,MMGenObject):
 		return self._parsed
 		return self._parsed
 
 
 	@classmethod
 	@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 (
 		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):
 def is_coin_addr(proto,s):

+ 1 - 3
mmgen/contrib/license.py

@@ -20,9 +20,7 @@
 contrib.license: Copyright notice and text of GPLv3
 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
   {gc.proj_name} Copyright (C) {gc.Cdates} by {gc.author} {gc.email}.  This
   program comes with ABSOLUTELY NO WARRANTY.  This is free software, and
   program comes with ABSOLUTELY NO WARRANTY.  This is free software, and
   you are welcome to redistribute it under certain conditions.
   you are welcome to redistribute it under certain conditions.

+ 3 - 5
mmgen/mn_entry.py

@@ -20,7 +20,7 @@
 mn_entry.py - Mnemonic user entry methods for the MMGen suite
 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 .util import msg,msg_r,fmt,fmt_list,capfirst,die,ascii_lowercase
 from .term import get_char,get_char_raw
 from .term import get_char,get_char_raw
@@ -297,8 +297,7 @@ class MnemonicEntry:
 				lo = idx + 1
 				lo = idx + 1
 
 
 	def get_cls_by_entry_mode(self,entry_mode):
 	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):
 	def choose_entry_mode(self):
 		msg('Choose an entry mode:\n')
 		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.bconv = getattr(importlib.import_module(f'mmgen.{me.modname}'),me.modname)(wl_id)
 	me.wl = me.bconv.digits
 	me.wl = me.bconv.digits
 	if entry_mode:
 	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
 	return me

+ 1 - 1
mmgen/msg.py

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

+ 6 - 6
mmgen/obj.py

@@ -284,15 +284,15 @@ class Int(int,Hilite,InitErrors):
 		except Exception as e:
 		except Exception as e:
 			return cls.init_fail(e,n)
 			return cls.init_fail(e,n)
 
 
-	def fmt(self,**kwargs):
-		return super().fmtc(self.__str__(),**kwargs)
-
 	@classmethod
 	@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):
 	def hl(self,**kwargs):
-		return super().colorize(self.__str__(),**kwargs)
+		return super().colorize(str(self), **kwargs)
 
 
 class NonNegativeInt(Int):
 class NonNegativeInt(Int):
 	min_val = 0
 	min_val = 0

+ 2 - 1
mmgen/ui.py

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

+ 1 - 1
mmgen/util2.py

@@ -130,7 +130,7 @@ def format_elapsed_hr(t,now=None,cached={}):
 	if not e in cached:
 	if not e in cached:
 		abs_e = abs(e)
 		abs_e = abs(e)
 		cached[e] = ' '.join(
 		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),
 				('day',    abs_e // 86400),
 				('hour',   abs_e // 3600 % 24),
 				('hour',   abs_e // 3600 % 24),
 				('minute', abs_e // 60 % 60),
 				('minute', abs_e // 60 % 60),

+ 0 - 13
pyproject.toml

@@ -46,19 +46,6 @@ disable = [
 	"function-redefined",
 	"function-redefined",
 	"method-hidden",
 	"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]
 [tool.pylint.miscellaneous]
 notes = ["FIXME", "TODO", "DEBUG", "WIP"]
 notes = ["FIXME", "TODO", "DEBUG", "WIP"]