10
10
11
11
12
12
class PipPrettyHelpFormatter (optparse .IndentedHelpFormatter ):
13
- """ A prettier/less verbose help formatter for optparse """
13
+ """A prettier/less verbose help formatter for optparse. """
14
14
15
15
def __init__ (self , * args , ** kw ):
16
16
kw ['max_help_position' ] = 23
@@ -19,23 +19,27 @@ def __init__(self, *args, **kw):
19
19
# do as argparse does
20
20
try :
21
21
kw ['width' ] = int (os .environ ['COLUMNS' ]) - 2
22
- #except (KeyError, ValueError):
23
22
except :
24
23
kw ['width' ] = 78
25
24
26
25
optparse .IndentedHelpFormatter .__init__ (self , * args , ** kw )
27
26
28
27
def format_option_strings (self , option ):
29
- #return self._format_option_strings(option, ' %s', ' ')
30
28
return self ._format_option_strings (option , ' <%s>' , ', ' )
31
29
32
30
def _format_option_strings (self , option , mvarfmt = ' <%s>' , optsep = ', ' ):
33
- """ ('-f', '--format') -> -f%(optsep)s--format mvarfmt % metavar"""
31
+ """
32
+ Return a comma-separated list of option strings and metavars.
33
+
34
+ :param option: tuple of (short opt, long opt), e.g: ('-f', '--format')
35
+ :param mvarfmt: metavar format string - evaluated as mvarfmt % metavar
36
+ :param optsep: separator
37
+ """
34
38
35
39
opts = []
36
40
37
41
if option ._short_opts : opts .append (option ._short_opts [0 ])
38
- if option ._long_opts : opts .append (option ._long_opts [0 ])
42
+ if option ._long_opts : opts .append (option ._long_opts [0 ])
39
43
if len (opts ) > 1 : opts .insert (1 , optsep )
40
44
41
45
if option .takes_value ():
@@ -58,15 +62,15 @@ def format_usage(self, usage):
58
62
59
63
return msg
60
64
61
- # leave full control over description to us
62
65
def format_description (self , description ):
66
+ # leave full control over description to us
63
67
if description :
64
68
return description
65
69
else :
66
70
return ''
67
71
68
- # leave full control over epilog to us
69
72
def format_epilog (self , epilog ):
73
+ # leave full control over epilog to us
70
74
if epilog :
71
75
return epilog
72
76
else :
0 commit comments