@@ -25,8 +25,8 @@ def __init__(self, fname: str, suggested_summary: str = None):
2525 self .fname = fname
2626 self .description = piptree .sum_up (suggested_summary ) if suggested_summary else ""
2727 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..."
3030 infos = utils .get_source_package_infos (bname ) # get name, version
3131 if infos :
3232 self .name , self .version = utils .normalize (infos [0 ]), infos [1 ]
@@ -40,7 +40,7 @@ def __str__(self):
4040class Distribution :
4141 """Handles operations on a WinPython distribution."""
4242 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
4444 self .verbose = verbose
4545 self .pip = None
4646 self .to_be_removed = []
@@ -265,90 +265,62 @@ def main(test=False):
265265 parser .add_argument (
266266 "--register" ,
267267 dest = "registerWinPython" ,
268- action = "store_const" ,
269- const = True ,
270- default = False ,
268+ action = "store_true" , # Store True when flag is present
271269 help = registerWinPythonHelp ,
272270 )
273271 parser .add_argument (
274272 "--unregister" ,
275273 dest = "unregisterWinPython" ,
276- action = "store_const" ,
277- const = True ,
278- default = False ,
274+ action = "store_true" ,
279275 help = unregisterWinPythonHelp ,
280276 )
281277 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" ,
288280 help = "show more details on packages and actions" ,
289281 )
290282 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" ,
298286 )
299287 parser .add_argument (
300288 "-p" ,
301289 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]" ,
306292 )
307293 parser .add_argument (
308294 "-r" ,
309295 dest = "pipup" ,
310- action = "store_const" ,
311- const = True ,
312- default = False ,
296+ action = "store_true" ,
313297 help = f"show Reverse dependancies of the given package[option]: wppm -r pytest[test]" ,
314298 )
315299 parser .add_argument (
316- "-l" ,
317- dest = "levels" ,
300+ "-l" , "--levels" ,
318301 type = int ,
319302 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" ,
321304 )
322305 parser .add_argument (
323306 "-lsa" ,
324307 dest = "all" ,
325- action = "store_const" ,
326- const = True ,
327- default = False ,
308+ action = "store_true" ,
328309 help = f"list details of package names matching given regular expression: wppm -lsa pandas -l1" ,
329310 )
330311 parser .add_argument (
331- "-t" ,
332- dest = "target" ,
312+ "-t" , "--target" ,
333313 default = sys .prefix ,
334314 help = f'path to target Python distribution (default: "{ sys .prefix } ")' ,
335315 )
336316 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" ,
343319 help = "install a given package wheel (use pip for more features)" ,
344320 )
345321 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
352324 help = "uninstall package (use pip for more features)" ,
353325 )
354326 args = parser .parse_args ()
0 commit comments