@@ -25,8 +25,8 @@ def __init__(self, fname: str, suggested_summary: str = None):
25
25
self .fname = fname
26
26
self .description = piptree .sum_up (suggested_summary ) if suggested_summary else ""
27
27
self .name , self .version = None , None
28
- if fname .endswith ((".zip" , ".tar.gz" , ".whl" )):
29
- bname = Path (self .fname ).name #wheel style name like "sqlite_bro-1.0.0..."
28
+ if fname .lower (). endswith ((".zip" , ".tar.gz" , ".whl" )):
29
+ bname = Path (self .fname ).name # e.g., "sqlite_bro-1.0.0..."
30
30
infos = utils .get_source_package_infos (bname ) # get name, version
31
31
if infos :
32
32
self .name , self .version = utils .normalize (infos [0 ]), infos [1 ]
@@ -40,7 +40,7 @@ def __str__(self):
40
40
class Distribution :
41
41
"""Handles operations on a WinPython distribution."""
42
42
def __init__ (self , target : str = None , verbose : bool = False ):
43
- self .target = target or os . path . dirname ( sys .executable ) # Default target more explicit
43
+ self .target = target or str ( Path ( sys .executable ). parent ) # Default target more explicit
44
44
self .verbose = verbose
45
45
self .pip = None
46
46
self .to_be_removed = []
@@ -265,90 +265,62 @@ def main(test=False):
265
265
parser .add_argument (
266
266
"--register" ,
267
267
dest = "registerWinPython" ,
268
- action = "store_const" ,
269
- const = True ,
270
- default = False ,
268
+ action = "store_true" , # Store True when flag is present
271
269
help = registerWinPythonHelp ,
272
270
)
273
271
parser .add_argument (
274
272
"--unregister" ,
275
273
dest = "unregisterWinPython" ,
276
- action = "store_const" ,
277
- const = True ,
278
- default = False ,
274
+ action = "store_true" ,
279
275
help = unregisterWinPythonHelp ,
280
276
)
281
277
parser .add_argument (
282
- "-v" ,
283
- "--verbose" ,
284
- dest = "verbose" ,
285
- action = "store_const" ,
286
- const = True ,
287
- default = False ,
278
+ "-v" , "--verbose" ,
279
+ action = "store_true" ,
288
280
help = "show more details on packages and actions" ,
289
281
)
290
282
parser .add_argument (
291
- "-ls" ,
292
- "--list" ,
293
- dest = "list" ,
294
- action = "store_const" ,
295
- const = True ,
296
- default = False ,
297
- help = f"list packages matching the given [optionnal] package expression: wppm -ls, wppm -ls pand" ,
283
+ "-ls" , "--list" ,
284
+ action = "store_true" ,
285
+ help = "list installed packages matching the given [optional] package expression: wppm -ls, wppm -ls pand" ,
298
286
)
299
287
parser .add_argument (
300
288
"-p" ,
301
289
dest = "pipdown" ,
302
- action = "store_const" ,
303
- const = True ,
304
- default = False ,
305
- help = f"show Package dependancies of the given package[option]: wppm -p pandas[test]" ,
290
+ action = "store_true" ,
291
+ help = "show Package dependencies of the given package[option]: wppm -p pandas[test]" ,
306
292
)
307
293
parser .add_argument (
308
294
"-r" ,
309
295
dest = "pipup" ,
310
- action = "store_const" ,
311
- const = True ,
312
- default = False ,
296
+ action = "store_true" ,
313
297
help = f"show Reverse dependancies of the given package[option]: wppm -r pytest[test]" ,
314
298
)
315
299
parser .add_argument (
316
- "-l" ,
317
- dest = "levels" ,
300
+ "-l" , "--levels" ,
318
301
type = int ,
319
302
default = 2 ,
320
- help = f "show 'LEVELS' levels of dependancies of the package , default is 2: wppm -p pandas -l1" ,
303
+ help = "show 'LEVELS' levels of dependencies (with -p, -r) , default is 2: wppm -p pandas -l1" ,
321
304
)
322
305
parser .add_argument (
323
306
"-lsa" ,
324
307
dest = "all" ,
325
- action = "store_const" ,
326
- const = True ,
327
- default = False ,
308
+ action = "store_true" ,
328
309
help = f"list details of package names matching given regular expression: wppm -lsa pandas -l1" ,
329
310
)
330
311
parser .add_argument (
331
- "-t" ,
332
- dest = "target" ,
312
+ "-t" , "--target" ,
333
313
default = sys .prefix ,
334
314
help = f'path to target Python distribution (default: "{ sys .prefix } ")' ,
335
315
)
336
316
parser .add_argument (
337
- "-i" ,
338
- "--install" ,
339
- dest = "install" ,
340
- action = "store_const" ,
341
- const = True ,
342
- default = False ,
317
+ "-i" , "--install" ,
318
+ action = "store_true" ,
343
319
help = "install a given package wheel (use pip for more features)" ,
344
320
)
345
321
parser .add_argument (
346
- "-u" ,
347
- "--uninstall" ,
348
- dest = "uninstall" ,
349
- action = "store_const" ,
350
- const = True ,
351
- default = False ,
322
+ "-u" , "--uninstall" ,
323
+ action = "store_true" , # Store True when flag is present
352
324
help = "uninstall package (use pip for more features)" ,
353
325
)
354
326
args = parser .parse_args ()
0 commit comments