Skip to content

Commit 6e6d273

Browse files
committed
re-order help, add column tittle to wppm -ls
1 parent 265fd04 commit 6e6d273

1 file changed

Lines changed: 33 additions & 37 deletions

File tree

winpython/wppm.py

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
1010
Created on Fri Aug 03 14:32:26 2012
1111
"""
12-
# pypy3 to patch from 'python' to 'pypy3': 379 493 497 627 692 696 743 767 785
13-
from __future__ import print_function
1412

1513
import os
1614
from pathlib import Path
@@ -730,13 +728,11 @@ def main(test=False):
730728
bold = "\033[1m"
731729
unbold = "\033[0m"
732730
registerWinPythonHelp = f"""Register distribution
733-
Associate file extensions, icons and context menu entries with this WinPython.
734-
Create a menu group {unbold}WinPython{unbold} for this WinPython launchers.
731+
Associate file extensions, icons and context menu {unbold}WinPython{unbold} with this WinPython.
735732
"""
736733

737734
unregisterWinPythonHelp = f"""Unregister distribution
738-
De-Associate file extensions, icons and context menu entries from this WinPython.
739-
Remove menu group {unbold}WinPython{unbold} .
735+
De-Associate file extensions, icons and context menu {unbold}WinPython{unbold} from this WinPython.
740736
"""
741737

742738
parser = ArgumentParser(
@@ -751,31 +747,7 @@ def main(test=False):
751747
nargs="?",
752748
default="",
753749
type=str,
754-
help="path to a Python package, or package name",
755-
)
756-
parser.add_argument(
757-
"-t",
758-
dest="target",
759-
default=sys.prefix,
760-
help="path to target Python distribution " f'(default: "{sys.prefix}")',
761-
)
762-
parser.add_argument(
763-
"-i",
764-
"--install",
765-
dest="install",
766-
action="store_const",
767-
const=True,
768-
default=False,
769-
help="install a given package wheel (otherwise use pip)",
770-
)
771-
parser.add_argument(
772-
"-u",
773-
"--uninstall",
774-
dest="uninstall",
775-
action="store_const",
776-
const=True,
777-
default=False,
778-
help="uninstall package",
750+
help="optional package name or package wheel",
779751
)
780752
parser.add_argument(
781753
"-r",
@@ -784,7 +756,7 @@ def main(test=False):
784756
action="store_const",
785757
const=True,
786758
default=False,
787-
help="show reverse dependancies of the given package[option]. {unbold}wppm -r pytest[test]{unbold}",
759+
help=f"show reverse dependancies of the given package[option]. {unbold}wppm -r pytest[test]{unbold}",
788760
)
789761
parser.add_argument(
790762
"-p",
@@ -793,14 +765,14 @@ def main(test=False):
793765
action="store_const",
794766
const=True,
795767
default=False,
796-
help="show dependancies of the given package[option]. {unbold}wppm -p pandas[test]{unbold}",
768+
help=f"show dependancies of the given package[option]. {unbold}wppm -p pandas[test]{unbold}",
797769
)
798770
parser.add_argument(
799771
"-l",
800772
dest="levels",
801773
type=int,
802774
default=2,
803-
help="show l levels of depth of hierarchy from given package",
775+
help="show l levels of depth of hierarchy from given package default is 2 levels",
804776
)
805777
parser.add_argument(
806778
"-ls",
@@ -809,7 +781,7 @@ def main(test=False):
809781
action="store_const",
810782
const=True,
811783
default=False,
812-
help="list packages matching the given expression. {unbold}wppm -ls{unbold}",
784+
help=f"list packages matching the given package expression. {unbold}wppm -ls{unbold}",
813785
)
814786
parser.add_argument(
815787
"-lsa",
@@ -845,7 +817,30 @@ def main(test=False):
845817
default=False,
846818
help=unregisterWinPythonHelp,
847819
)
848-
820+
parser.add_argument(
821+
"-t",
822+
dest="target",
823+
default=sys.prefix,
824+
help="path to target Python distribution " f'(default: "{sys.prefix}")',
825+
)
826+
parser.add_argument(
827+
"-i",
828+
"--install",
829+
dest="install",
830+
action="store_const",
831+
const=True,
832+
default=False,
833+
help="install a given package wheel (use pip for more features)",
834+
)
835+
parser.add_argument(
836+
"-u",
837+
"--uninstall",
838+
dest="uninstall",
839+
action="store_const",
840+
const=True,
841+
default=False,
842+
help="uninstall package",
843+
)
849844
args = parser.parse_args()
850845
targetpython = None
851846
if args.target and not args.target==sys.prefix:
@@ -868,7 +863,8 @@ def main(test=False):
868863
elif args.list:
869864
pip = piptree.pipdata(Target=targetpython)
870865
todo = [l for l in pip.pip_list(full=True) if bool(re.search(args.fname, l[0])) ]
871-
listed = utils.formatted_list(todo)
866+
titles = [['Package', 'Version', 'Summary'],['_' * max(x, 6) for x in utils.columns_width(todo)]]
867+
listed = utils.formatted_list(titles + todo)
872868
for p in listed:
873869
print(*p)
874870
sys.exit()

0 commit comments

Comments
 (0)