@@ -65,9 +65,7 @@ def __init__(self, sourceFile, id, codeblock, pathFinder):
6565 self .children = set ()
6666 if not os .path .exists (self .progFullPath ):
6767 print (
68- "ERROR: Required program {0} does not exists. Please rebuild ITK" .format (
69- self .progBaseName
70- )
68+ f"ERROR: Required program { self .progBaseName } does not exists. Please rebuild ITK"
7169 )
7270 sys .exit (- 1 )
7371
@@ -81,43 +79,43 @@ def DoInputsExists(self):
8179 if ii == None :
8280 continue
8381 if not os .path .exists (ii ):
84- print ("ERROR: XXXXXXXXXXXX MISSING {0}" . format ( ii ) )
82+ print (f "ERROR: XXXXXXXXXXXX MISSING { ii } " )
8583 return False
8684 return True
8785
8886 def AreOutputsNewer (self ):
8987 oldest_output = 100000000000000000000000
9088 if self .verbose :
91- print ("Self Outputs {0}" . format ( self .outputs ) )
92- print ("Self Inputs {0}" . format ( self .inputs ) )
89+ print (f "Self Outputs { self .outputs } " )
90+ print (f "Self Inputs { self .inputs } " )
9391 for o in self .outputs :
9492 if self .verbose :
95- print ("CHECKING TIME FOR: {0}" . format ( o ) )
93+ print (f "CHECKING TIME FOR: { o } " )
9694 if os .path .exists (o ):
9795 this_output_time = os .path .getmtime (o )
9896 if self .verbose :
99- print ("This Ouptut Time: {0}" . format ( this_output_time ) )
97+ print (f "This Ouptut Time: { this_output_time } " )
10098 if this_output_time < oldest_output :
10199 oldest_output = this_output_time
102100 else :
103101 if self .verbose :
104- print ("Missing Output: {0}" . format ( o ) )
102+ print (f "Missing Output: { o } " )
105103 return False
106104 newest_input = os .path .getmtime (self .progFullPath )
107105 for i in self .inputs :
108106 if i == None :
109107 continue
110108 if self .verbose :
111- print ("CHECKING TIME FOR: {0}" . format ( i ) )
109+ print (f "CHECKING TIME FOR: { i } " )
112110 if os .path .exists (i ):
113111 this_input_time = os .path .getmtime (i )
114112 if self .verbose :
115- print ("This Input Time: {0}" . format ( this_input_time ) )
113+ print (f "This Input Time: { this_input_time } " )
116114 if this_input_time > newest_input :
117115 newest_input = this_input_time
118116 else :
119- print ("Missing input {0}" . format ( i ) )
120- print ("Searched {0}" . format ( self .inputs ) )
117+ print (f "Missing input { i } " )
118+ print (f "Searched { self .inputs } " )
121119 print ("ERROR:" * 20 )
122120 print (
123121 "Failing to process all data, This should never happen because you should only run this function once all inputs exists."
@@ -126,11 +124,7 @@ def AreOutputsNewer(self):
126124 - 1
127125 ) # This should never happen because you should only run this function once all inputs exists.
128126 if self .verbose :
129- print (
130- "Newest Input: {0}, Oldest Output: {1}" .format (
131- newest_input , oldest_output
132- )
133- )
127+ print (f"Newest Input: { newest_input } , Oldest Output: { oldest_output } " )
134128 if newest_input < oldest_output :
135129 return True
136130 else :
@@ -145,19 +139,15 @@ def GetCommandLine(self):
145139 parseGroups = lineparse .search (currLine )
146140 if parseGroups == None :
147141 print (
148- "ERROR: Invalid parsing of {0} at line {1}" .format (
149- self .sourceFile , currLineNumber
150- )
142+ f"ERROR: Invalid parsing of { self .sourceFile } at line { currLineNumber } "
151143 )
152144 sys .exit (- 1 )
153145 if parseGroups .group (1 ) == "INPUTS" :
154146 inputBaseFileName = parseGroups .group (2 )
155147 inputFileName = pathFinder .GetInputPath (inputBaseFileName )
156148 if inputFileName == None :
157149 print (
158- "ERROR: Invalid input {0} at {1} at line {2}" .format (
159- parseGroups .group (2 ), self .sourceFile , currLineNumber
160- )
150+ f"ERROR: Invalid input { parseGroups .group (2 )} at { self .sourceFile } at line { currLineNumber } "
161151 )
162152 exit (- 1 )
163153 else :
@@ -166,9 +156,7 @@ def GetCommandLine(self):
166156 inputFileName = pathFinder .GetOutputPath (inputBaseFileName )
167157 if not os .path .exists (inputFileName ):
168158 print (
169- "WARNING: Can not find {0} path, assuming it is autogenerated" .format (
170- inputFileName
171- )
159+ f"WARNING: Can not find { inputFileName } path, assuming it is autogenerated"
172160 )
173161 self .inputs .append (inputFileName )
174162 elif parseGroups .group (1 ) == "OUTPUTS" :
@@ -212,9 +200,7 @@ def MakeAllFileLists(self):
212200 pass
213201 else :
214202 print (
215- "ERROR: INVALID LINE IDENTIFIER {0} at line {1} in {2}" .format (
216- parseGroups .group (1 ), lineNumber , self .sourceFile
217- )
203+ f"ERROR: INVALID LINE IDENTIFIER { parseGroups .group (1 )} at line { lineNumber } in { self .sourceFile } "
218204 )
219205 sys .exit (- 1 )
220206
@@ -224,7 +210,7 @@ def Print(self):
224210 print (self .sourceFile )
225211 for blocktext in self .codeblock :
226212 blockline += 1
227- print ("{0 } : {1}" . format ( blockline , blocktext ) )
213+ print (f" { blockline } : { blocktext } " )
228214 print (self .GetCommandLine ())
229215 print ("^" * 80 )
230216
@@ -300,17 +286,15 @@ def __init__(self, itkSourceDir, itkExecutablesDir, itkBuildDir, SWGuidBaseOutpu
300286 mkdir_p (self .outPicDir )
301287
302288 # HACK: Need beter search criteria
303- searchPaths = "{0}/ExternalData/Testing/Data/Input#{0}/ExternalData/Examples/Data/BrainWeb#{0}/Testing/Temporary#{0}/Modules/Nonunit/Review/test#{0}/ExternalData/Modules/Segmentation/LevelSetsv4/test/Baseline#{0}/ExternalData/Modules/IO/GE/test/Baseline#{0}/ExternalData/Examples/Filtering/test/Baseline#{0}/Examples/Segmentation/test#{1}/Art/Generated#{2}/Examples/Data" .format (
304- itkBuildDir , SWGuidBaseOutput , itkSourceDir
305- )
289+ searchPaths = f"{ itkBuildDir } /ExternalData/Testing/Data/Input#{ itkBuildDir } /ExternalData/Examples/Data/BrainWeb#{ itkBuildDir } /Testing/Temporary#{ itkBuildDir } /Modules/Nonunit/Review/test#{ itkBuildDir } /ExternalData/Modules/Segmentation/LevelSetsv4/test/Baseline#{ itkBuildDir } /ExternalData/Modules/IO/GE/test/Baseline#{ itkBuildDir } /ExternalData/Examples/Filtering/test/Baseline#{ itkBuildDir } /Examples/Segmentation/test#{ SWGuidBaseOutput } /Art/Generated#{ itkSourceDir } /Examples/Data"
306290 dirtyDirPaths = searchPaths .split ("#" )
307291
308292 self .searchDirList = []
309293 for eachpath in dirtyDirPaths :
310294 if os .path .isdir (eachpath ):
311295 self .searchDirList .append (os .path .realpath (eachpath ))
312296 else :
313- print ("WARNING: MISSING search path {0 } " . format ( eachpath ) )
297+ print (f "WARNING: MISSING search path { eachpath } " )
314298 sys .exit (- 1 )
315299
316300 def GetProgramPath (self , execfilenamebase ):
@@ -320,7 +304,7 @@ def GetProgramPath(self, execfilenamebase):
320304 if os .path .exists (testPath ):
321305 return testPath
322306 else :
323- print ("ERROR: {0 } does not exists" . format ( testPath ) )
307+ print (f "ERROR: { testPath } does not exists" )
324308 sys .exit (- 1 )
325309
326310 def GetInputPath (self , inputBaseName ):
@@ -329,15 +313,15 @@ def GetInputPath(self, inputBaseName):
329313 if os .path .exists (testPath ):
330314 return testPath
331315 else :
332- # print(' ##STATUS: Not yet found input {0}'.format( testPath) )
316+ # print(f" ##STATUS: Not yet found input {testPath}" )
333317 pass
334318 return self .GetOutputPath (inputBaseName )
335319
336320 def GetOutputPath (self , outputBaseName ):
337321 outPath = os .path .join (self .outPicDir , outputBaseName )
338322 # outPath = outPath.replace(self.outPicDir+'/'+self.outPicDir, self.outPicDir ) #Avoid multiple path concatenations
339323 # if not os.path.exists(outPath):
340- # print("@@Warning: Output missing {0}".format(outPath) )
324+ # print(f "@@Warning: Output missing {outPath}" )
341325 return outPath
342326
343327
@@ -424,12 +408,12 @@ def GetSortedCodeBlockList(self):
424408 allCommandBlocks = []
425409 for rootDir , dirList , fileList in os .walk (args .itkSourceDir ):
426410 if rootDir .count ("ThirdParty" ) >= 1 :
427- # print("Passing on: {0}".format(rootDir) )
411+ # print(f "Passing on: {rootDir}" )
428412 continue
429413
430414 for currFile in fileList :
431415 if currFile [- 4 :] != ".cxx" : # Only parse cxx files
432- # print("NOT PARSING: {0 } because it has wrong extension {1}".format( currFile,currFile [-r:]) )
416+ # print(f "NOT PARSING: {currFile } because it has wrong extension {currFile[-r:]}" )
433417 continue
434418 sourceFile = os .path .realpath (rootDir + "/" + currFile )
435419
@@ -442,8 +426,8 @@ def GetSortedCodeBlockList(self):
442426 runCommand = blockStart .GetCommandLine ()
443427 for inputFile in blockStart .inputs :
444428 if not os .path .exists (inputFile ):
445- print ("WARNING: {0 } input does not exist" . format ( blockStart . sourceFile ) )
446- print ("Running: {0}" . format ( runCommand ) )
429+ print (f "WARNING: { blockStart . sourceFile } input does not exist" )
430+ print (f "Running: { runCommand } " )
447431 try :
448432 retcode = subprocess .call (runCommand , shell = True )
449433 if retcode < 0 :
@@ -462,16 +446,12 @@ def GetSortedCodeBlockList(self):
462446 for outputFile in block .outputs :
463447 if not os .path .exists (outputFile ):
464448 print (
465- "WARNING: output {0} of {1} does not exist!" .format (
466- outputFile , baseProgramName
467- )
449+ f"WARNING: output { outputFile } of { baseProgramName } does not exist!"
468450 )
469451 for inputFile in block .inputs :
470452 if not os .path .exists (inputFile ):
471453 print (
472- "WARNING: input {0} of {1} does not exist!" .format (
473- inputFile , baseProgramName
474- )
454+ f"WARNING: input { inputFile } of { baseProgramName } does not exist!"
475455 )
476456 dependencyDictionary [baseProgramName ].extend (block .outputs )
477457 for inputFile in block .inputs :
@@ -489,17 +469,16 @@ def GetSortedCodeBlockList(self):
489469 outputCDFile = open (outputCMakeDependancies , "w" )
490470 allDependencies = "set(allEPS-DEPS "
491471 for baseName in dependencyDictionary .keys ():
492- outstring = 'set("{name }-DEPS" ' . format ( name = baseName )
493- allDependencies += ' "${' + "{name }-DEPS". format ( name = baseName ) + '}" '
472+ outstring = f 'set("{ baseName } -DEPS" '
473+ allDependencies += ' "${' + f" { baseName } -DEPS" + '}" '
494474 for output in dependencyDictionary [baseName ]:
495475 epsOutput = os .path .join (
496476 outputEPSDirectory , os .path .basename (output .replace (".png" , ".eps" ))
497477 )
498- outstring += ' "{epsOutput}"' .format (epsOutput = epsOutput .replace ("\\ " , "/" ))
478+ # chr(92) is backslash
479+ outstring += f' "{ epsOutput .replace (chr (92 ), "/" )} "'
499480 outputCDFile .write (
500- 'CONVERT_INPUT_IMG("{0}" "{1}" "{2}")\n ' .format (
501- output .replace ("\\ " , "/" ), epsOutput .replace ("\\ " , "/" ), ""
502- )
481+ f'CONVERT_INPUT_IMG("{ output .replace (chr (92 ), "/" )} " "{ epsOutput .replace (chr (92 ), "/" )} " "")\n '
503482 )
504483 outstring += ")\n "
505484 outputCDFile .write (outstring )
0 commit comments