Skip to content

Commit 770d2f8

Browse files
jeremyclineacmel
authored andcommitted
perf scripts python: Add Python 3 support to Core.py
Support both Python 2 and Python 3 in Core.py. This should have no functional change. Signed-off-by: Jeremy Cline <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Herton Krzesinski <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/0100016341a72ebe-e572899e-f445-4765-98f0-c314935727f9-000000@email.amazonses.com Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 877cc63 commit 770d2f8

File tree

1 file changed

+17
-23
lines changed
  • tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace

1 file changed

+17
-23
lines changed

tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ def flag_str(event_name, field_name, value):
3131
string = ""
3232

3333
if flag_fields[event_name][field_name]:
34-
print_delim = 0
35-
keys = flag_fields[event_name][field_name]['values'].keys()
36-
keys.sort()
37-
for idx in keys:
34+
print_delim = 0
35+
for idx in sorted(flag_fields[event_name][field_name]['values']):
3836
if not value and not idx:
3937
string += flag_fields[event_name][field_name]['values'][idx]
4038
break
@@ -51,14 +49,12 @@ def symbol_str(event_name, field_name, value):
5149
string = ""
5250

5351
if symbolic_fields[event_name][field_name]:
54-
keys = symbolic_fields[event_name][field_name]['values'].keys()
55-
keys.sort()
56-
for idx in keys:
52+
for idx in sorted(symbolic_fields[event_name][field_name]['values']):
5753
if not value and not idx:
58-
string = symbolic_fields[event_name][field_name]['values'][idx]
54+
string = symbolic_fields[event_name][field_name]['values'][idx]
5955
break
60-
if (value == idx):
61-
string = symbolic_fields[event_name][field_name]['values'][idx]
56+
if (value == idx):
57+
string = symbolic_fields[event_name][field_name]['values'][idx]
6258
break
6359

6460
return string
@@ -74,19 +70,17 @@ def trace_flag_str(value):
7470
string = ""
7571
print_delim = 0
7672

77-
keys = trace_flags.keys()
78-
79-
for idx in keys:
80-
if not value and not idx:
81-
string += "NONE"
82-
break
83-
84-
if idx and (value & idx) == idx:
85-
if print_delim:
86-
string += " | ";
87-
string += trace_flags[idx]
88-
print_delim = 1
89-
value &= ~idx
73+
for idx in trace_flags:
74+
if not value and not idx:
75+
string += "NONE"
76+
break
77+
78+
if idx and (value & idx) == idx:
79+
if print_delim:
80+
string += " | ";
81+
string += trace_flags[idx]
82+
print_delim = 1
83+
value &= ~idx
9084

9185
return string
9286

0 commit comments

Comments
 (0)