Improve print statement compatibility with Python3

This commit is contained in:
marmeladema 2019-10-14 00:15:02 +01:00
parent eda6d3e0c5
commit 4e1ee07a79
4 changed files with 24 additions and 16 deletions

View file

@ -7,6 +7,8 @@
# option. This file may not be copied, modified, or distributed
# except according to those terms.
from __future__ import print_function
from errno import ENOENT as NO_SUCH_FILE_OR_DIRECTORY
from glob import glob
import shutil
@ -350,15 +352,15 @@ class CommandBase(object):
version_line = subprocess.check_output(["rustup" + BIN_SUFFIX, "--version"])
except OSError as e:
if e.errno == NO_SUCH_FILE_OR_DIRECTORY:
print "It looks like rustup is not installed. See instructions at " \
"https://github.com/servo/servo/#setting-up-your-environment"
print
print("It looks like rustup is not installed. See instructions at "
"https://github.com/servo/servo/#setting-up-your-environment")
print()
return 1
raise
version = tuple(map(int, re.match("rustup (\d+)\.(\d+)\.(\d+)", version_line).groups()))
if version < (1, 11, 0):
print "rustup is at version %s.%s.%s, Servo requires 1.11.0 or more recent." % version
print "Try running 'rustup self update'."
print("rustup is at version %s.%s.%s, Servo requires 1.11.0 or more recent." % version)
print("Try running 'rustup self update'.")
return 1
toolchain = self.toolchain()
if platform.system() == "Windows":

View file

@ -7,6 +7,8 @@
# option. This file may not be copied, modified, or distributed
# except according to those terms.
from __future__ import print_function
import os
import sys
@ -20,7 +22,7 @@ class Lint(LintRunner):
def _get_wpt_files(self, suite):
working_dir = os.path.join(WPT_PATH, suite, '')
file_iter = self.get_files(working_dir, exclude_dirs=[])
print '\nRunning the WPT lint on %s...' % working_dir
print('\nRunning the WPT lint on %s...' % working_dir)
for f in file_iter:
if filter_file(f):
yield f[len(working_dir):]

View file

@ -7,6 +7,8 @@
# option. This file may not be copied, modified, or distributed
# except according to those terms.
from __future__ import print_function
import fileinput
import re
import random
@ -28,7 +30,7 @@ def init_variables(if_blocks):
def deleteStatements(file_name, line_numbers):
for line in fileinput.input(file_name, inplace=True):
if fileinput.lineno() not in line_numbers:
print line.rstrip()
print(line.rstrip())
class Strategy:
@ -48,7 +50,7 @@ class Strategy:
for line in fileinput.input(file_name, inplace=True):
if fileinput.lineno() == mutation_line_number:
line = re.sub(self._replace_strategy['regex'], self._replace_strategy['replaceString'], line)
print line.rstrip()
print(line.rstrip())
return mutation_line_number