From 0d5fd4a0403bd6efa7eb4680f470558e35c65b16 Mon Sep 17 00:00:00 2001 From: Mark Charney Date: Sun, 11 Jun 2017 10:58:41 -0400 Subject: [PATCH] more replacing of map(str with list comprehension Change-Id: I0b3832f5e30c35927c46d177b7b3b13692c6d306 (cherry picked from commit 34c9f848802827bf4699c06b97a732ef79875218) --- pysrc/flag_gen.py | 4 ++-- pysrc/generator.py | 10 +++++----- pysrc/genutil.py | 2 +- pysrc/ild_cdict.py | 4 ++-- pysrc/ild_phash.py | 2 -- pysrc/opnds.py | 2 +- pysrc/read-encfile.py | 6 +++--- 7 files changed, 14 insertions(+), 16 deletions(-) diff --git a/pysrc/flag_gen.py b/pysrc/flag_gen.py index f0e744f..c434a86 100755 --- a/pysrc/flag_gen.py +++ b/pysrc/flag_gen.py @@ -224,7 +224,7 @@ class flags_rec_t(object): s.append(self.qualifier) s.append(self.may_must) s.append('[') - s.extend(map(str,self.flag_actions)) + s.extend([str(x) for x in self.flag_actions]) s.append(']') return ' '.join(s) @@ -302,7 +302,7 @@ class flags_info_t(object): return self.complex_id def __str__(self): - s = ', '.join(map(str,self.flags_recs)) + s = ', '.join( [str(x) for x in self.flags_recs] ) return s def x87_flags(self): diff --git a/pysrc/generator.py b/pysrc/generator.py index fc42c14..faed4bb 100755 --- a/pysrc/generator.py +++ b/pysrc/generator.py @@ -708,7 +708,7 @@ class prebinding_t(object): def __str__(self): s = [] s.append(self.field_name) - s.extend(map(str,self.bit_info_list)) + s.extend( [str(x) for x in self.bit_info_list ] ) return ', '.join(s) def get_btype(b): @@ -1418,7 +1418,7 @@ class instruction_info_t(partitionable_info_t): return ''.join(s) if self.prebindings: s.append('prebindings: \n\t' + - '\n\t'.join(map(str,list(self.prebindings.values()))) + '\n') + '\n\t'.join( [str(x) for x in list(self.prebindings.values())]) + '\n') for op in self.operands: s.append(pad) s.append(" ") @@ -2034,19 +2034,19 @@ def partition_by_required_values(options, instructions, bitpos, token, osf = operand_storage_dict[operand_decider.token] if osf.ctype.find('enum') == -1: nvalues = 1 << int(osf.bitwidth) - #all_values_for_this_od = map(str,range(0,nvalues)) + #all_values_for_this_od = [ str(x) for x in range(0,nvalues) ] all_values_for_this_od = range(0,nvalues) if vod(): msge("Synthesized values for %s: %s" % ( operand_decider.token, - ", ".join(map(str,all_values_for_this_od)))) + ", ".join( [ str(x) for x in all_values_for_this_od]))) except: die("could not find %s in state space dictionary" % (operand_decider.token)) if vod(): msge("All values for OD: %s" % - ", ".join(map(str,all_values_for_this_od))) + ", ".join( [ str(x) for x in all_values_for_this_od] )) for a in all_values_for_this_od: all_values[a]=True trimmed_vals = list(filter(lambda x: x != operand_decider.requirement, diff --git a/pysrc/genutil.py b/pysrc/genutil.py index a78b984..d95fd81 100755 --- a/pysrc/genutil.py +++ b/pysrc/genutil.py @@ -230,7 +230,7 @@ def hex_to_binary(x): return decimal_to_binary(i) def stringify_list(lst): - return ' '.join(map(str,lst)) + return ' '.join([ str(x) for x in lst]) def round_up_power_of_two(x): lg = math.ceil(math.log(x,2)) diff --git a/pysrc/ild_cdict.py b/pysrc/ild_cdict.py index 7ae2241..0ebc4dd 100755 --- a/pysrc/ild_cdict.py +++ b/pysrc/ild_cdict.py @@ -259,7 +259,7 @@ def _replace_RM_with_RM4(cnames, ptrn_list): cnames.add(_rm_token_4) for ptrn in ptrn_list: found = False - #print "PATTERN BITS", "\t\n".join(map(str,ptrn.ii.ipattern.bits)) + #print "PATTERN BITS", "\t\n".join( [str(x) for x in ptrn.ii.ipattern.bits]) for bt in ptrn.ii.ipattern.bits: if bt.token == _rm_token: if bt.test == 'eq': @@ -268,7 +268,7 @@ def _replace_RM_with_RM4(cnames, ptrn_list): break if not found: #print "X", str(cnames) - #print "\t\n".join(map(str,ptrn_list)) + #print "\t\n".join( [ str(x) for x in ptrn_list] ) ptrn.constraints[_rm_token_4] = {0:True, 1:True} #FIXME: probably should move this one to layers diff --git a/pysrc/ild_phash.py b/pysrc/ild_phash.py index 5e0d9a2..945ca04 100755 --- a/pysrc/ild_phash.py +++ b/pysrc/ild_phash.py @@ -292,8 +292,6 @@ class l1_phash_t(phash_t): # legal ordinal starts at 1 self.cdict.tuple2rule[t].index = hash_val + 1 - #for key sequence postprocessing analysis - #sys.stderr.write("KEYS:" + " ".join(map(str,sorted(self.x2hx.keys()))) + '\n') def __str__(self): lines = ['-----------1-LEVEL-PHASH-------------'] diff --git a/pysrc/opnds.py b/pysrc/opnds.py index 451d63c..188e051 100644 --- a/pysrc/opnds.py +++ b/pysrc/opnds.py @@ -197,7 +197,7 @@ class operand_info_t(object): s.append("MULTIREG{}".format(self.multireg)) if self.bit_positions: - s.append(' bitpos: ' + ', '.join(map(str,self.bit_positions))) + s.append(' bitpos: ' + ', '.join( [str(x) for x in self.bit_positions] )) if self.invert: s.append('invert') diff --git a/pysrc/read-encfile.py b/pysrc/read-encfile.py index 1d4cd1e..625507b 100755 --- a/pysrc/read-encfile.py +++ b/pysrc/read-encfile.py @@ -579,7 +579,7 @@ class conditions_t(object): generation (emit actions), by searching the conditions to see which ones are captures""" if vcapture(): - msgb("CAPTURE COLLECTION USING:\n\t%s\n" % "\n\t".join(map(str,clist))) + msgb("CAPTURE COLLECTION USING:\n\t%s\n" % "\n\t".join( [ str(x) for x in clist] )) full_captures = list(filter(lambda x: x.is_bit_capture(), clist)) captures = [ x.capture_info() for x in full_captures] return captures @@ -1009,7 +1009,7 @@ class rule_t(object): list_of_tuples = self.compute_field_capture_list() if vtuples(): - msgb("TUPLES", (" ,".join(map(str, list_of_tuples)))) + msgb("TUPLES", (" ,".join( [str(x) for x in list_of_tuples] ))) if len(list_of_tuples) == 0 or a.emit_type == 'numeric': # no substitutions required (length, s) = self.prepare_value_for_emit(a) @@ -2179,7 +2179,7 @@ class encoder_configuration_t(object): # decode-patterns are encode-actions [blot_t], # modal-patterns that become encode-conditions [string]) - #msgerr("OPERANDS %s" % ' '.join(map(str,operands))) + #msgerr("OPERANDS %s" % ' '.join( [str(x) for x in operands])) return (operands, patterns, modal_patterns) def print_iclass_info(self,iclass, operands, ipattern, conditions,