@@ -126,20 +126,15 @@ def __init__(self, fname):
126
126
self .url = None
127
127
128
128
def __str__ (self ):
129
- text = "%s %s" % ( self .name , self .version )
129
+ text = f" { self .name } { self .version } "
130
130
pytext = ""
131
131
if self .pyversion is not None :
132
- pytext = " for Python %s" % self .pyversion
132
+ pytext = f " for Python { self .pyversion } "
133
133
if self .architecture is not None :
134
134
if not pytext :
135
135
pytext = " for Python"
136
- pytext += " %dbits" % self .architecture
137
- text += "%s\n %s\n Website: %s\n [%s]" % (
138
- pytext ,
139
- self .description ,
140
- self .url ,
141
- Path (self .fname ).name ,
142
- )
136
+ pytext += f" { self .architecture } bits"
137
+ text += f"{ pytext } \n { self .description } \n Website: { self .url } \n [{ Path (self .fname ).name } ]"
143
138
return text
144
139
145
140
def is_compatible_with (self , distribution ):
@@ -205,7 +200,7 @@ def extract_infos(self):
205
200
self .name , self .version = infos
206
201
return
207
202
raise NotImplementedError (
208
- "Not supported package type %s" % bname
203
+ f "Not supported package type { bname } "
209
204
)
210
205
211
206
@@ -227,7 +222,7 @@ def extract_infos(self):
227
222
if match is None :
228
223
return
229
224
self .name = match .groups ()[0 ]
230
- self .logname = '%s -wininst.log' % self . name
225
+ self .logname = f' { self . name } -wininst.log'
231
226
fd = open (
232
227
str (Path (self .distribution .target ) / self .logname ),
233
228
'U' ,
@@ -285,8 +280,7 @@ def clean_up(self):
285
280
shutil .rmtree (path , onerror = utils .onerror )
286
281
except WindowsError :
287
282
print (
288
- "Directory %s could not be removed"
289
- % path ,
283
+ f"Directory { path } could not be removed" ,
290
284
file = sys .stderr ,
291
285
)
292
286
@@ -316,7 +310,7 @@ def copy_files(
316
310
src = str (Path (srcdir ) / t_dname )
317
311
dst = str (Path (dstdir ) / t_dname )
318
312
if self .verbose :
319
- print ("mkdir: %s" % dst )
313
+ print (f "mkdir: { dst } " )
320
314
full_dst = str (Path (self .target ) / dst )
321
315
if not Path (full_dst ).exists ():
322
316
os .mkdir (full_dst )
@@ -330,15 +324,15 @@ def copy_files(
330
324
else :
331
325
dst = str (Path (dstdir ) / t_fname )
332
326
if self .verbose :
333
- print ("file: %s" % dst )
327
+ print (f "file: { dst } " )
334
328
full_dst = str (Path (self .target ) / dst )
335
329
shutil .move (src , full_dst )
336
330
package .files .append (dst )
337
331
name , ext = Path (dst ).stem , Path (dst ).suffix
338
332
if create_bat_files and ext in ('' , '.py' ):
339
333
dst = name + '.bat'
340
334
if self .verbose :
341
- print ("file: %s" % dst )
335
+ print (f "file: { dst } " )
342
336
full_dst = str (Path (self .target ) / dst )
343
337
fd = open (full_dst , 'w' )
344
338
fd .write (
@@ -354,7 +348,7 @@ def create_file(self, package, name, dstdir, contents):
354
348
"""Generate data file -- path is relative to distribution root dir"""
355
349
dst = str (Path (dstdir ) / name )
356
350
if self .verbose :
357
- print ("create: %s" % dst )
351
+ print (f "create: { dst } " )
358
352
full_dst = str (Path (self .target ) / dst )
359
353
open (full_dst , 'w' ).write (contents )
360
354
package .files .append (dst )
@@ -386,8 +380,7 @@ def get_installed_packages(self, update=False):
386
380
# create pip package list
387
381
wppm = [
388
382
Package (
389
- '%s-%s-py2.py3-none-any.whl'
390
- % (i [0 ].replace ('-' , '_' ).lower (), i [1 ])
383
+ f"{ i [0 ].replace ('-' , '_' ).lower ()} -{ i [1 ]} -py2.py3-none-any.whl"
391
384
, update = update )
392
385
for i in pip_list
393
386
]
@@ -671,7 +664,7 @@ def handle_specific_packages(self, package):
671
664
'.' ,
672
665
contents .replace (
673
666
'.' ,
674
- './Lib/site-packages/%s' % package .name ,
667
+ f './Lib/site-packages/{ package .name } ' ,
675
668
),
676
669
)
677
670
# pyuic script
@@ -691,7 +684,7 @@ def handle_specific_packages(self, package):
691
684
692
685
self .create_file (
693
686
package ,
694
- 'pyuic%s.bat' % package .name [- 1 ],
687
+ f 'pyuic{ package .name [- 1 ]} .bat' ,
695
688
'Scripts' ,
696
689
tmp_string .replace (
697
690
'package.name' , package .name
@@ -754,7 +747,7 @@ def install_bdist_direct(
754
747
"""Install a package directly !"""
755
748
self ._print (
756
749
package ,
757
- "Installing %s" % package .fname .split ("." )[- 1 ],
750
+ f "Installing { package .fname .split ('.' )[- 1 ]} " ,
758
751
)
759
752
try :
760
753
fname = utils .direct_pip_install (
@@ -861,7 +854,7 @@ def main(test=False):
861
854
dest = 'target' ,
862
855
default = sys .prefix ,
863
856
help = 'path to target Python distribution '
864
- '(default: "%s")' % sys .prefix ,
857
+ f '(default: "{ sys .prefix } ")' ,
865
858
)
866
859
parser .add_argument (
867
860
'-i' ,
@@ -948,7 +941,7 @@ def main(test=False):
948
941
if utils .is_python_distribution (args .target ):
949
942
dist = Distribution (args .target )
950
943
else :
951
- raise WindowsError ("Invalid Python distribution {args.target}" )
944
+ raise WindowsError (f "Invalid Python distribution { args .target } " )
952
945
print (f'registering { args .target } ' )
953
946
print ('continue ? Y/N' )
954
947
theAnswer = input ()
@@ -961,7 +954,7 @@ def main(test=False):
961
954
if utils .is_python_distribution (args .target ):
962
955
dist = Distribution (args .target )
963
956
else :
964
- raise WindowsError ("Invalid Python distribution {args.target}" )
957
+ raise WindowsError (f "Invalid Python distribution { args .target } " )
965
958
print (f'unregistering { args .target } ' )
966
959
print ('continue ? Y/N' )
967
960
theAnswer = input ()
@@ -976,7 +969,7 @@ def main(test=False):
976
969
parser .print_help ()
977
970
sys .exit ()
978
971
else :
979
- raise IOError ("File not found: %s" % args .fname )
972
+ raise IOError (f "File not found: { args .fname } " )
980
973
if utils .is_python_distribution (args .target ):
981
974
dist = Distribution (args .target )
982
975
try :
@@ -993,20 +986,15 @@ def main(test=False):
993
986
else :
994
987
raise RuntimeError (
995
988
"Package is not compatible with Python "
996
- "%s %dbit"
997
- % (
998
- dist .version ,
999
- dist .architecture ,
1000
- )
989
+ f"{ dist .version } { dist .architecture } bit"
1001
990
)
1002
991
except NotImplementedError :
1003
992
raise RuntimeError (
1004
993
"Package is not (yet) supported by WPPM"
1005
994
)
1006
995
else :
1007
996
raise WindowsError (
1008
- "Invalid Python distribution %s"
1009
- % args .target
997
+ f"Invalid Python distribution { args .target } "
1010
998
)
1011
999
1012
1000
0 commit comments