Browse Source

minor fixes and cleanups

The MMGen Project 3 years ago
parent
commit
acd9c1e13f
5 changed files with 16 additions and 17 deletions
  1. 1 2
      mmgen/altcoins/eth/tx.py
  2. 5 6
      mmgen/tx.py
  3. 2 6
      mmgen/util.py
  4. 1 2
      mmgen/wallet.py
  5. 7 1
      scripts/gendiff.py

+ 1 - 2
mmgen/altcoins/eth/tx.py

@@ -138,9 +138,8 @@ class EthereumMMGenTX:
 				self.process_cmd_arg(a,ad_f,ad_w)
 
 		def select_unspent(self,unspent):
-			prompt = 'Enter an account to spend from: '
 			while True:
-				reply = my_raw_input(prompt).strip()
+				reply = my_raw_input('Enter an account to spend from: ').strip()
 				if reply:
 					if not is_int(reply):
 						msg('Account number must be an integer')

+ 5 - 6
mmgen/tx.py

@@ -493,12 +493,11 @@ class MMGenTX:
 				if keypress_confirm(m,default_yes=False):
 					while True:
 						s = MMGenTxLabel(my_raw_input('Comment: ',insert_txt=self.label))
-						if s:
-							lbl_save = self.label
-							self.label = s
-							return (True,False)[lbl_save == self.label]
-						else:
-							msg('Invalid comment')
+						if not s:
+							ymsg('Warning: comment is empty')
+						lbl_save = self.label
+						self.label = s
+						return (True,False)[lbl_save == self.label]
 				return False
 
 		def get_non_mmaddrs(self,desc):

+ 2 - 6
mmgen/util.py

@@ -706,8 +706,7 @@ def get_lines_from_file(fn,desc='',trim_comments=False,quiet=False,silent=False)
 	return ret
 
 def get_data_from_user(desc='data'): # user input MUST be UTF-8
-	p = f'Enter {desc}: ' if g.stdin_tty else ''
-	data = my_raw_input(p,echo=opt.echo_passphrase)
+	data = my_raw_input(f'Enter {desc}: ',echo=opt.echo_passphrase)
 	dmsg(f'User input: [{data}]')
 	return data
 
@@ -801,10 +800,7 @@ def my_raw_input(prompt,echo=True,insert_txt='',use_readline=True):
 
 	kb_hold_protect()
 
-	try:
-		return reply.strip()
-	except:
-		die(1,'User input must be UTF-8 encoded.')
+	return reply.strip()
 
 def keypress_confirm(prompt,default_yes=False,verbose=False,no_nl=False,complete_prompt=False):
 

+ 1 - 2
mmgen/wallet.py

@@ -732,8 +732,7 @@ class MMGenWallet(WalletEnc):
 			'to reuse the label {}'.format(old_lbl.hl(encl="''")) if old_lbl else
 			'for no label' )
 		while True:
-			msg_r(prompt)
-			ret = my_raw_input('')
+			ret = my_raw_input(prompt)
 			if ret:
 				lbl = get_obj(MMGenWalletLabel,s=ret)
 				if lbl:

+ 7 - 1
scripts/gendiff.py

@@ -39,6 +39,12 @@ def cleanup_file(fn):
 cleaned_texts = [cleanup_file(fn) for fn in fns]
 
 if len(fns) == 2:
-	print('\n'.join(unified_diff(*cleaned_texts)))
+	"""
+	chunk headers have trailing newlines, hence the rstrip()
+	"""
+	print(
+		f'diff a/{fns[0]} b/{fns[1]}\n' +
+		'\n'.join(a.rstrip() for a in unified_diff(*cleaned_texts,fromfile=f'a/{fns[0]}',tofile=f'b/{fns[1]}'))
+	)
 else:
 	print(f'{len(fns)} input files.  Not generating diff.')