Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Unified Diff: pylib/gyp/MSVSSettings.py

Issue 1454433002: Python 3 compatibility Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: Rebase with master (4ec6c4e3a94bd04a6da2858163d40b2429b8aad1) Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pylib/gyp/MSVSSettings.py
diff --git a/pylib/gyp/MSVSSettings.py b/pylib/gyp/MSVSSettings.py
index 4985756bdde76a5412bf82ad5317177198b8475d..42d3b95e62bfa5a3e5067bb9981bc796e5f04332 100644
--- a/pylib/gyp/MSVSSettings.py
+++ b/pylib/gyp/MSVSSettings.py
@@ -14,9 +14,16 @@ 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
import re
+try:
+ basestring = basestring
+except NameError:
+ basestring = str
+
# Dictionaries of settings validators. The key is the tool name, the value is
# a dictionary mapping setting names to validation functions.
_msvs_validators = {}
@@ -400,7 +407,7 @@ def _ValidateExclusionSetting(setting, settings, error_msg, stderr=sys.stderr):
if unrecognized:
# We don't know this setting. Give a warning.
- print >> stderr, error_msg
+ print(error_msg, file=stderr)
def FixVCMacroSlashes(s):
@@ -433,7 +440,7 @@ def ConvertVCMacrosToMSBuild(s):
'$(PlatformName)': '$(Platform)',
'$(SafeInputName)': '%(Filename)',
}
- for old, new in replace_map.iteritems():
+ for old, new in replace_map.items():
s = s.replace(old, new)
s = FixVCMacroSlashes(s)
return s
@@ -453,17 +460,18 @@ def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
dictionaries of settings and their values.
"""
msbuild_settings = {}
- for msvs_tool_name, msvs_tool_settings in msvs_settings.iteritems():
+ for msvs_tool_name, msvs_tool_settings in msvs_settings.items():
if msvs_tool_name in _msvs_to_msbuild_converters:
msvs_tool = _msvs_to_msbuild_converters[msvs_tool_name]
- for msvs_setting, msvs_value in msvs_tool_settings.iteritems():
+ for msvs_setting, msvs_value in msvs_tool_settings.items():
if msvs_setting in msvs_tool:
# Invoke the translation function.
try:
msvs_tool[msvs_setting](msvs_value, msbuild_settings)
- except ValueError, e:
- print >> stderr, ('Warning: while converting %s/%s to MSBuild, '
- '%s' % (msvs_tool_name, msvs_setting, e))
+ except ValueError as e:
+ print(('Warning: while converting %s/%s to MSBuild, '
+ '%s' % (msvs_tool_name, msvs_setting, e)),
+ file=stderr)
else:
_ValidateExclusionSetting(msvs_setting,
msvs_tool,
@@ -472,8 +480,8 @@ def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
(msvs_tool_name, msvs_setting)),
stderr)
else:
- print >> stderr, ('Warning: unrecognized tool %s while converting to '
- 'MSBuild.' % msvs_tool_name)
+ print(('Warning: unrecognized tool %s while converting to '
+ 'MSBuild.' % msvs_tool_name), file=stderr)
return msbuild_settings
@@ -513,13 +521,13 @@ def _ValidateSettings(validators, settings, stderr):
for tool_name in settings:
if tool_name in validators:
tool_validators = validators[tool_name]
- for setting, value in settings[tool_name].iteritems():
+ for setting, value in settings[tool_name].items():
if setting in tool_validators:
try:
tool_validators[setting](value)
- except ValueError, e:
- print >> stderr, ('Warning: for %s/%s, %s' %
- (tool_name, setting, e))
+ except ValueError as e:
+ print(('Warning: for %s/%s, %s' %
+ (tool_name, setting, e)), file=stderr)
else:
_ValidateExclusionSetting(setting,
tool_validators,
@@ -528,7 +536,7 @@ def _ValidateSettings(validators, settings, stderr):
stderr)
else:
- print >> stderr, ('Warning: unrecognized tool %s' % tool_name)
+ print(('Warning: unrecognized tool %s' % tool_name), file=stderr)
# MSVS and MBuild names of the tools.

Powered by Google App Engine
This is Rietveld 408576698