1414MSBuild install directory, e.g. c:\Program Files (x86)\MSBuild
1515"""
1616
17- from __future__ import print_function
18-
19- from gyp import string_types
20-
21- import sys
2217import re
18+ import sys
2319
2420# Dictionaries of settings validators. The key is the tool name, the value is
2521# a dictionary mapping setting names to validation functions.
3632_msbuild_name_of_tool = {}
3733
3834
39- class _Tool ( object ) :
35+ class _Tool :
4036 """Represents a tool used by MSVS or MSBuild.
4137
4238 Attributes:
@@ -68,7 +64,7 @@ def _GetMSBuildToolSettings(msbuild_settings, tool):
6864 return msbuild_settings .setdefault (tool .msbuild_name , {})
6965
7066
71- class _Type ( object ) :
67+ class _Type :
7268 """Type of settings (Base class)."""
7369
7470 def ValidateMSVS (self , value ):
@@ -110,11 +106,11 @@ class _String(_Type):
110106 """A setting that's just a string."""
111107
112108 def ValidateMSVS (self , value ):
113- if not isinstance (value , string_types ):
109+ if not isinstance (value , str ):
114110 raise ValueError ("expected string; got %r" % value )
115111
116112 def ValidateMSBuild (self , value ):
117- if not isinstance (value , string_types ):
113+ if not isinstance (value , str ):
118114 raise ValueError ("expected string; got %r" % value )
119115
120116 def ConvertToMSBuild (self , value ):
@@ -126,11 +122,11 @@ class _StringList(_Type):
126122 """A settings that's a list of strings."""
127123
128124 def ValidateMSVS (self , value ):
129- if not isinstance (value , string_types ) and not isinstance ( value , list ):
125+ if not isinstance (value , ( list , str ) ):
130126 raise ValueError ("expected string list; got %r" % value )
131127
132128 def ValidateMSBuild (self , value ):
133- if not isinstance (value , string_types ) and not isinstance ( value , list ):
129+ if not isinstance (value , ( list , str ) ):
134130 raise ValueError ("expected string list; got %r" % value )
135131
136132 def ConvertToMSBuild (self , value ):
@@ -195,7 +191,7 @@ class _Enumeration(_Type):
195191 def __init__ (self , label_list , new = None ):
196192 _Type .__init__ (self )
197193 self ._label_list = label_list
198- self ._msbuild_values = set ( value for value in label_list if value is not None )
194+ self ._msbuild_values = { value for value in label_list if value is not None }
199195 if new is not None :
200196 self ._msbuild_values .update (new )
201197
@@ -342,7 +338,7 @@ def _Translate(value, msbuild_settings):
342338 if value == "true" :
343339 tool_settings = _GetMSBuildToolSettings (msbuild_settings , tool )
344340 if "AdditionalOptions" in tool_settings :
345- new_flags = "%s %s" % (tool_settings ["AdditionalOptions" ], flag )
341+ new_flags = "{} {}" . format (tool_settings ["AdditionalOptions" ], flag )
346342 else :
347343 new_flags = flag
348344 tool_settings ["AdditionalOptions" ] = new_flags
@@ -536,14 +532,14 @@ def _ValidateSettings(validators, settings, stderr):
536532 tool_validators [setting ](value )
537533 except ValueError as e :
538534 print (
539- "Warning: for %s/%s, %s" % ( tool_name , setting , e ) ,
535+ f "Warning: for { tool_name } / { setting } , { e } " ,
540536 file = stderr ,
541537 )
542538 else :
543539 _ValidateExclusionSetting (
544540 setting ,
545541 tool_validators ,
546- ("Warning: unrecognized setting %s/%s" % ( tool_name , setting ) ),
542+ (f "Warning: unrecognized setting { tool_name } / { setting } " ),
547543 stderr ,
548544 )
549545
0 commit comments