Convert print statements to Python 3 style
Ran "2to3 -w -n -f print ./" and manually added imports.
Ran "^\s*print " and "\s+print " to find batch/shell scripts, comments and the like with embedded code, and updated them manually.
Also manually added imports to files, which used print as a function, but were missing the import.
The scripts still work with Python 2.
There are no intended behaviour changes.
Bug: 942522
Change-Id: Id777e4d4df4adcdfdab1b18bde89f235ef491b9f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1595684
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@chromium.org>
Auto-Submit: Raul Tambre <raul@tambre.ee>
diff --git a/gerrit_util.py b/gerrit_util.py
index baec860..24cc357 100644
--- a/gerrit_util.py
+++ b/gerrit_util.py
@@ -8,6 +8,8 @@
https://gerrit-review.googlesource.com/Documentation/rest-api.html
"""
+from __future__ import print_function
+
import base64
import contextlib
import cookielib
@@ -166,10 +168,10 @@
st = os.stat(path)
if st.st_mode & (stat.S_IRWXG | stat.S_IRWXO):
- print >> sys.stderr, (
+ print(
'WARNING: netrc file %s cannot be used because its file '
'permissions are insecure. netrc file permissions should be '
- '600.' % path)
+ '600.' % path, file=sys.stderr)
with open(path) as fd:
content = fd.read()
@@ -189,11 +191,11 @@
try:
return netrc.netrc(path)
except IOError:
- print >> sys.stderr, 'WARNING: Could not read netrc file %s' % path
+ print('WARNING: Could not read netrc file %s' % path, file=sys.stderr)
return netrc.netrc(os.devnull)
except netrc.NetrcParseError as e:
- print >> sys.stderr, ('ERROR: Cannot use netrc file %s due to a '
- 'parsing error: %s' % (path, e))
+ print('ERROR: Cannot use netrc file %s due to a parsing error: %s' %
+ (path, e), file=sys.stderr)
return netrc.netrc(os.devnull)
@classmethod
@@ -786,7 +788,7 @@
'reviewer': r,
'state': state,
'notify': 'NONE', # We handled `notify` argument above.
- })
+ })
conn = CreateHttpConn(host, path, reqtype='POST', body=body)
# Gerrit will return 400 if one or more of the requested reviewers are