@@ -163,10 +163,10 @@ def sortable_datetime():
163
163
164
164
165
165
def prompt (prompt ):
166
- return input (f "[{ prompt } > " )
166
+ return input ("[{}> " . format ( prompt ) )
167
167
168
168
def require_ok (prompt ):
169
- prompt = f "[{ prompt } > "
169
+ prompt = "[{}> " . format ( prompt )
170
170
while True :
171
171
s = input (prompt ).strip ()
172
172
if s == 'ok' :
@@ -393,7 +393,7 @@ def parse(self, text, *, metadata=None, filename="input"):
393
393
line_number = None
394
394
395
395
def throw (s ):
396
- raise BlurbError (f "Error in { filename } :{ line_number } :\n { s } " )
396
+ raise BlurbError ("Error in {}:{}:\n {}" . format ( filename , line_number , s ) )
397
397
398
398
def finish_entry ():
399
399
nonlocal body
@@ -473,7 +473,7 @@ def __str__(self):
473
473
add_separator = True
474
474
if metadata :
475
475
for name , value in sorted (metadata .items ()):
476
- add (f ".. { name } : { value } \n " )
476
+ add (".. {}: {}\n " . format ( name , value ) )
477
477
add ("\n " )
478
478
add (textwrap_body (body ))
479
479
return "" .join (output )
@@ -495,10 +495,10 @@ def _parse_next_filename(filename):
495
495
components = filename .split ("/" )
496
496
section , filename = components [- 2 :]
497
497
section = unsanitize_section (section )
498
- assert section in sections , f "Unknown section { section } "
498
+ assert section in sections , "Unknown section {}" . format ( section )
499
499
500
500
fields = [x .strip () for x in filename .split ("." )]
501
- assert len (fields ) >= 4 , f "Can't parse 'next' filename! filename { filename !r} fields { fields } "
501
+ assert len (fields ) >= 4 , "Can't parse 'next' filename! filename {!r} fields {}" . format ( filename , fields )
502
502
assert fields [- 1 ] == "rst"
503
503
504
504
metadata = {"date" : fields [0 ], "nonce" : fields [- 2 ], "section" : section }
@@ -647,7 +647,7 @@ def subcommand(fn):
647
647
def get_subcommand (subcommand ):
648
648
fn = subcommands .get (subcommand )
649
649
if not fn :
650
- error (f "Unknown subcommand: { subcommand } " )
650
+ error ("Unknown subcommand: {}" . format ( subcommand ) )
651
651
return fn
652
652
653
653
@@ -704,19 +704,19 @@ def help(subcommand=None):
704
704
for name , p in inspect .signature (fn ).parameters .items ():
705
705
if p .kind == inspect .Parameter .KEYWORD_ONLY :
706
706
short_option = name [0 ]
707
- options .append (f " [-{ short_option } |--{ name } ]" )
707
+ options .append (" [-{}|--{}]" . format ( short_option , name ) )
708
708
elif p .kind == inspect .Parameter .POSITIONAL_OR_KEYWORD :
709
709
positionals .append (" " )
710
710
has_default = (p .default != inspect ._empty )
711
711
if has_default :
712
712
positionals .append ("[" )
713
713
nesting += 1
714
- positionals .append (f "<{ name } >" )
714
+ positionals .append ("<{}>" . format ( name ) )
715
715
positionals .append ("]" * nesting )
716
716
717
717
718
718
parameters = "" .join (options + positionals )
719
- print (f "blurb { subcommand } { parameters } " )
719
+ print ("blurb {}{}" . format ( subcommand , parameters ) )
720
720
print ()
721
721
print (doc )
722
722
sys .exit (0 )
@@ -811,7 +811,7 @@ def init_tmp_with_template():
811
811
812
812
if failure :
813
813
print ()
814
- print (f "Error: { failure } " )
814
+ print ("Error: {}" . format ( failure ) )
815
815
print ()
816
816
prompt ("Hit return to retry (or Ctrl-C to abort)" )
817
817
print ()
@@ -841,20 +841,20 @@ def release(version):
841
841
if existing_filenames :
842
842
error ("Sorry, can't handle appending 'next' files to an existing version (yet)." )
843
843
844
- output = f "Misc/NEWS.d/{ version } .rst"
844
+ output = "Misc/NEWS.d/{}.rst" . format ( version )
845
845
filenames = glob_blurbs ("next" )
846
846
blurbs = Blurbs ()
847
847
date = current_date ()
848
848
849
849
if not filenames :
850
- print (f "No blurbs found. Setting { version } as having no changes." )
851
- body = f "There were no new changes in version { version } .\n "
850
+ print ("No blurbs found. Setting {} as having no changes." . format ( version ) )
851
+ body = "There were no new changes in version {}.\n " . format ( version )
852
852
metadata = {"no changes" : "True" , "bpo" : "0" , "section" : "Library" , "date" : date , "nonce" : nonceify (body )}
853
853
blurbs .append ((metadata , body ))
854
854
else :
855
855
no_changes = None
856
856
count = len (filenames )
857
- print (f 'Merging { count } blurbs to "{ output } ".' )
857
+ print ('Merging {} blurbs to "{}".' . format ( count , output ) )
858
858
859
859
for filename in filenames :
860
860
if not filename .endswith (".rst" ):
@@ -873,9 +873,9 @@ def release(version):
873
873
# sanity check: ensuring that saving/reloading the merged blurb file works.
874
874
blurbs2 = Blurbs ()
875
875
blurbs2 .load (output )
876
- assert blurbs2 == blurbs , f "Reloading { output } isn't reproducable?!"
876
+ assert blurbs2 == blurbs , "Reloading {} isn't reproducable?!" . format ( output )
877
877
878
- print (f "Removing { len ( filenames ) } 'next' files from git." )
878
+ print ("Removing {} 'next' files from git." . format ( len ( filenames )) )
879
879
git_rm_files .extend (filenames )
880
880
flush_git_rm_files ()
881
881
@@ -948,7 +948,7 @@ def print(*a, sep=" "):
948
948
metadata , body = blurbs [0 ]
949
949
release_date = metadata ["release date" ]
950
950
951
- print (f "*Release date: { release_date } *" )
951
+ print ("*Release date: {}*" . format ( release_date ) )
952
952
print ()
953
953
954
954
if "no changes" in metadata :
@@ -1010,11 +1010,11 @@ def populate():
1010
1010
1011
1011
for section in sections :
1012
1012
dir_name = sanitize_section (section )
1013
- dir_path = f "NEWS.d/next/{ dir_name } "
1013
+ dir_path = "NEWS.d/next/{}" . format ( dir_name )
1014
1014
safe_mkdir (dir_path )
1015
- readme_path = f "NEWS.d/next/{ dir_name } /README.rst"
1015
+ readme_path = "NEWS.d/next/{}/README.rst" . format ( dir_name )
1016
1016
with open (readme_path , "wt" , encoding = "utf-8" ) as f :
1017
- f .write (f "Put news entry ``blurb`` files for the *{ section } * section in this directory.\n " )
1017
+ f .write ("Put news entry ``blurb`` files for the *{}* section in this directory.\n " . format ( section ) )
1018
1018
git_add_files .append (dir_path )
1019
1019
git_add_files .append (readme_path )
1020
1020
flush_git_add_files ()
@@ -1025,7 +1025,7 @@ def populate():
1025
1025
# """
1026
1026
# Test function for blurb command-line processing.
1027
1027
# """
1028
- # print(f "arg: boolean {boolean } option {option}" )
1028
+ # print("arg: boolean {} option {}".format(boolean, option) )
1029
1029
1030
1030
1031
1031
@subcommand
@@ -1110,7 +1110,7 @@ def flush_blurb():
1110
1110
fields .append (field )
1111
1111
see_also = ", " .join (fields )
1112
1112
# print("see_also: ", repr(see_also))
1113
- accumulator .append (f "(See also: { see_also } )" )
1113
+ accumulator .append ("(See also: {})" . format ( see_also ) )
1114
1114
see_also = None
1115
1115
if not accumulator :
1116
1116
return
@@ -1156,8 +1156,8 @@ def flush_version():
1156
1156
if version is None :
1157
1157
assert not blurbs , "version should only be None initially, we shouldn't have blurbs yet"
1158
1158
return
1159
- assert blurbs , f "No blurbs defined when flushing version { version } !"
1160
- output = f "NEWS.d/{ version } .rst"
1159
+ assert blurbs , "No blurbs defined when flushing version {}!" . format ( version )
1160
+ output = "NEWS.d/{}.rst" . format ( version )
1161
1161
1162
1162
if released :
1163
1163
# saving merged blurb file for version, e.g. Misc/NEWS.d/3.7.0a1.rst
@@ -1273,11 +1273,11 @@ def flush_version():
1273
1273
elif line .startswith ("- Issue: #15138: base64.urlsafe_{en,de}code() are now 3-4x faster." ):
1274
1274
line = "- Issue #15138: base64.urlsafe_{en,de}code() are now 3-4x faster."
1275
1275
elif line .title ().startswith (("- Request #" , "- Bug #" , "- Patch #" , "- Patches #" )):
1276
- # print(f "FIXING LINE {line_number }: {line !r}")
1276
+ # print("FIXING LINE {}: {!r}".format(line_number), line )
1277
1277
line = "- Issue #" + line .partition ('#' )[2 ]
1278
- # print(f "FIXED LINE {line !r}")
1278
+ # print("FIXED LINE {!r}".format(line) )
1279
1279
# else:
1280
- # print(f "NOT FIXING LINE {line_number }: {line !r}")
1280
+ # print("NOT FIXING LINE {}: {!r}".format(line_number, line) )
1281
1281
1282
1282
1283
1283
# 4. determine the actual content of the line
@@ -1341,7 +1341,7 @@ def flush_version():
1341
1341
line = line [4 :]
1342
1342
parse_bpo = True
1343
1343
else :
1344
- # print(f "[[{line_number :8} no bpo]] {line}" )
1344
+ # print("[[{:8} no bpo]] {}".format(line_number, line) )
1345
1345
parse_bpo = False
1346
1346
if parse_bpo :
1347
1347
# GAAAH
@@ -1381,9 +1381,9 @@ def flush_version():
1381
1381
try :
1382
1382
int (bpo ) # this will throw if it's not a legal int
1383
1383
except ValueError :
1384
- sys .exit (f "Couldn't convert bpo number to int on line { line_number } ! " + repr (bpo ))
1384
+ sys .exit ("Couldn't convert bpo number to int on line {}! " . format ( line_number ) + repr (bpo ))
1385
1385
if see_also == "partially" :
1386
- sys .exit (f "What the hell on line { line_number } ! " + repr (bpo ))
1386
+ sys .exit ("What the hell on line {}! " . format ( line_number ) + repr (bpo ))
1387
1387
1388
1388
# 4.6.1 continuation of blurb
1389
1389
elif line .startswith (" " ):
@@ -1392,7 +1392,7 @@ def flush_version():
1392
1392
elif line .startswith (" * " ):
1393
1393
line = line [3 :]
1394
1394
elif line :
1395
- sys .exit (f "Didn't recognize line { line_number } ! " + repr (line ))
1395
+ sys .exit ("Didn't recognize line {}! " . format ( line_number ) + repr (line ))
1396
1396
# only add blank lines if we have an initial line in the accumulator
1397
1397
if line or accumulator :
1398
1398
accumulator .append (line )
@@ -1404,7 +1404,7 @@ def flush_version():
1404
1404
git_rm_files .append ("NEWS" )
1405
1405
flush_git_rm_files ()
1406
1406
1407
- print (f "Wrote { blurb_count } news items across { version_count } versions." )
1407
+ print ("Wrote {} news items across {} versions." . format ( blurb_count , version_count ) )
1408
1408
print ()
1409
1409
print ("Ready for commit." )
1410
1410
@@ -1451,10 +1451,10 @@ def main():
1451
1451
def handle_option (s , dict ):
1452
1452
name = dict .get (s , None )
1453
1453
if not name :
1454
- sys .exit (f 'blurb: Unknown option for { subcommand } : "{ s } "' )
1454
+ sys .exit ('blurb: Unknown option for {}: "{}"' . format ( subcommand , s ) )
1455
1455
kwargs [name ] = not kwargs [name ]
1456
1456
1457
- # print(f "short_options {short_options } long_options {long_options}" )
1457
+ # print("short_options {} long_options {}".format(short_options, long_options) )
1458
1458
for a in args :
1459
1459
if done_with_options :
1460
1460
filtered_args .append (a )
@@ -1488,23 +1488,23 @@ def handle_option(s, dict):
1488
1488
# whoops, must be a real type error, reraise
1489
1489
raise e
1490
1490
1491
- how_many = f" { specified } argument"
1491
+ how_many = "{ } argument". format ( specified )
1492
1492
if specified != 1 :
1493
1493
how_many += "s"
1494
1494
1495
1495
if total == 0 :
1496
1496
middle = "accepts no arguments"
1497
1497
else :
1498
1498
if total == required :
1499
- middle = f "requires"
1499
+ middle = "requires"
1500
1500
else :
1501
1501
plural = "" if required == 1 else "s"
1502
- middle = f "requires at least { required } argument{ plural } and at most"
1503
- middle += f " { total } argument"
1502
+ middle = "requires at least {} argument{} and at most" . format ( required , plural )
1503
+ middle += " {} argument" . format ( total )
1504
1504
if total != 1 :
1505
1505
middle += "s"
1506
1506
1507
- print (f 'Error: Wrong number of arguments!\n \n blurb { subcommand } { middle } ,\n and you specified { how_many } .' )
1507
+ print ('Error: Wrong number of arguments!\n \n blurb {} {},\n and you specified {}.' . format ( subcommand , middle , how_many ) )
1508
1508
print ()
1509
1509
print ("usage: " , end = "" )
1510
1510
help (subcommand )
0 commit comments