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. |