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>
This commit is contained in:
Raul Tambre
2019-05-06 22:41:05 +00:00
committed by Commit Bot
parent ad1c8b22e2
commit 80ee78e7fa
60 changed files with 424 additions and 317 deletions

View File

@@ -32,6 +32,8 @@ Example:
# >
# [VPYTHON:END]
from __future__ import print_function
import collections
import contextlib
from datetime import datetime
@@ -566,8 +568,8 @@ class MyActivity(object):
})
def print_heading(self, heading):
print
print self.options.output_format_heading.format(heading=heading)
print()
print(self.options.output_format_heading.format(heading=heading))
def match(self, author):
if '@' in self.user:
@@ -654,8 +656,8 @@ class MyActivity(object):
}
if optional_values is not None:
values.update(optional_values)
print DefaultFormatter().format(output_format, **values).encode(
sys.getdefaultencoding())
print(DefaultFormatter().format(output_format,
**values).encode(sys.getdefaultencoding()))
def filter_issue(self, issue, should_filter_by_user=True):
@@ -802,25 +804,25 @@ class MyActivity(object):
if changes_by_issue_uid[issue_uid] or not skip_empty_own:
self.print_issue(issues[issue_uid])
if changes_by_issue_uid[issue_uid]:
print
print()
for change in changes_by_issue_uid[issue_uid]:
print ' ', # this prints one space due to comma, but no newline
print(' ', end='') # this prints no newline
self.print_change(change)
print
print()
# Changes referencing others' issues.
for issue_uid in ref_issues:
assert changes_by_ref_issue_uid[issue_uid]
self.print_issue(ref_issues[issue_uid])
for change in changes_by_ref_issue_uid[issue_uid]:
print '', # this prints one space due to comma, but no newline
print('', end=' ') # this prints one space due to comma, but no newline
self.print_change(change)
# Changes referencing no issues.
if changes_without_issue:
print self.options.output_format_no_url.format(title='Other changes')
print(self.options.output_format_no_url.format(title='Other changes'))
for change in changes_without_issue:
print '', # this prints one space due to comma, but no newline
print('', end=' ') # this prints one space due to comma, but no newline
self.print_change(change)
def print_activity(self):
@@ -855,7 +857,7 @@ class MyActivity(object):
'changes': format_for_json_dump(self.changes),
'issues': format_for_json_dump(self.issues)
}
print json.dumps(output, indent=2, cls=PythonObjectEncoder)
print(json.dumps(output, indent=2, cls=PythonObjectEncoder))
def main():