7575
7676"""
7777
78- class Checker ( object ) :
78+ class Checker :
7979 def __init__ (self ):
8080 path = os .getenv ('LLVM_COMPILER_PATH' )
8181
@@ -112,17 +112,17 @@ def check(self):
112112 return 0 if success else 1
113113
114114 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 ' )
117117
118118
119119 def checkLogging (self ):
120120 (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" } .' )
122122 if not level :
123- print ('Logging level not set, defaulting to WARNING\n ' )
123+ print ('Logging level not set, defaulting to WARNING. ' )
124124 else :
125- print ('Logging level set to {0}. \n ' . format ( level ) )
125+ print (f 'Logging level set to { level } .' )
126126
127127
128128 def checkOS (self ):
@@ -137,7 +137,7 @@ def checkSwitch(self):
137137 compiler_type = os .getenv ('LLVM_COMPILER' )
138138 if compiler_type == 'clang' :
139139 return (1 , '\n We are using clang.\n ' )
140- elif compiler_type == 'dragonegg' :
140+ if compiler_type == 'dragonegg' :
141141 return (2 , '\n We are using dragonegg.\n ' )
142142 return (0 , explain_LLVM_COMPILER )
143143
@@ -147,8 +147,8 @@ def checkClang(self):
147147 cc_name = os .getenv ('LLVM_CC_NAME' )
148148 cxx_name = os .getenv ('LLVM_CXX_NAME' )
149149
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++" } '
152152
153153 return self .checkCompilers (cc , cxx )
154154
@@ -162,8 +162,8 @@ def checkDragonegg(self):
162162 if os .getenv ('LLVM_GCC_PREFIX' ) is not None :
163163 pfx = os .getenv ('LLVM_GCC_PREFIX' )
164164
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++'
167167
168168 return self .checkCompilers (cc , cxx )
169169
@@ -180,11 +180,11 @@ def checkDragoneggPlugin(self):
180180 try :
181181 open (plugin )
182182 except IOError as e :
183- print (" Unable to open {0 }: {1}" . format ( plugin , str (e )) )
183+ print (f' Unable to open { plugin } : { str (e )} ' )
184184 else :
185185 return True
186186 else :
187- print (" Could not find {0}" . format ( plugin ) )
187+ print (f' Could not find { plugin } ' )
188188 return False
189189
190190
@@ -195,10 +195,10 @@ def checkCompiler(self):
195195 if code == 0 :
196196 print (comment )
197197 return False
198- elif code == 1 :
198+ if code == 1 :
199199 print (comment )
200200 return self .checkClang ()
201- elif code == 2 :
201+ if code == 2 :
202202 print (comment )
203203 return self .checkDragonegg ()
204204 print ('Insane' )
@@ -212,14 +212,14 @@ def checkCompilers(self, cc, cxx):
212212 (cxxOk , cxxVersion ) = self .checkExecutable (cxx )
213213
214214 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 ' )
216216 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 ' )
218218
219219 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 ' )
221221 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 ' )
223223
224224 if not ccOk or not cxxOk :
225225 print (explain_LLVM_COMPILER_PATH )
@@ -239,13 +239,13 @@ def checkExecutable(self, exe, version_switch='-v'):
239239 try :
240240 compiler = sp .Popen (cmd , stdout = sp .PIPE , stderr = sp .PIPE )
241241 output = compiler .communicate ()
242- compilerOutput = '{0}{1}' . format ( output [0 ], output [1 ])
242+ compilerOutput = f' { output [0 ]. decode () } { output [1 ]. decode () } '
243243 except OSError as e :
244244 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 } ' )
249249 else :
250250 return (True , compilerOutput )
251251
@@ -262,34 +262,34 @@ def checkAuxiliaries(self):
262262 if not ar_name :
263263 ar_name = 'llvm-ar'
264264
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
267267
268268 (linkOk , linkVersion ) = self .checkExecutable (link , '-version' )
269269
270270 (arOk , arVersion ) = self .checkExecutable (ar , '-version' )
271271
272272 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 ' )
274274 print (explain_LLVM_LINK_NAME )
275275 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 ' )
277277
278278 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 ' )
280280 print (explain_LLVM_AR_NAME )
281281 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 ' )
283283
284284
285285 def checkStore (self ):
286286 """Checks that the bitcode store, if set, makes sense."""
287287 store_dir = os .getenv ('WLLVM_BC_STORE' )
288288 if store_dir :
289289 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 ' )
291291 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 ' )
293293 else :
294294 print ('Not using a bitcode store.\n \n ' )
295295
0 commit comments