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/git_footers.py b/git_footers.py
index 6749181..ad091b5 100755
--- a/git_footers.py
+++ b/git_footers.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 argparse
import json
import re
@@ -229,23 +231,23 @@
if opts.key:
for v in footers.get(normalize_name(opts.key), []):
- print v
+ print(v)
elif opts.position:
pos = get_position(footers)
- print '%s@{#%s}' % (pos[0], pos[1] or '?')
+ print('%s@{#%s}' % (pos[0], pos[1] or '?'))
elif opts.position_ref:
- print get_position(footers)[0]
+ print(get_position(footers)[0])
elif opts.position_num:
pos = get_position(footers)
assert pos[1], 'No valid position for commit'
- print pos[1]
+ print(pos[1])
elif opts.json:
with open(opts.json, 'w') as f:
json.dump(footers, f)
else:
for k in footers.keys():
for v in footers[k]:
- print '%s: %s' % (k, v)
+ print('%s: %s' % (k, v))
return 0