tools: Use Python 3 style print statements [4/9]

Initial conversion performed using '2to3 -f print .'.
Imports added and duplicate parentheses removed manually.
Manually converted files, comments and inline code that 2to3 missed.
Presubmit disabled due to an unrelated error in find_runtime_symbols/find_runtime_symbols.py.
Afterwards ran "git cl format --python" and cherry-picked the formatting changes.

There are no intended behavioural changes.

NOPRESUBMIT=true

Bug: 941669
Change-Id: I3174ed0eb7005d493c6bc44751353b8fae18a1f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1818478
Commit-Queue: Raul Tambre <raul@tambre.ee>
Reviewed-by: Nico Weber <thakis@chromium.org>
Auto-Submit: Raul Tambre <raul@tambre.ee>
Cr-Original-Commit-Position: refs/heads/master@{#699202}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: f3d9412eeb7dafb5ea0d37a54d3ccbae674934c7
diff --git a/idl_parser.py b/idl_parser.py
index 9fdfef9..cd22a2a 100755
--- a/idl_parser.py
+++ b/idl_parser.py
@@ -29,6 +29,8 @@
 # pylint: disable=R0201
 # pylint: disable=C0301
 
+from __future__ import print_function
+
 import os.path
 import sys
 import time
@@ -1187,11 +1189,11 @@
       out = IDLNode(cls, filename, lineno, pos, childlist)
       return out
     except:
-      print 'Exception while parsing:'
+      print('Exception while parsing:')
       for num, item in enumerate(p):
-        print '  [%d] %s' % (num, ExpandProduction(item))
+        print('  [%d] %s' % (num, ExpandProduction(item)))
       if self.LastToken():
-        print 'Last token: %s' % str(self.LastToken())
+        print('Last token: %s' % str(self.LastToken()))
       raise
 
   def BuildNamed(self, cls, p, index, childlist=None):
@@ -1296,9 +1298,9 @@
 
   ast = IDLNode('AST', '__AST__', 0, 0, nodes)
 
-  print '\n'.join(ast.Tree())
+  print('\n'.join(ast.Tree()))
   if errors:
-    print '\nFound %d errors.\n' % errors
+    print('\nFound %d errors.\n' % errors)
 
   return errors
 
diff --git a/run_tests.py b/run_tests.py
index 878f17e..187181c 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -3,6 +3,8 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+from __future__ import print_function
+
 import glob
 import os
 import sys
@@ -12,7 +14,7 @@
   suite = unittest.TestSuite()
   cur_dir = os.path.dirname(os.path.realpath(__file__))
   for testname in glob.glob(os.path.join(cur_dir, '*_test.py')):
-    print 'Adding Test: ' + testname
+    print('Adding Test: ' + testname)
     module = __import__(os.path.basename(testname)[:-3])
     suite.addTests(unittest.defaultTestLoader.loadTestsFromModule(module))
   result = unittest.TextTestRunner(verbosity=2).run(suite)