@@ -65,9 +65,7 @@ def __init__(self, sourceFile, id, codeblock, pathFinder):
65
65
self .children = set ()
66
66
if not os .path .exists (self .progFullPath ):
67
67
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"
71
69
)
72
70
sys .exit (- 1 )
73
71
@@ -81,43 +79,43 @@ def DoInputsExists(self):
81
79
if ii == None :
82
80
continue
83
81
if not os .path .exists (ii ):
84
- print ("ERROR: XXXXXXXXXXXX MISSING {0}" . format ( ii ) )
82
+ print (f "ERROR: XXXXXXXXXXXX MISSING { ii } " )
85
83
return False
86
84
return True
87
85
88
86
def AreOutputsNewer (self ):
89
87
oldest_output = 100000000000000000000000
90
88
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 } " )
93
91
for o in self .outputs :
94
92
if self .verbose :
95
- print ("CHECKING TIME FOR: {0}" . format ( o ) )
93
+ print (f "CHECKING TIME FOR: { o } " )
96
94
if os .path .exists (o ):
97
95
this_output_time = os .path .getmtime (o )
98
96
if self .verbose :
99
- print ("This Ouptut Time: {0}" . format ( this_output_time ) )
97
+ print (f "This Ouptut Time: { this_output_time } " )
100
98
if this_output_time < oldest_output :
101
99
oldest_output = this_output_time
102
100
else :
103
101
if self .verbose :
104
- print ("Missing Output: {0}" . format ( o ) )
102
+ print (f "Missing Output: { o } " )
105
103
return False
106
104
newest_input = os .path .getmtime (self .progFullPath )
107
105
for i in self .inputs :
108
106
if i == None :
109
107
continue
110
108
if self .verbose :
111
- print ("CHECKING TIME FOR: {0}" . format ( i ) )
109
+ print (f "CHECKING TIME FOR: { i } " )
112
110
if os .path .exists (i ):
113
111
this_input_time = os .path .getmtime (i )
114
112
if self .verbose :
115
- print ("This Input Time: {0}" . format ( this_input_time ) )
113
+ print (f "This Input Time: { this_input_time } " )
116
114
if this_input_time > newest_input :
117
115
newest_input = this_input_time
118
116
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 } " )
121
119
print ("ERROR:" * 20 )
122
120
print (
123
121
"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):
126
124
- 1
127
125
) # This should never happen because you should only run this function once all inputs exists.
128
126
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 } " )
134
128
if newest_input < oldest_output :
135
129
return True
136
130
else :
@@ -145,19 +139,15 @@ def GetCommandLine(self):
145
139
parseGroups = lineparse .search (currLine )
146
140
if parseGroups == None :
147
141
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 } "
151
143
)
152
144
sys .exit (- 1 )
153
145
if parseGroups .group (1 ) == "INPUTS" :
154
146
inputBaseFileName = parseGroups .group (2 )
155
147
inputFileName = pathFinder .GetInputPath (inputBaseFileName )
156
148
if inputFileName == None :
157
149
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 } "
161
151
)
162
152
exit (- 1 )
163
153
else :
@@ -166,9 +156,7 @@ def GetCommandLine(self):
166
156
inputFileName = pathFinder .GetOutputPath (inputBaseFileName )
167
157
if not os .path .exists (inputFileName ):
168
158
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"
172
160
)
173
161
self .inputs .append (inputFileName )
174
162
elif parseGroups .group (1 ) == "OUTPUTS" :
@@ -212,9 +200,7 @@ def MakeAllFileLists(self):
212
200
pass
213
201
else :
214
202
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 } "
218
204
)
219
205
sys .exit (- 1 )
220
206
@@ -224,7 +210,7 @@ def Print(self):
224
210
print (self .sourceFile )
225
211
for blocktext in self .codeblock :
226
212
blockline += 1
227
- print ("{0 } : {1}" . format ( blockline , blocktext ) )
213
+ print (f" { blockline } : { blocktext } " )
228
214
print (self .GetCommandLine ())
229
215
print ("^" * 80 )
230
216
@@ -300,17 +286,15 @@ def __init__(self, itkSourceDir, itkExecutablesDir, itkBuildDir, SWGuidBaseOutpu
300
286
mkdir_p (self .outPicDir )
301
287
302
288
# 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"
306
290
dirtyDirPaths = searchPaths .split ("#" )
307
291
308
292
self .searchDirList = []
309
293
for eachpath in dirtyDirPaths :
310
294
if os .path .isdir (eachpath ):
311
295
self .searchDirList .append (os .path .realpath (eachpath ))
312
296
else :
313
- print ("WARNING: MISSING search path {0 } " . format ( eachpath ) )
297
+ print (f "WARNING: MISSING search path { eachpath } " )
314
298
sys .exit (- 1 )
315
299
316
300
def GetProgramPath (self , execfilenamebase ):
@@ -320,7 +304,7 @@ def GetProgramPath(self, execfilenamebase):
320
304
if os .path .exists (testPath ):
321
305
return testPath
322
306
else :
323
- print ("ERROR: {0 } does not exists" . format ( testPath ) )
307
+ print (f "ERROR: { testPath } does not exists" )
324
308
sys .exit (- 1 )
325
309
326
310
def GetInputPath (self , inputBaseName ):
@@ -329,15 +313,15 @@ def GetInputPath(self, inputBaseName):
329
313
if os .path .exists (testPath ):
330
314
return testPath
331
315
else :
332
- # print(' ##STATUS: Not yet found input {0}'.format( testPath) )
316
+ # print(f" ##STATUS: Not yet found input {testPath}" )
333
317
pass
334
318
return self .GetOutputPath (inputBaseName )
335
319
336
320
def GetOutputPath (self , outputBaseName ):
337
321
outPath = os .path .join (self .outPicDir , outputBaseName )
338
322
# outPath = outPath.replace(self.outPicDir+'/'+self.outPicDir, self.outPicDir ) #Avoid multiple path concatenations
339
323
# if not os.path.exists(outPath):
340
- # print("@@Warning: Output missing {0}".format(outPath) )
324
+ # print(f "@@Warning: Output missing {outPath}" )
341
325
return outPath
342
326
343
327
@@ -424,12 +408,12 @@ def GetSortedCodeBlockList(self):
424
408
allCommandBlocks = []
425
409
for rootDir , dirList , fileList in os .walk (args .itkSourceDir ):
426
410
if rootDir .count ("ThirdParty" ) >= 1 :
427
- # print("Passing on: {0}".format(rootDir) )
411
+ # print(f "Passing on: {rootDir}" )
428
412
continue
429
413
430
414
for currFile in fileList :
431
415
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:]}" )
433
417
continue
434
418
sourceFile = os .path .realpath (rootDir + "/" + currFile )
435
419
@@ -442,8 +426,8 @@ def GetSortedCodeBlockList(self):
442
426
runCommand = blockStart .GetCommandLine ()
443
427
for inputFile in blockStart .inputs :
444
428
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 } " )
447
431
try :
448
432
retcode = subprocess .call (runCommand , shell = True )
449
433
if retcode < 0 :
@@ -462,16 +446,12 @@ def GetSortedCodeBlockList(self):
462
446
for outputFile in block .outputs :
463
447
if not os .path .exists (outputFile ):
464
448
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!"
468
450
)
469
451
for inputFile in block .inputs :
470
452
if not os .path .exists (inputFile ):
471
453
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!"
475
455
)
476
456
dependencyDictionary [baseProgramName ].extend (block .outputs )
477
457
for inputFile in block .inputs :
@@ -489,17 +469,16 @@ def GetSortedCodeBlockList(self):
489
469
outputCDFile = open (outputCMakeDependancies , "w" )
490
470
allDependencies = "set(allEPS-DEPS "
491
471
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" + '}" '
494
474
for output in dependencyDictionary [baseName ]:
495
475
epsOutput = os .path .join (
496
476
outputEPSDirectory , os .path .basename (output .replace (".png" , ".eps" ))
497
477
)
498
- outstring += ' "{epsOutput}"' .format (epsOutput = epsOutput .replace ("\\ " , "/" ))
478
+ # chr(92) is backslash
479
+ outstring += f' "{ epsOutput .replace (chr (92 ), "/" )} "'
499
480
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 '
503
482
)
504
483
outstring += ")\n "
505
484
outputCDFile .write (outstring )
0 commit comments