Commit eaec33fb authored by Raul Tambre's avatar Raul Tambre Committed by Commit Bot

//base: Convert print statements to Python 3 style

Ran "2to3 -w -n -f print ./base" and manually added imports.
There are no intended behaviour changes.

Bug: 941669
Change-Id: If5eb9217385a6d9a7807a4ca03116e1db9999695
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1559958
Commit-Queue: Raul Tambre <raul@tambre.ee>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Auto-Submit: Raul Tambre <raul@tambre.ee>
Cr-Commit-Position: refs/heads/master@{#649237}
parent fe27ac42
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
"""Extracts native methods from a Java file and generates the JNI bindings. """Extracts native methods from a Java file and generates the JNI bindings.
If you change this, please run and update the tests.""" If you change this, please run and update the tests."""
from __future__ import print_function
import base64 import base64
import collections import collections
import errno import errno
...@@ -1534,13 +1536,13 @@ def GenerateJNIHeader(input_file, output_file, options): ...@@ -1534,13 +1536,13 @@ def GenerateJNIHeader(input_file, output_file, options):
input_file, options) input_file, options)
content = jni_from_java_source.GetContent() content = jni_from_java_source.GetContent()
except ParseError, e: except ParseError, e:
print e print(e)
sys.exit(1) sys.exit(1)
if output_file: if output_file:
with build_utils.AtomicOutput(output_file) as f: with build_utils.AtomicOutput(output_file) as f:
f.write(content) f.write(content)
else: else:
print content print(content)
def GetScriptName(): def GetScriptName():
...@@ -1613,7 +1615,7 @@ See SampleForTests.java for more details. ...@@ -1613,7 +1615,7 @@ See SampleForTests.java for more details.
input_file = options.input_file input_file = options.input_file
else: else:
option_parser.print_help() option_parser.print_help()
print '\nError: Must specify --jar_file or --input_file.' print('\nError: Must specify --jar_file or --input_file.')
return 1 return 1
output_file = None output_file = None
if options.output_dir: if options.output_dir:
......
...@@ -11,6 +11,8 @@ code generator and ensures the output matches a golden ...@@ -11,6 +11,8 @@ code generator and ensures the output matches a golden
file. file.
""" """
from __future__ import print_function
import difflib import difflib
import inspect import inspect
import optparse import optparse
...@@ -133,16 +135,16 @@ class BaseTest(unittest.TestCase): ...@@ -133,16 +135,16 @@ class BaseTest(unittest.TestCase):
stripped_generated = FilterText(generated_text) stripped_generated = FilterText(generated_text)
if stripped_golden == stripped_generated: if stripped_golden == stripped_generated:
return True return True
print self.id() print(self.id())
for line in difflib.context_diff(stripped_golden, stripped_generated): for line in difflib.context_diff(stripped_golden, stripped_generated):
print line print(line)
print '\n\nGenerated' print('\n\nGenerated')
print '=' * 80 print('=' * 80)
print generated_text print(generated_text)
print '=' * 80 print('=' * 80)
print 'Run with:' print('Run with:')
print 'REBASELINE=1', sys.argv[0] print('REBASELINE=1', sys.argv[0])
print 'to regenerate the data files.' print('to regenerate the data files.')
def AssertGoldenTextEquals(self, generated_text, suffix='', golden_file=None): def AssertGoldenTextEquals(self, generated_text, suffix='', golden_file=None):
"""Compares generated text with the corresponding golden_file """Compares generated text with the corresponding golden_file
......
...@@ -58,6 +58,8 @@ These exceptions are: ...@@ -58,6 +58,8 @@ These exceptions are:
instead of by another class using that object. instead of by another class using that object.
""" """
from __future__ import print_function
import argparse import argparse
import sys import sys
import string import string
......
...@@ -58,6 +58,8 @@ Note: MODE_SPECIFIC_STRINGS cannot be specified if STRING_IDS is not specified. ...@@ -58,6 +58,8 @@ Note: MODE_SPECIFIC_STRINGS cannot be specified if STRING_IDS is not specified.
# and IDS_L10N_OFFSET_* for the language we are interested in. # and IDS_L10N_OFFSET_* for the language we are interested in.
# #
from __future__ import print_function
import argparse import argparse
import exceptions import exceptions
import glob import glob
...@@ -318,8 +320,9 @@ Missing input files: ...@@ -318,8 +320,9 @@ Missing input files:
Extra input files: Extra input files:
{} {}
''' '''
print error.format('\n'.join(self.expected_xtb_input_files), print(error.format('\n'.join(self.expected_xtb_input_files),
'\n'.join(all_xtb_files), '\n'.join(missing), '\n'.join(extra)) '\n'.join(all_xtb_files), '\n'.join(missing),
'\n'.join(extra)))
sys.exit(1) sys.exit(1)
return translated_strings return translated_strings
...@@ -391,12 +394,12 @@ Extra input files: ...@@ -391,12 +394,12 @@ Extra input files:
if missing_xtb_files: if missing_xtb_files:
missing_error = ("There were files that were found in the .grd file " missing_error = ("There were files that were found in the .grd file "
"'{}' but do not exist on disk:\n{}") "'{}' but do not exist on disk:\n{}")
print missing_error.format(grd_file, '\n'.join(missing_xtb_files)) print(missing_error.format(grd_file, '\n'.join(missing_xtb_files)))
if extra_xtb_files: if extra_xtb_files:
extra_error = ("There were files that exist on disk but were not found " extra_error = ("There were files that exist on disk but were not found "
"in the .grd file '{}':\n{}") "in the .grd file '{}':\n{}")
print extra_error.format(grd_file, '\n'.join(extra_xtb_files)) print(extra_error.format(grd_file, '\n'.join(extra_xtb_files)))
sys.exit(1) sys.exit(1)
return translated_strings return translated_strings
...@@ -585,8 +588,8 @@ def main(): ...@@ -585,8 +588,8 @@ def main():
xtb_relative_paths = args.input_xtb_relative_paths xtb_relative_paths = args.input_xtb_relative_paths
if len(grd_files) != len(xtb_relative_paths): if len(grd_files) != len(xtb_relative_paths):
parser.error('Mismatch in number of grd files ({}) and xtb relative ' parser.error('Mismatch in number of grd files ({}) and xtb relative '
'paths ({})'.format(len(grd_files), len(xtb_relative_paths))) 'paths ({})'.format(len(grd_files), len(xtb_relative_paths)))
inputs = zip(grd_files, xtb_relative_paths) inputs = zip(grd_files, xtb_relative_paths)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment