History

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.

Jeremy Cline committed 8 years ago

Commit 770d2f81 parent 877cc631 file · +17 −23Browse files

Showing the changes to tools/perf/scripts/python (1 of 1 file). Show all

Unified · Split

tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py+17−23
@@ -31,10 +31,8 @@ def flag_str(event_name, field_name, value): · 30 unmodified lines
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): · 10 unmodified lines
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): · 9 unmodified lines
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