14
14
MSBuild install directory, e.g. c:\Program Files (x86)\MSBuild
15
15
"""
16
16
17
- from __future__ import print_function
18
-
19
- from gyp import string_types
20
-
21
- import sys
22
17
import re
18
+ import sys
23
19
24
20
# Dictionaries of settings validators. The key is the tool name, the value is
25
21
# a dictionary mapping setting names to validation functions.
36
32
_msbuild_name_of_tool = {}
37
33
38
34
39
- class _Tool ( object ) :
35
+ class _Tool :
40
36
"""Represents a tool used by MSVS or MSBuild.
41
37
42
38
Attributes:
@@ -68,7 +64,7 @@ def _GetMSBuildToolSettings(msbuild_settings, tool):
68
64
return msbuild_settings .setdefault (tool .msbuild_name , {})
69
65
70
66
71
- class _Type ( object ) :
67
+ class _Type :
72
68
"""Type of settings (Base class)."""
73
69
74
70
def ValidateMSVS (self , value ):
@@ -110,11 +106,11 @@ class _String(_Type):
110
106
"""A setting that's just a string."""
111
107
112
108
def ValidateMSVS (self , value ):
113
- if not isinstance (value , string_types ):
109
+ if not isinstance (value , str ):
114
110
raise ValueError ("expected string; got %r" % value )
115
111
116
112
def ValidateMSBuild (self , value ):
117
- if not isinstance (value , string_types ):
113
+ if not isinstance (value , str ):
118
114
raise ValueError ("expected string; got %r" % value )
119
115
120
116
def ConvertToMSBuild (self , value ):
@@ -126,11 +122,11 @@ class _StringList(_Type):
126
122
"""A settings that's a list of strings."""
127
123
128
124
def ValidateMSVS (self , value ):
129
- if not isinstance (value , string_types ) and not isinstance ( value , list ):
125
+ if not isinstance (value , ( list , str ) ):
130
126
raise ValueError ("expected string list; got %r" % value )
131
127
132
128
def ValidateMSBuild (self , value ):
133
- if not isinstance (value , string_types ) and not isinstance ( value , list ):
129
+ if not isinstance (value , ( list , str ) ):
134
130
raise ValueError ("expected string list; got %r" % value )
135
131
136
132
def ConvertToMSBuild (self , value ):
@@ -195,7 +191,7 @@ class _Enumeration(_Type):
195
191
def __init__ (self , label_list , new = None ):
196
192
_Type .__init__ (self )
197
193
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 }
199
195
if new is not None :
200
196
self ._msbuild_values .update (new )
201
197
@@ -342,7 +338,7 @@ def _Translate(value, msbuild_settings):
342
338
if value == "true" :
343
339
tool_settings = _GetMSBuildToolSettings (msbuild_settings , tool )
344
340
if "AdditionalOptions" in tool_settings :
345
- new_flags = "%s %s" % (tool_settings ["AdditionalOptions" ], flag )
341
+ new_flags = "{} {}" . format (tool_settings ["AdditionalOptions" ], flag )
346
342
else :
347
343
new_flags = flag
348
344
tool_settings ["AdditionalOptions" ] = new_flags
@@ -536,14 +532,14 @@ def _ValidateSettings(validators, settings, stderr):
536
532
tool_validators [setting ](value )
537
533
except ValueError as e :
538
534
print (
539
- "Warning: for %s/%s, %s" % ( tool_name , setting , e ) ,
535
+ f "Warning: for { tool_name } / { setting } , { e } " ,
540
536
file = stderr ,
541
537
)
542
538
else :
543
539
_ValidateExclusionSetting (
544
540
setting ,
545
541
tool_validators ,
546
- ("Warning: unrecognized setting %s/%s" % ( tool_name , setting ) ),
542
+ (f "Warning: unrecognized setting { tool_name } / { setting } " ),
547
543
stderr ,
548
544
)
549
545
0 commit comments