From 06f5ff1582e463b6868814310b153c35da6c5111 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 9 Jul 2014 15:20:12 -0700 Subject: report.py: Fix PEP8 issues Changes: - uses rawstrings (r'foo') for regex strings - compare to None using 'is' and 'is not' - break long lines - fix hanging indents Signed-off-by: Dylan Baker Acked-by: Kenneth Graunke --- report.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/report.py b/report.py index d1aab27..69fa9ec 100755 --- a/report.py +++ b/report.py @@ -10,10 +10,10 @@ def get_results(filename): results = {} - re_match = re.compile("(\S*)\s*(\S*)\s*:\s*(\S*)") + re_match = re.compile(r"(\S*)\s*(\S*)\s*:\s*(\S*)") for line in lines: match = re.search(re_match, line) - if match == None: + if match is None: continue groups = match.groups() @@ -63,7 +63,7 @@ def main(): namestr = name + " " + type before_count = args.before[p] - if args.after.get(p) != None: + if args.after.get(p) is not None: after_count = args.after[p] total_before += before_count @@ -82,7 +82,7 @@ def main(): lost.append(namestr) for p in args.after: - if (args.before.get(p) == None): + if args.before.get(p) is None: gained.append(p[0] + " " + p[1]) helped.sort() @@ -91,10 +91,12 @@ def main(): if len(helped) > 0: print("") - hurt.sort(key=lambda k: float(args.after[k] - args.before[k]) / args.before[k]) + hurt.sort( + key=lambda k: float(args.after[k] - args.before[k]) / args.before[k]) for p in hurt: namestr = p[0] + " " + p[1] - print("HURT: " + get_result_string(namestr, args.before[p], args.after[p])) + print("HURT: " + get_result_string( + namestr, args.before[p], args.after[p])) if len(hurt) > 0: print("") @@ -110,11 +112,15 @@ def main(): if len(gained) > 0: print("") - print("total instructions in shared programs: " + change(total_before, total_after)) - print("instructions in affected programs: " + change(affected_before, affected_after)) - print("GAINED: {0}".format(len(gained))) - print("LOST: {0}".format(len(lost))) + print("total instructions in shared programs: {0}\n" + "instructions in affected programs: {1}\n" + "GAINED: {2}\n" + "LOST: {3}".format( + change(total_before, total_after), + change(affected_before, affected_after), + len(gained), + len(lost))) if __name__ == "__main__": - main() + main() -- cgit v1.2.3