[NFC] Fix minor python issues.
authorJordan Rupprecht <rupprecht@google.com>
Fri, 28 Feb 2020 22:11:21 +0000 (14:11 -0800)
committerJordan Rupprecht <rupprecht@google.com>
Fri, 28 Feb 2020 22:17:43 +0000 (14:17 -0800)
* llvm-gisel-cov.py: extra `)` after print
* chunk-print-before-all.py: py2-only print method

llvm/utils/chunk-print-before-all.py
llvm/utils/llvm-gisel-cov.py

index ce17c68c742a2555449633f9ac62a3787c519583..b036e380ef9fb6ad72d9e59d13d59900c76a1694 100755 (executable)
@@ -5,6 +5,8 @@
 # "crashinfo.txt" file leaving only the valid input IR in the last chunk.
 # Files are written to current working directory.
 
+from __future__ import print_function
+
 import sys
 
 basename = "chunk-"
@@ -15,7 +17,7 @@ def print_chunk(lines):
     global basename
     fname = basename + str(chunk_id) + ".ll"
     chunk_id = chunk_id + 1
-    print "writing chunk " + fname + " (" + str(len(lines)) + " lines)"
+    print("writing chunk " + fname + " (" + str(len(lines)) + " lines)")
     with open(fname, "w") as f:
         f.writelines(lines)
 
@@ -35,7 +37,7 @@ for line in sys.stdin:
         cur.append(line)
 
 if is_dump:
-    print "writing crashinfo.txt (" + str(len(cur)) + " lines)"
+    print("writing crashinfo.txt (" + str(len(cur)) + " lines)")
     with open("crashinfo.txt", "w") as f:
         f.writelines(cur)
 else:
index 820fceab0d02a1c0483cb548c7bf8ded87f33c13..88b19455ac3931187acc6f6c9f10771302dce53a 100755 (executable)
@@ -15,11 +15,11 @@ class FileFormatError(Exception):
 
 def backend_int_pair(s):
   backend, sep, value = s.partition('=')
-  if (sep is None):
+  if sep is None:
     raise argparse.ArgumentTypeError("'=' missing, expected name=value")
-  if (not backend):
+  if not backend:
     raise argparse.ArgumentTypeError("Expected name=value")
-  if (not value):
+  if not value:
     raise argparse.ArgumentTypeError("Expected name=value")
   return backend, int(value)
 
@@ -60,7 +60,7 @@ def main():
   num_rules = dict(args.num_rules)
   for backend, rules_for_backend in covered_rules.items():
     if backend in num_rules:
-      print("%s: %3.2f%% of rules covered" % (backend, float(len(rules_for_backend)) / num_rules[backend]) * 100))
+      print("%s: %3.2f%% of rules covered" % (backend, float(len(rules_for_backend)) / num_rules[backend]) * 100)
     else:
       print("%s: %d rules covered" % (backend, len(rules_for_backend)))