+from optparse import IndentedHelpFormatter
from optparse import OptionParser
import Configuration.Defaults
-def default_option_parser(usage):
+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',
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