Browse Source

py3port: revert some changes made by 2to3

MMGen 6 years ago
parent
commit
44eb299442
16 changed files with 37 additions and 37 deletions
  1. 5 5
      mmgen/altcoin.py
  2. 2 2
      mmgen/altcoins/eth/tw.py
  3. 1 1
      mmgen/color.py
  4. 1 1
      mmgen/crypto.py
  5. 5 5
      mmgen/obj.py
  6. 1 1
      mmgen/opts.py
  7. 1 1
      mmgen/protocol.py
  8. 1 1
      mmgen/seed.py
  9. 1 1
      mmgen/share/Opts.py
  10. 2 2
      mmgen/tool.py
  11. 4 4
      mmgen/tw.py
  12. 3 3
      mmgen/tx.py
  13. 1 1
      mmgen/util.py
  14. 1 1
      scripts/create-token.py
  15. 6 6
      test/test.py
  16. 2 2
      test/tooltest.py

+ 5 - 5
mmgen/altcoin.py

@@ -448,7 +448,7 @@ class CoinInfo(object):
 						msg("Upgrading trust for coin '{}': {} -> {}".format(sym,line[6],1))
 						line[6] = 1
 
-			print((fs.format(*line)))
+			print(fs.format(*line))
 		msg('Processed {} entries'.format(len(data)))
 
 	@classmethod
@@ -464,8 +464,8 @@ class CoinInfo(object):
 		high = phash2addr(ver_num,'ff'*20)
 
 		if verbose:
-			print(('low address:  ' + low))
-			print(('high address: ' + high))
+			print('low address:  ' + low)
+			print('high address: ' + high)
 
 		l1,h1 = low[0],high[0]
 		return (l1,h1) if l1 != h1 else l1
@@ -475,9 +475,9 @@ class CoinInfo(object):
 		w = max(len(e[0]) for e in cls.coin_constants['mainnet'])
 		for line in cls.coin_constants['mainnet']:
 			if reverse:
-				print(('{:6} {}'.format(line[1],line[0])))
+				print('{:6} {}'.format(line[1],line[0]))
 			else:
-				print((('','{:{}} '.format(line[0],w))[include_names] + line[1]))
+				print(('','{:{}} '.format(line[0],w))[include_names] + line[1])
 
 	@classmethod
 	def create_trust_table(cls):

+ 2 - 2
mmgen/altcoins/eth/tw.py

@@ -55,11 +55,11 @@ class EthereumTrackingWallet(TrackingWallet):
 			if not 'tokens' in self.data:
 				self.data['tokens'] = {}
 			def conv_types(ad):
-				for v in list(ad.values()):
+				for v in ad.values():
 					v['mmid'] = TwMMGenID(v['mmid'],on_fail='raise')
 					v['comment'] = TwComment(v['comment'],on_fail='raise')
 			conv_types(self.data['accounts'])
-			for v in list(self.data['tokens'].values()):
+			for v in self.data['tokens'].values():
 				conv_types(v)
 
 	def upgrade_wallet_maybe(self):

+ 1 - 1
mmgen/color.py

@@ -85,6 +85,6 @@ def test_color():
 		pass
 	for desc,n in (('auto','auto'),('8-color',8),('256-color',256)):
 		if n != 'auto': init_color(num_colors=n)
-		print(('{:9}: {}'.format(desc,' '.join([globals()[c](c) for c in sorted(_colors)]))))
+		print('{:9}: {}'.format(desc,' '.join([globals()[c](c) for c in sorted(_colors)])))
 
 if __name__ == '__main__': test_color()

+ 1 - 1
mmgen/crypto.py

@@ -168,7 +168,7 @@ def get_hash_preset_from_user(hp=g.hash_preset,desc='data'):
 	while True:
 		ret = my_raw_input(prompt)
 		if ret:
-			if ret in list(g.hash_presets.keys()):
+			if ret in g.hash_presets.keys():
 				return ret
 			else:
 				m = 'Invalid input.  Valid choices are {}'

+ 5 - 5
mmgen/obj.py

@@ -50,10 +50,10 @@ def truncate_str(s,width): # width = screen width
 class MMGenObject(object):
 
 	# Pretty-print any object subclassed from MMGenObject, recursing into sub-objects - WIP
-	def pmsg(self): print((self.pformat()))
-	def pdie(self): print((self.pformat())); sys.exit(0)
+	def pmsg(self): print(self.pformat())
+	def pdie(self): print(self.pformat()); sys.exit(0)
 	def pformat(self,lvl=0):
-		scalars = (str,str,int,float,Decimal)
+		scalars = (str,int,float,Decimal)
 		def do_list(out,e,lvl=0,is_dict=False):
 			out.append('\n')
 			for i in e:
@@ -327,7 +327,7 @@ class BTCAmt(Decimal,Hilite,InitErrors):
 			if from_unit:
 				assert from_unit in cls.units,(
 					"'{}': unrecognized denomination for {}".format(from_unit,cls.__name__))
-				assert type(num) in (int,int),'value is not an integer or long integer'
+				assert type(num) == int,'value is not an integer or long integer'
 				me = Decimal.__new__(cls,num * getattr(cls,from_unit))
 			else:
 				for t in cls.forbidden_types:
@@ -841,7 +841,7 @@ class MMGenAddrType(str,Hilite,InitErrors,MMGenObject):
 
 	@classmethod
 	def get_names(cls):
-		return [v['name'] for v in list(cls.mmtypes.values())]
+		return [v['name'] for v in cls.mmtypes.values()]
 
 class MMGenPasswordType(MMGenAddrType):
 	mmtypes = {

+ 1 - 1
mmgen/opts.py

@@ -298,7 +298,7 @@ def init(opts_f,add_opts=[],opt_filter=None):
 		opts_data['long_options'] = common_opts_data
 		if g.debug_utf8:
 			for k in opts_data:
-				if type(opts_data[k]) in (str,str):
+				if type(opts_data[k]) == str:
 					opts_data[k] += '-α'
 		mmgen.share.Opts.parse_opts(sys.argv,opts_data,opt_filter=opt_filter)
 

+ 1 - 1
mmgen/protocol.py

@@ -457,7 +457,7 @@ class CoinProtocol(MMGenObject):
 
 	@classmethod
 	def get_base_coin_from_name(cls,name):
-		for proto,foo in list(cls.coins.values()):
+		for (proto,foo) in cls.coins.values():
 			if name == proto.__name__[:-8].lower():
 				return proto.base_coin
 		return False

+ 1 - 1
mmgen/seed.py

@@ -259,7 +259,7 @@ an empty passphrase, just hit ENTER twice.
 		while True:
 			ret = my_raw_input(p)
 			if ret:
-				if ret in list(g.hash_presets.keys()):
+				if ret in g.hash_presets.keys():
 					self.ssdata.hash_preset = ret
 					return ret
 				else:

+ 1 - 1
mmgen/share/Opts.py

@@ -24,7 +24,7 @@ import sys,getopt
 import collections
 
 def usage(opts_data):
-	print(('USAGE: {} {}'.format(opts_data['prog_name'], opts_data['usage'])))
+	print('USAGE: {} {}'.format(opts_data['prog_name'], opts_data['usage']))
 	sys.exit(2)
 
 def print_help_and_exit(opts_data,longhelp=False):

+ 2 - 2
mmgen/tool.py

@@ -106,7 +106,7 @@ cmd_data = OrderedDict([
 
 def usage(command):
 
-	for v in list(cmd_data.values()):
+	for v in cmd_data.values():
 		if v and v[0][-2:] == '-]':
 			v[0] = v[0][:-2] + ' or STDIN]'
 		if 'MARGS' in v: v.remove('MARGS')
@@ -624,7 +624,7 @@ def monero_wallet_ops(infile,op,blockheight=None,addrs=None):
 			m[op][2](n,d,fn)
 		gmsg('\n{} wallet{} {}ed'.format(dl,suf(dl),m[op][0].lower()))
 		if op == 'sync':
-			col1_w = max(list(map(len,bals))) + 1
+			col1_w = max(map(len,bals)) + 1
 			fs = '{:%s} {} {}' % col1_w
 			msg('\n'+fs.format('Wallet','Balance           ','Unlocked Balance  '))
 			from mmgen.obj import XMRAmt

+ 4 - 4
mmgen/tw.py

@@ -143,7 +143,7 @@ watch-only wallet using '{}-addrimport' and then re-run this program.
 		}
 		key = key or self.sort_key
 		if key not in sort_funcs:
-			die(1,"'{}': invalid sort key.  Valid options: {}".format(key,' '.join(list(sort_funcs.keys()))))
+			die(1,"'{}': invalid sort key.  Valid options: {}".format(key,' '.join(sort_funcs.keys())))
 		self.sort_key = key
 		assert type(reverse) == bool
 		self.unspent.sort(key=sort_funcs[key],reverse=reverse or self.reverse)
@@ -456,13 +456,13 @@ class TwAddrList(MMGenDict):
 	def format(self,showbtcaddrs,sort,show_age,show_days):
 		out = ['Chain: '+green(g.chain.upper())] if g.chain != 'mainnet' else []
 		fs = '{{mid}}{} {{cmt}} {{amt}}{}'.format(('',' {addr}')[showbtcaddrs],('',' {age}')[show_age])
-		mmaddrs = [k for k in list(self.keys()) if k.type == 'mmgen']
+		mmaddrs = [k for k in self.keys() if k.type == 'mmgen']
 		max_mmid_len = max(len(k) for k in mmaddrs) + 2 if mmaddrs else 10
-		max_cmt_len  = max(max(screen_width(v['lbl'].comment) for v in list(self.values())),7)
+		max_cmt_len  = max(max(screen_width(v['lbl'].comment) for v in self.values()),7)
 		addr_width = max(len(self[mmid]['addr']) for mmid in self)
 
 		# fp: fractional part
-		max_fp_len = max([len(a.split('.')[1]) for a in [str(v['amt']) for v in list(self.values())] if '.' in a] or [1])
+		max_fp_len = max([len(a.split('.')[1]) for a in [str(v['amt']) for v in self.values()] if '.' in a] or [1])
 		out += [fs.format(
 				mid=MMGenID.fmtc('MMGenID',width=max_mmid_len),
 				addr=(CoinAddr.fmtc('ADDRESS',width=addr_width) if showbtcaddrs else None),

+ 3 - 3
mmgen/tx.py

@@ -240,7 +240,7 @@ Selected non-{pnm} inputs: {{}}""".strip().format(pnm=g.proj_name,pnl=g.proj_nam
 	class MMGenTxInput(MMGenListItem):
 		for k in txio_attrs: locals()[k] = txio_attrs[k] # in lieu of inheritance
 		scriptPubKey = MMGenListItemAttr('scriptPubKey','HexBytes')
-		sequence = MMGenListItemAttr('sequence',(int,int)[g.platform=='win'],typeconv=False)
+		sequence = MMGenListItemAttr('sequence',int,typeconv=False)
 
 	class MMGenTxOutput(MMGenListItem):
 		for k in txio_attrs: locals()[k] = txio_attrs[k]
@@ -548,7 +548,7 @@ Selected non-{pnm} inputs: {{}}""".strip().format(pnm=g.proj_name,pnl=g.proj_nam
 	def process_fee_spec(self,tx_fee,tx_size,on_fail='throw'):
 		import re
 		units = dict((u[0],u) for u in g.proto.coin_amt.units)
-		pat = r'([1-9][0-9]*)({})'.format('|'.join(list(units.keys())))
+		pat = r'([1-9][0-9]*)({})'.format('|'.join(units.keys()))
 		if g.proto.coin_amt(tx_fee,on_fail='silent'):
 			return g.proto.coin_amt(tx_fee)
 		elif re.match(pat,tx_fee):
@@ -605,7 +605,7 @@ Selected non-{pnm} inputs: {{}}""".strip().format(pnm=g.proj_name,pnl=g.proj_nam
 
 	def decode_io_oldfmt(self,data):
 		tr = {'amount':'amt', 'address':'addr', 'confirmations':'confs','comment':'label'}
-		tr_rev = dict(list(map(reversed,list(tr.items()))))
+		tr_rev = dict(map(reversed,list(tr.items())))
 		copy_keys = [tr_rev[k] if k in tr_rev else k for k in self.MMGenTxInput.__dict__]
 		ret = MMGenList(self.MMGenTxInput(**dict([(tr[k] if k in tr else k,d[k])
 					for k in copy_keys if k in d and d[k] != ''])) for d in data)

+ 1 - 1
mmgen/util.py

@@ -122,7 +122,7 @@ def check_or_create_dir(path):
 		os.listdir(path)
 	except:
 		try:
-			os.makedirs(path,stat.S_IRUSR|stat.S_IWUSR|stat.S_IXUSR)
+			os.makedirs(path,0o700)
 		except:
 			die(2,"ERROR: unable to read or create path '{}'".format(path))
 

+ 1 - 1
scripts/create-token.py

@@ -183,4 +183,4 @@ def compile_code(code):
 src = create_src(code_in)
 out = compile_code(src)
 if opt.stdout:
-	print((json.dumps(out)))
+	print(json.dumps(out))

+ 6 - 6
test/test.py

@@ -1270,7 +1270,7 @@ if opt.list_cmds:
 	fs = '  {:<{w}} - {}'
 
 	Msg(green('AVAILABLE COMMANDS:'))
-	w = max(list(map(len,cmd_data)))
+	w = max(map(len,cmd_data))
 	for cmd in cmd_data:
 		if cmd[:5] == 'info_':
 			Msg(green('  {}:'.format(capfirst(cmd_data[cmd][0]))))
@@ -1278,7 +1278,7 @@ if opt.list_cmds:
 		Msg('  '+fs.format(cmd,cmd_data[cmd][1],w=w))
 
 	for cl,lbl in ((meta_cmds,'METACOMMANDS'),(cmd_list,'COMMAND GROUPS')):
-		w = max(list(map(len,cl)))
+		w = max(map(len,cl))
 		Msg('\n'+green('AVAILABLE {}:'.format(lbl)))
 		for cmd in cl:
 			ft = format_par(' '.join(cl[cmd]),width=tw,indent=4,as_list=True)
@@ -1286,7 +1286,7 @@ if opt.list_cmds:
 			Msg('  {}{}{}'.format(yellow(cmd+':'),sep,'\n'.join(ft).lstrip()))
 
 	Msg('\n'+green('AVAILABLE UTILITIES:'))
-	w = max(list(map(len,utils)))
+	w = max(map(len,utils))
 	for cmd in sorted(utils):
 		Msg(fs.format(cmd,utils[cmd],w=w))
 
@@ -1416,7 +1416,7 @@ def get_label(do_shuffle=False):
 def create_fake_unspent_data(adata,tx_data,non_mmgen_input='',non_mmgen_input_compressed=True):
 
 	out = []
-	for d in list(tx_data.values()):
+	for d in tx_data.values():
 		al = adata.addrlist(d['al_id'])
 		for n,(idx,coinaddr) in enumerate(al.addrpairs()):
 			lbl = get_label(do_shuffle=True)
@@ -1610,7 +1610,7 @@ def check_deps(cmds):
 
 	check_needs_rerun(ts,cmd,build=False)
 
-	w = max(list(map(len,rebuild_list))) + 1
+	w = max(map(len,rebuild_list)) + 1
 	for cmd in rebuild_list:
 		c = rebuild_list[cmd]
 		m = 'Rebuild' if (c[0] and c[1]) else 'Build' if c[0] else 'OK'
@@ -1653,7 +1653,7 @@ class MMGenTestSuite(object):
 		num = str(cmd_data[cmd][0])
 		dgl = cfgs[num]['dep_generators']
 #	mmsg(num,cmd,dgl)
-		if cmd in list(dgl.values()):
+		if cmd in dgl.values():
 			exts = [k for k in dgl if dgl[k] == cmd]
 			return (num,exts)
 		else:

+ 2 - 2
test/tooltest.py

@@ -178,7 +178,7 @@ add_spawn_args = ['--data-dir='+cfg['tmpdir']] + ['--{}{}'.format(
 if opt.list_cmds:
 	fs = '  {:<{w}} - {}'
 	Msg('Available commands:')
-	w = max(list(map(len,cmd_data)))
+	w = max(map(len,cmd_data))
 	for cmd in cmd_data:
 		Msg(fs.format(cmd,cmd_data[cmd]['desc'],w=w))
 	Msg('\nAvailable utilities:')
@@ -186,7 +186,7 @@ if opt.list_cmds:
 	sys.exit(0)
 if opt.list_names:
 	acc = []
-	for v in list(cmd_data.values()):
+	for v in cmd_data.values():
 		acc += list(v['cmd_data'].keys())
 	tc = sorted(c.lower() for c in acc)
 	msg('{}\n{}'.format(green('Tested commands:'),'\n'.join(tc)))