]>
gitweb.michael.orlitzky.com - dead/census-tools.git/blob - src/CLI.py
1 from optparse
import IndentedHelpFormatter
2 from optparse
import OptionParser
4 import Configuration
.Defaults
7 def default_option_parser(usage
=None):
8 # Use a VerbatimFormatter instead of the default
9 # IndentedHelpFormatter.
10 fmtr
= VerbatimHelpFormatter()
12 # -h (help) Conflicts with -h HOSTNAME
13 parser
= OptionParser(usage
= usage
,
14 add_help_option
= False,
17 parser
.add_option('-h',
19 help='The hostname/address where the database is located.',
20 default
=Configuration
.Defaults
.DATABASE_HOST
)
22 parser
.add_option('-d',
24 help='The database in which the population data are stored.',
25 default
=Configuration
.Defaults
.DATABASE_NAME
)
27 parser
.add_option('-U',
29 help='The username who has access to the database.',
30 default
=Configuration
.Defaults
.DATABASE_USERNAME
)
36 class VerbatimHelpFormatter(IndentedHelpFormatter
):
38 The two HelpFormatters supplied with OptParse like to mangle their
39 descriptions during print_help(). This subclassed formatter
40 overrides the format_description() method with an implementation
41 that simply returns the description unmodified.
43 def format_description(self
, description
):