convert to print function

Newer repo's sometimes import the print function on us, and then import
these python files directly which then throws an error.  Convert us to
the print function to avoid it.  It's not a bad thing.

BUG=None
TEST=`./pre-upload_unittest.py` passes

Change-Id: Ib42108b58bfc544bc56db129f78bbf86e7b064ac
Reviewed-on: https://chromium-review.googlesource.com/194398
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/errors.py b/errors.py
index 198d0e2..398223a 100644
--- a/errors.py
+++ b/errors.py
@@ -2,6 +2,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 re
 import sys
 
@@ -30,7 +32,7 @@
   """
   regex = re.compile(r'^', re.M)
   msg = regex.sub(_INDENT * indent_level, msg)
-  print >> sys.stderr, msg
+  print(msg, file=sys.stderr)
 
 
 def _FormatCommitDesc(desc):
@@ -57,7 +59,7 @@
   """
   _PrintWithIndent(_PROJECT_INFO % project, 0)
   _PrintWithIndent(_FormatHookFailure(error), 1)
-  print >> sys.stderr, ''
+  print('', file=sys.stderr)
 
 
 def PrintErrorsForCommit(project, commit, commit_desc, error_list):
@@ -98,5 +100,4 @@
   for error in error_list:
     _PrintWithIndent(_FormatHookFailure(error), 3)
 
-  print >> sys.stderr, ''
-
+  print('', file=sys.stderr)
diff --git a/pre-upload.py b/pre-upload.py
index b3ba2ce..8f5f725 100755
--- a/pre-upload.py
+++ b/pre-upload.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 ConfigParser
 import json
 import optparse
@@ -434,7 +436,7 @@
       if not config.getboolean(SECTION, flag): disable_flags.append(flag)
     except ValueError as e:
       msg = "Error parsing flag \'%s\' in %s file - " % (flag, _CONFIG_FILE)
-      print msg + str(e)
+      print(msg + str(e))
 
   disabled_keys = set(_DISABLE_FLAGS.iterkeys()).intersection(disable_flags)
   return set([_DISABLE_FLAGS[key] for key in disabled_keys])
@@ -519,7 +521,7 @@
            '- To disable some source style checks, and for other hints, see '
            '<checkout_dir>/src/repohooks/README\n'
            '- To upload only current project, run \'repo upload .\'')
-    print >> sys.stderr, msg
+    print(msg, file=sys.stderr)
     sys.exit(1)
 
 
@@ -636,7 +638,7 @@
       raise BadInvocation("Repo couldn't identify the project of %s" % opts.dir)
 
   if verbose:
-    print "Running hooks on %s" % (opts.project)
+    print("Running hooks on %s" % (opts.project))
 
   found_error = _run_project_hooks(opts.project, proj_dir=opts.dir)
   if found_error:
@@ -659,6 +661,6 @@
     try:
       exit_code = direct_main(sys.argv)
     except BadInvocation, e:
-      print >>sys.stderr, "%s: %s" % (prog_name, str(e))
+      print("%s: %s" % (prog_name, str(e)), file=sys.stderr)
       exit_code = 1
   sys.exit(exit_code)