75
75
76
76
"""
77
77
78
- class Checker ( object ) :
78
+ class Checker :
79
79
def __init__ (self ):
80
80
path = os .getenv ('LLVM_COMPILER_PATH' )
81
81
@@ -112,17 +112,17 @@ def check(self):
112
112
return 0 if success else 1
113
113
114
114
def checkSelf (self ):
115
- print ('wllvm version: {0}' . format ( wllvm_version ) )
116
- print ('wllvm released: {0 }\n ' . format ( wllvm_date ) )
115
+ print (f 'wllvm version: { wllvm_version } ' )
116
+ print (f 'wllvm released: { wllvm_date } \n ' )
117
117
118
118
119
119
def checkLogging (self ):
120
120
(destination , level ) = loggingConfiguration ()
121
- print ('Logging output to {0}.' . format ( destination if destination else ' standard error' ) )
121
+ print (f 'Logging output to { destination if destination else " standard error" } .' )
122
122
if not level :
123
- print ('Logging level not set, defaulting to WARNING\n ' )
123
+ print ('Logging level not set, defaulting to WARNING. ' )
124
124
else :
125
- print ('Logging level set to {0}. \n ' . format ( level ) )
125
+ print (f 'Logging level set to { level } .' )
126
126
127
127
128
128
def checkOS (self ):
@@ -137,7 +137,7 @@ def checkSwitch(self):
137
137
compiler_type = os .getenv ('LLVM_COMPILER' )
138
138
if compiler_type == 'clang' :
139
139
return (1 , '\n We are using clang.\n ' )
140
- elif compiler_type == 'dragonegg' :
140
+ if compiler_type == 'dragonegg' :
141
141
return (2 , '\n We are using dragonegg.\n ' )
142
142
return (0 , explain_LLVM_COMPILER )
143
143
@@ -147,8 +147,8 @@ def checkClang(self):
147
147
cc_name = os .getenv ('LLVM_CC_NAME' )
148
148
cxx_name = os .getenv ('LLVM_CXX_NAME' )
149
149
150
- cc = '{0}{1}' . format ( self .path , cc_name if cc_name else ' clang' )
151
- cxx = '{0}{1}' . format ( self .path , cxx_name if cxx_name else ' clang++' )
150
+ cc = f' { self .path } { cc_name if cc_name else " clang" } '
151
+ cxx = f' { self .path } { cxx_name if cxx_name else " clang++" } '
152
152
153
153
return self .checkCompilers (cc , cxx )
154
154
@@ -162,8 +162,8 @@ def checkDragonegg(self):
162
162
if os .getenv ('LLVM_GCC_PREFIX' ) is not None :
163
163
pfx = os .getenv ('LLVM_GCC_PREFIX' )
164
164
165
- cc = '{0}{1 }gcc'. format ( self . path , pfx )
166
- cxx = '{0}{1 }g++'. format ( self . path , pfx )
165
+ cc = f' { self . path } { pfx } gcc'
166
+ cxx = f' { self . path } { pfx } g++'
167
167
168
168
return self .checkCompilers (cc , cxx )
169
169
@@ -180,11 +180,11 @@ def checkDragoneggPlugin(self):
180
180
try :
181
181
open (plugin )
182
182
except IOError as e :
183
- print (" Unable to open {0 }: {1}" . format ( plugin , str (e )) )
183
+ print (f' Unable to open { plugin } : { str (e )} ' )
184
184
else :
185
185
return True
186
186
else :
187
- print (" Could not find {0}" . format ( plugin ) )
187
+ print (f' Could not find { plugin } ' )
188
188
return False
189
189
190
190
@@ -195,10 +195,10 @@ def checkCompiler(self):
195
195
if code == 0 :
196
196
print (comment )
197
197
return False
198
- elif code == 1 :
198
+ if code == 1 :
199
199
print (comment )
200
200
return self .checkClang ()
201
- elif code == 2 :
201
+ if code == 2 :
202
202
print (comment )
203
203
return self .checkDragonegg ()
204
204
print ('Insane' )
@@ -212,14 +212,14 @@ def checkCompilers(self, cc, cxx):
212
212
(cxxOk , cxxVersion ) = self .checkExecutable (cxx )
213
213
214
214
if not ccOk :
215
- print ('The C compiler {0 } was not found or not executable.\n Better not try using wllvm!\n ' . format ( cc ) )
215
+ print (f 'The C compiler { cc } was not found or not executable.\n Better not try using wllvm!\n ' )
216
216
else :
217
- print ('The C compiler {0 } is:\n \n \t {1} \n ' . format ( cc , extractLine (ccVersion , 0 )) )
217
+ print (f 'The C compiler { cc } is:\n \n \t { extractLine (ccVersion , 0 )} \n ' )
218
218
219
219
if not cxxOk :
220
- print ('The CXX compiler {0 } was not found or not executable.\n Better not try using wllvm++!\n ' . format ( cxx ) )
220
+ print (f 'The CXX compiler { cxx } was not found or not executable.\n Better not try using wllvm++!\n ' )
221
221
else :
222
- print ('The C++ compiler {0 } is:\n \n \t {1} \n ' . format ( cxx , extractLine (cxxVersion , 0 )) )
222
+ print (f 'The C++ compiler { cxx } is:\n \n \t { extractLine (cxxVersion , 0 )} \n ' )
223
223
224
224
if not ccOk or not cxxOk :
225
225
print (explain_LLVM_COMPILER_PATH )
@@ -239,13 +239,13 @@ def checkExecutable(self, exe, version_switch='-v'):
239
239
try :
240
240
compiler = sp .Popen (cmd , stdout = sp .PIPE , stderr = sp .PIPE )
241
241
output = compiler .communicate ()
242
- compilerOutput = '{0}{1}' . format ( output [0 ], output [1 ])
242
+ compilerOutput = f' { output [0 ]. decode () } { output [1 ]. decode () } '
243
243
except OSError as e :
244
244
if e .errno == errno .EPERM :
245
- return (False , '{0 } not executable'. format ( exe ) )
246
- elif e .errno == errno .ENOENT :
247
- return (False , '{0 } not found'. format ( exe ) )
248
- return (False , '{0 } not sure why, errno is {1}' . format ( exe , e .errno ) )
245
+ return (False , f' { exe } not executable' )
246
+ if e .errno == errno .ENOENT :
247
+ return (False , f' { exe } not found' )
248
+ return (False , f' { exe } not sure why, errno is { e .errno } ' )
249
249
else :
250
250
return (True , compilerOutput )
251
251
@@ -262,34 +262,34 @@ def checkAuxiliaries(self):
262
262
if not ar_name :
263
263
ar_name = 'llvm-ar'
264
264
265
- link = '{0}{1}' . format ( self .path , link_name ) if self .path else link_name
266
- ar = '{0}{1}' . format ( self .path , ar_name ) if self .path else ar_name
265
+ link = f' { self .path } { link_name } ' if self .path else link_name
266
+ ar = f' { self .path } { ar_name } ' if self .path else ar_name
267
267
268
268
(linkOk , linkVersion ) = self .checkExecutable (link , '-version' )
269
269
270
270
(arOk , arVersion ) = self .checkExecutable (ar , '-version' )
271
271
272
272
if not linkOk :
273
- print ('The bitcode linker {0 } was not found or not executable.\n Better not try using extract-bc!\n ' . format ( link ) )
273
+ print (f 'The bitcode linker { link } was not found or not executable.\n Better not try using extract-bc!\n ' )
274
274
print (explain_LLVM_LINK_NAME )
275
275
else :
276
- print ('The bitcode linker {0 } is:\n \n \t {1} \n ' . format ( link , extractLine (linkVersion , 1 )) )
276
+ print (f 'The bitcode linker { link } is:\n \n \t { extractLine (linkVersion , 1 )} \n ' )
277
277
278
278
if not arOk :
279
- print ('The bitcode archiver {0 } was not found or not executable.\n Better not try using extract-bc!\n ' . format ( ar ) )
279
+ print (f 'The bitcode archiver { ar } was not found or not executable.\n Better not try using extract-bc!\n ' )
280
280
print (explain_LLVM_AR_NAME )
281
281
else :
282
- print ('The bitcode archiver {0 } is:\n \n \t {1} \n ' . format ( ar , extractLine (arVersion , 1 )) )
282
+ print (f 'The bitcode archiver { ar } is:\n \n \t { extractLine (arVersion , 1 )} \n ' )
283
283
284
284
285
285
def checkStore (self ):
286
286
"""Checks that the bitcode store, if set, makes sense."""
287
287
store_dir = os .getenv ('WLLVM_BC_STORE' )
288
288
if store_dir :
289
289
if os .path .exists (store_dir ) and os .path .isdir (store_dir ) and os .path .isabs (store_dir ):
290
- print ('Using the bitcode store:\n \n \t {0 }\n \n ' . format ( store_dir ) )
290
+ print (f 'Using the bitcode store:\n \n \t { store_dir } \n \n ' )
291
291
else :
292
- print ('The bitcode store:\n \n \t {0 }\n \n is either not absolute, does not exist, or is not a directory.\n \n ' . format ( store_dir ) )
292
+ print (f 'The bitcode store:\n \n \t { store_dir } \n \n is either not absolute, does not exist, or is not a directory.\n \n ' )
293
293
else :
294
294
print ('Not using a bitcode store.\n \n ' )
295
295
0 commit comments