@@ -1028,10 +1028,9 @@ def report(f, dest):
1028
1028
msg = 'template %r never instantiated' % (name ,)
1029
1029
else :
1030
1030
assert False
1031
- sys .stderr .write ('%s:%d: warning WUNUSED: %s during build.'
1032
- % (dest , line , msg )
1033
- + ' Only partial porting possible\n ' )
1034
- sys .stderr .write ('%s: original location\n ' % (loc ,))
1031
+ print (f'{ dest } :{ line } : warning WUNUSED: { msg } during build. Only partial porting possible' ,
1032
+ file = sys .stderr )
1033
+ print (f'{ loc } : original location' , file = sys .stderr )
1035
1034
1036
1035
tags = {
1037
1036
'PSHA1' : PSHA1 ,
@@ -1152,19 +1151,18 @@ def main(argv):
1152
1151
t = tags [tag ](loc , ast .literal_eval (params ))
1153
1152
transformations .setdefault (t .phase , []).append ((t , lineno , line ))
1154
1153
except :
1155
- sys . stderr . write ("Unexpected error on this porting tag:\n " )
1156
- sys .stderr . write ( line )
1157
- sys . stderr . write ( "%s:%d : found here\n " % ( tagfilename , lineno ) )
1154
+ print ("Unexpected error on this porting tag:" , file = sys . stderr )
1155
+ print ( line , file = sys .stderr )
1156
+ print ( f" { tagfilename } : { lineno } : found here" , file = sys . stderr )
1158
1157
raise
1159
1158
1160
1159
if not transformations :
1161
- sys .stderr .write ('%s:0: error: no tags found matching file %r' % (
1162
- tagfilename , args .src ))
1160
+ print (f'{ tagfilename } :0: error: no tags found matching file { args .src } ' , file = sys .stderr )
1163
1161
exit (1 )
1164
1162
1165
1163
if args .compat and is_device_file (args .src ):
1166
- sys . stderr . write ( '%s :0: warning: file contains device statement,'
1167
- % ( args . src ,) + ' ignoring --compat flag \n ' )
1164
+ print ( f' { args . src } :0: warning: file contains device statement, ignoring --compat flag' ,
1165
+ file = sys . stderr )
1168
1166
args .compat = False
1169
1167
src = SourceFile (args .src , args .compat )
1170
1168
errors = 0
@@ -1174,14 +1172,14 @@ def main(argv):
1174
1172
t .apply (src )
1175
1173
except PortingFailure as e :
1176
1174
(loc , _ ) = line .split (' porting ' , 2 )
1177
- sys . stderr . write ( "%s error%s: %s \n " % (
1178
- loc , '' if e . tag is None else ' ' + e . tag , e ) )
1179
- sys . stderr . write ( "%s:%d : found here\n " % ( tagfilename , lineno ) )
1175
+ print ( f""" { loc } error{ '' if e . tag is None else ' ' + e . tag } : { e } """ ,
1176
+ file = sys . stderr )
1177
+ print ( f" { tagfilename } : { lineno } : found here" , file = sys . stderr )
1180
1178
errors += 1
1181
1179
except :
1182
- sys . stderr . write ("Unexpected error on this porting tag:\n " )
1183
- sys .stderr . write ( line )
1184
- sys . stderr . write ( "%s:%d : found here\n " % ( tagfilename , lineno ) )
1180
+ print ("Unexpected error on this porting tag:" , file = sys . stderr )
1181
+ print ( line , file = sys .stderr )
1182
+ print ( f" { tagfilename } : { lineno } : found here" , file = sys . stderr )
1185
1183
traceback .print_exc ()
1186
1184
errors += 1
1187
1185
@@ -1191,9 +1189,9 @@ def main(argv):
1191
1189
src .commit (f )
1192
1190
if errors :
1193
1191
total = sum (map (len , transformations .values ()))
1194
- sys . stderr . write (f'''\
1192
+ print (f'''\
1195
1193
*** Failed to apply { errors } out of { total } porting tags; partial result saved to { args .dest } . Consider applying the failed tags manually.
1196
- ''' )
1194
+ ''' , file = sys . stderr )
1197
1195
exit (2 )
1198
1196
1199
1197
if __name__ == '__main__' :
0 commit comments