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/dart_format.py b/dart_format.py
index ae85602..5fec2a3 100755
--- a/dart_format.py
+++ b/dart_format.py
@@ -10,6 +10,8 @@
This tool is named dart_format.py instead of dartfmt to parallel
clang_format.py, which is in this same repository."""
+from __future__ import print_function
+
import os
import subprocess
import sys
@@ -42,14 +44,14 @@
try:
tool = FindDartFmtToolInChromiumTree()
except NotFoundError, e:
- print >> sys.stderr, e
+ print(e, file=sys.stderr)
sys.exit(1)
# Add some visibility to --help showing where the tool lives, since this
# redirection can be a little opaque.
help_syntax = ('-h', '--help', '-help', '-help-list', '--help-list')
if any(match in args for match in help_syntax):
- print '\nDepot tools redirects you to the dartfmt at:\n %s\n' % tool
+ print('\nDepot tools redirects you to the dartfmt at:\n %s\n' % tool)
return subprocess.call([tool] + sys.argv[1:])