X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FCLI.py;h=93ac2a058ab1fb39998043e76b1a6ff64538f6ad;hb=3a1235a834118bb52c5d92fce9c7182c04a44e0b;hp=b7fcaaff8e49fe8fb377fcdaed8c9cc61caf2938;hpb=d67b2e640133c45a31813ec853e58a866553134a;p=dead%2Fcensus-tools.git diff --git a/src/CLI.py b/src/CLI.py index b7fcaaf..93ac2a0 100644 --- a/src/CLI.py +++ b/src/CLI.py @@ -1,11 +1,18 @@ +from optparse import IndentedHelpFormatter from optparse import OptionParser import Configuration.Defaults def default_option_parser(usage=None): + # Use a VerbatimFormatter instead of the default + # IndentedHelpFormatter. + fmtr = VerbatimHelpFormatter() + # -h (help) Conflicts with -h HOSTNAME - parser = OptionParser(usage=usage, add_help_option = False) + parser = OptionParser(usage = usage, + add_help_option = False, + formatter = fmtr) parser.add_option('-h', '--host', @@ -23,3 +30,15 @@ def default_option_parser(usage=None): default=Configuration.Defaults.DATABASE_USERNAME) return parser + + + +class VerbatimHelpFormatter(IndentedHelpFormatter): + """ + The two HelpFormatters supplied with OptParse like to mangle their + descriptions during print_help(). This subclassed formatter + overrides the format_description() method with an implementation + that simply returns the description unmodified. + """ + def format_description(self, description): + return description