Skip to content

Commit

Permalink
gyp: use print as a function, as specified in PEP 3105.
Browse files Browse the repository at this point in the history
#1150
Reviewed-By: Refael Ackermann <refack@gmail.com>
  • Loading branch information
rodrigc authored and rvagg committed Apr 24, 2019
1 parent abef93d commit 2040cd2
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 53 deletions.
15 changes: 8 additions & 7 deletions gyp/pylib/gyp/MSVSSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
The MSBuild schemas were also considered. They are typically found in the
MSBuild install directory, e.g. c:\Program Files (x86)\MSBuild
"""

from __future__ import print_function

import sys
Expand Down Expand Up @@ -463,8 +464,8 @@ def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
try:
msvs_tool[msvs_setting](msvs_value, msbuild_settings)
except ValueError as e:
print(('Warning: while converting %s/%s to MSBuild, '
'%s' % (msvs_tool_name, msvs_setting, e)), file=stderr)
print('Warning: while converting %s/%s to MSBuild, '
'%s' % (msvs_tool_name, msvs_setting, e), file=stderr)
else:
_ValidateExclusionSetting(msvs_setting,
msvs_tool,
Expand All @@ -473,8 +474,8 @@ def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
(msvs_tool_name, msvs_setting)),
stderr)
else:
print(('Warning: unrecognized tool %s while converting to '
'MSBuild.' % msvs_tool_name), file=stderr)
print('Warning: unrecognized tool %s while converting to '
'MSBuild.' % msvs_tool_name, file=stderr)
return msbuild_settings


Expand Down Expand Up @@ -519,8 +520,8 @@ def _ValidateSettings(validators, settings, stderr):
try:
tool_validators[setting](value)
except ValueError as e:
print(('Warning: for %s/%s, %s' %
(tool_name, setting, e)), file=stderr)
print('Warning: for %s/%s, %s' %
(tool_name, setting, e), file=stderr)
else:
_ValidateExclusionSetting(setting,
tool_validators,
Expand All @@ -529,7 +530,7 @@ def _ValidateSettings(validators, settings, stderr):
stderr)

else:
print(('Warning: unrecognized tool %s' % tool_name), file=stderr)
print('Warning: unrecognized tool %s' % (tool_name), file=stderr)


# MSVS and MBuild names of the tools.
Expand Down
9 changes: 5 additions & 4 deletions gyp/pylib/gyp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# found in the LICENSE file.

from __future__ import print_function

import copy
import gyp.input
import optparse
Expand Down Expand Up @@ -227,12 +228,12 @@ def Noop(value):
(action == 'store_false' and not value)):
flags.append(opt)
elif options.use_environment and env_name:
print(('Warning: environment regeneration unimplemented '
print('Warning: environment regeneration unimplemented '
'for %s flag %r env_name %r' % (action, opt,
env_name)), file=sys.stderr)
env_name), file=sys.stderr)
else:
print(('Warning: regeneration unimplemented for action %r '
'flag %r' % (action, opt)), file=sys.stderr)
print('Warning: regeneration unimplemented for action %r '
'flag %r' % (action, opt), file=sys.stderr)

return flags

Expand Down
15 changes: 8 additions & 7 deletions gyp/pylib/gyp/generator/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
directly supplied to gyp. OTOH if both "a.gyp" and "b.gyp" are supplied to gyp
then the "all" target includes "b1" and "b2".
"""

from __future__ import print_function

import gyp.common
Expand Down Expand Up @@ -292,8 +293,8 @@ def _WasBuildFileModified(build_file, data, files, toplevel_dir):
_ToGypPath(gyp.common.UnrelativePath(include_file, build_file))
if _ToLocalPath(toplevel_dir, rel_include_file) in files:
if debug:
print('included gyp file modified, gyp_file=', build_file, \
'included file=', rel_include_file)
print('included gyp file modified, gyp_file=', build_file,
'included file=', rel_include_file)
return True
return False

Expand Down Expand Up @@ -485,11 +486,11 @@ def _AddCompileTargets(target, roots, add_if_no_ancestor, result):
(add_if_no_ancestor or target.requires_build)) or
(target.is_static_library and add_if_no_ancestor and
not target.is_or_has_linked_ancestor)):
print('\t\tadding to compile targets', target.name, 'executable', \
target.is_executable, 'added_to_compile_targets', \
target.added_to_compile_targets, 'add_if_no_ancestor', \
add_if_no_ancestor, 'requires_build', target.requires_build, \
'is_static_library', target.is_static_library, \
print('\t\tadding to compile targets', target.name, 'executable',
target.is_executable, 'added_to_compile_targets',
target.added_to_compile_targets, 'add_if_no_ancestor',
add_if_no_ancestor, 'requires_build', target.requires_build,
'is_static_library', target.is_static_library,
'is_or_has_linked_ancestor', target.is_or_has_linked_ancestor)
result.add(target)
target.added_to_compile_targets = True
Expand Down
15 changes: 8 additions & 7 deletions gyp/pylib/gyp/generator/android.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import print_function
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand All @@ -15,6 +14,8 @@
# variables set potentially clash with other Android build system variables.
# Try to avoid setting global variables where possible.

from __future__ import print_function

import gyp
import gyp.common
import gyp.generator.make as make # Reuse global functions from make backend.
Expand Down Expand Up @@ -251,7 +252,7 @@ def WriteActions(self, actions, extra_sources, extra_outputs):
dirs = set()
for out in outputs:
if not out.startswith('$'):
print ('WARNING: Action for target "%s" writes output to local path '
print('WARNING: Action for target "%s" writes output to local path '
'"%s".' % (self.target, out))
dir = os.path.split(out)[0]
if dir:
Expand Down Expand Up @@ -356,7 +357,7 @@ def WriteRules(self, rules, extra_sources, extra_outputs):
dirs = set()
for out in outputs:
if not out.startswith('$'):
print ('WARNING: Rule for target %s writes output to local path %s'
print('WARNING: Rule for target %s writes output to local path %s'
% (self.target, out))
dir = os.path.dirname(out)
if dir:
Expand Down Expand Up @@ -430,7 +431,7 @@ def WriteCopies(self, copies, extra_outputs):
# $(gyp_shared_intermediate_dir). Note that we can't use an assertion
# because some of the gyp tests depend on this.
if not copy['destination'].startswith('$'):
print ('WARNING: Copy rule for target %s writes output to '
print('WARNING: Copy rule for target %s writes output to '
'local path %s' % (self.target, copy['destination']))

# LocalPathify() calls normpath, stripping trailing slashes.
Expand Down Expand Up @@ -637,8 +638,8 @@ def ComputeOutputParts(self, spec):
elif self.type == 'none':
target_ext = '.stamp'
elif self.type != 'executable':
print(("ERROR: What output file should be generated?",
"type", self.type, "target", target))
print("ERROR: What output file should be generated?",
"type", self.type, "target", target)

if self.type != 'static_library' and self.type != 'shared_library':
target_prefix = spec.get('product_prefix', target_prefix)
Expand Down Expand Up @@ -1066,7 +1067,7 @@ def CalculateMakefilePath(build_file, base_name):
write_alias_target=write_alias_targets,
sdk_version=sdk_version)
if android_module in android_modules:
print ('ERROR: Android module names must be unique. The following '
print('ERROR: Android module names must be unique. The following '
'targets both generate Android module name %s.\n %s\n %s' %
(android_module, android_modules[android_module],
qualified_target))
Expand Down
9 changes: 5 additions & 4 deletions gyp/pylib/gyp/generator/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
not be able to find the header file directories described in the generated
CMakeLists.txt file.
"""

from __future__ import print_function

import multiprocessing
Expand Down Expand Up @@ -640,8 +641,8 @@ def WriteTarget(namer, qualified_target, target_dicts, build_dir, config_to_use,

cmake_target_type = cmake_target_type_from_gyp_target_type.get(target_type)
if cmake_target_type is None:
print ('Target %s has unknown target type %s, skipping.' %
( target_name, target_type ) )
print('Target %s has unknown target type %s, skipping.' %
( target_name, target_type ))
return

SetVariable(output, 'TARGET', target_name)
Expand Down Expand Up @@ -864,8 +865,8 @@ def WriteTarget(namer, qualified_target, target_dicts, build_dir, config_to_use,
default_product_ext = generator_default_variables['SHARED_LIB_SUFFIX']

elif target_type != 'executable':
print(('ERROR: What output file should be generated?',
'type', target_type, 'target', target_name))
print('ERROR: What output file should be generated?',
'type', target_type, 'target', target_name)

product_prefix = spec.get('product_prefix', default_product_prefix)
product_name = spec.get('product_name', default_product_name)
Expand Down
12 changes: 6 additions & 6 deletions gyp/pylib/gyp/generator/make.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import print_function
# Copyright (c) 2013 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand All @@ -22,6 +21,8 @@
# toplevel Makefile. It may make sense to generate some .mk files on
# the side to keep the files readable.

from __future__ import print_function

import os
import re
import sys
Expand Down Expand Up @@ -678,9 +679,8 @@ def _ValidateSourcesForOSX(spec, all_sources):
error += ' %s: %s\n' % (basename, ' '.join(files))

if error:
print('static library %s has several files with the same basename:\n' %
spec['target_name'] + error + 'libtool on OS X will generate' +
' warnings for them.')
print(('static library %s has several files with the same basename:\n' % spec['target_name'])
+ error + 'libtool on OS X will generate' + ' warnings for them.')
raise GypError('Duplicate basenames in sources section, see list above')


Expand Down Expand Up @@ -1382,8 +1382,8 @@ def ComputeOutputBasename(self, spec):
elif self.type == 'none':
target = '%s.stamp' % target
elif self.type != 'executable':
print(("ERROR: What output file should be generated?",
"type", self.type, "target", target))
print("ERROR: What output file should be generated?",
"type", self.type, "target", target)

target_prefix = spec.get('product_prefix', target_prefix)
target = spec.get('product_name', target)
Expand Down
13 changes: 7 additions & 6 deletions gyp/pylib/gyp/generator/msvs.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import print_function
# Copyright (c) 2012 Google Inc. All rights reserved.
# 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 copy
import ntpath
import os
Expand Down Expand Up @@ -756,8 +757,8 @@ def _Replace(match):
# the VCProj but cause the same problem on the final command-line. Moving
# the item to the end of the list does works, but that's only possible if
# there's only one such item. Let's just warn the user.
print(('Warning: MSVS may misinterpret the odd number of ' +
'quotes in ' + s), file=sys.stderr)
print('Warning: MSVS may misinterpret the odd number of ' +
'quotes in ' + s, file=sys.stderr)
return s


Expand Down Expand Up @@ -975,8 +976,8 @@ def _ValidateSourcesForMSVSProject(spec, version):
error += ' %s: %s\n' % (basename, ' '.join(files))

if error:
print('static library %s has several files with the same basename:\n' %
spec['target_name'] + error + 'MSVC08 cannot handle that.')
print('static library %s has several files with the same basename:\n' % spec['target_name']
+ error + 'MSVC08 cannot handle that.')
raise GypError('Duplicate basenames in sources section, see list above')


Expand Down Expand Up @@ -3028,7 +3029,7 @@ def _FinalizeMSBuildSettings(spec, configuration):
for ignored_setting in ignored_settings:
value = configuration.get(ignored_setting)
if value:
print ('Warning: The automatic conversion to MSBuild does not handle '
print('Warning: The automatic conversion to MSBuild does not handle '
'%s. Ignoring setting of %s' % (ignored_setting, str(value)))

defines = [_EscapeCppDefineForMSBuild(d) for d in defines]
Expand Down
7 changes: 4 additions & 3 deletions gyp/pylib/gyp/input.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import print_function
# Copyright (c) 2012 Google Inc. All rights reserved.
# 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

from compiler.ast import Const
from compiler.ast import Dict
from compiler.ast import Discard
Expand Down Expand Up @@ -2530,8 +2531,8 @@ def ValidateSourcesInTarget(target, target_dict, build_file,
error += ' %s: %s\n' % (basename, ' '.join(files))

if error:
print('static library %s has several files with the same basename:\n' %
target + error + 'libtool on Mac cannot handle that. Use '
print('static library %s has several files with the same basename:\n' % target
+ error + 'libtool on Mac cannot handle that. Use '
'--no-duplicate-basename-check to disable this validation.')
raise GypError('Duplicate basenames in sources section, see list above')

Expand Down
7 changes: 3 additions & 4 deletions gyp/pylib/gyp/mac_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
These functions are executed via gyp-mac-tool when using the Makefile generator.
"""

from __future__ import print_function

import fcntl
Expand Down Expand Up @@ -441,8 +442,7 @@ def _FindProvisioningProfile(self, profile, bundle_identifier):
profiles_dir = os.path.join(
os.environ['HOME'], 'Library', 'MobileDevice', 'Provisioning Profiles')
if not os.path.isdir(profiles_dir):
print((
'cannot find mobile provisioning for %s' % bundle_identifier), file=sys.stderr)
print('cannot find mobile provisioning for %s' % (bundle_identifier), file=sys.stderr)
sys.exit(1)
provisioning_profiles = None
if profile:
Expand All @@ -463,8 +463,7 @@ def _FindProvisioningProfile(self, profile, bundle_identifier):
valid_provisioning_profiles[app_id_pattern] = (
profile_path, profile_data, team_identifier)
if not valid_provisioning_profiles:
print((
'cannot find mobile provisioning for %s' % bundle_identifier), file=sys.stderr)
print('cannot find mobile provisioning for %s' % (bundle_identifier), file=sys.stderr)
sys.exit(1)
# If the user has multiple provisioning profiles installed that can be
# used for ${bundle_identifier}, pick the most specific one (ie. the
Expand Down
1 change: 1 addition & 0 deletions gyp/pylib/gyp/win_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
These functions are executed via gyp-win-tool when using the ninja generator.
"""

from __future__ import print_function

import os
Expand Down
1 change: 1 addition & 0 deletions gyp/pylib/gyp/xcode_emulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
This module contains classes that help to emulate xcodebuild behavior on top of
other build systems, such as make and ninja.
"""

from __future__ import print_function

import copy
Expand Down
1 change: 1 addition & 0 deletions gyp/tools/graphviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""Using the JSON dumped by the dump-dependency-json generator,
generate input suitable for graphviz to render a dependency graph of
targets."""

from __future__ import print_function

import collections
Expand Down
1 change: 1 addition & 0 deletions gyp/tools/pretty_gyp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# found in the LICENSE file.

"""Pretty-prints the contents of a GYP file."""

from __future__ import print_function

import sys
Expand Down
3 changes: 2 additions & 1 deletion gyp/tools/pretty_sln.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
Then it outputs a possible build order.
"""
from __future__ import print_function

__author__ = 'nsylvain (Nicolas Sylvain)'

from __future__ import print_function

import os
import re
import sys
Expand Down
8 changes: 4 additions & 4 deletions gyp/tools/pretty_vcproj.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
It outputs the resulting xml to stdout.
"""
from __future__ import print_function

__author__ = 'nsylvain (Nicolas Sylvain)'

from __future__ import print_function

import os
import sys

Expand Down Expand Up @@ -284,8 +284,8 @@ def main(argv):

# check if we have exactly 1 parameter.
if len(argv) < 2:
print ('Usage: %s "c:\\path\\to\\vcproj.vcproj" [key1=value1] '
'[key2=value2]' % argv[0])
print(('Usage: %s "c:\\path\\to\\vcproj.vcproj" [key1=value1] '
'[key2=value2]' % argv[0]))
return 1

# Parse the keys
Expand Down

0 comments on commit 2040cd2

Please sign in to comment.