Skip to content

Commit

Permalink
Cover the case in which BaseCommand.create_parser retursn optparse.Op…
Browse files Browse the repository at this point in the history
…tionParser.
  • Loading branch information
jezdez committed Feb 13, 2015
1 parent f35e7e5 commit 6ce3740
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion configurations/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,18 @@ def install(check_options=False):

def create_parser(self, prog_name, subcommand):
parser = orig_create_parser(self, prog_name, subcommand)
if not isinstance(parser, OptionParser):
if isinstance(parser, OptionParser):
# in case the option_list is set the create_parser
# will actually return a OptionParser for backward
# compatibility. It uses BaseCommand.use_argparse
# to decide that, which checks for the option_list list
base.BaseCommand.option_list += configuration_options
else:
# probably argparse, let's not import argparse though
parser.add_argument(CONFIGURATION_ARGUMENT,
help=CONFIGURATION_ARGUMENT_HELP)
return parser

base.BaseCommand.create_parser = create_parser
else:
# add the configuration option to all management commands
Expand Down

0 comments on commit 6ce3740

Please sign in to comment.