diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/main.py | 15 | ||||
-rw-r--r-- | lib/spack/spack/test/cmd/flake8.py | 1 |
2 files changed, 8 insertions, 8 deletions
diff --git a/lib/spack/spack/main.py b/lib/spack/spack/main.py index 39c64b3ce0..543d871f42 100644 --- a/lib/spack/spack/main.py +++ b/lib/spack/spack/main.py @@ -32,8 +32,8 @@ from __future__ import print_function import sys import os import inspect -from argparse import _ArgumentGroup, ArgumentParser, RawTextHelpFormatter import pstats +import argparse import llnl.util.tty as tty from llnl.util.tty.color import * @@ -126,7 +126,7 @@ def index_commands(): return index -class SpackArgumentParser(ArgumentParser): +class SpackArgumentParser(argparse.ArgumentParser): def format_help_sections(self, level): """Format help on sections for a particular verbosity level. @@ -165,7 +165,7 @@ class SpackArgumentParser(ArgumentParser): if action.metavar in cmd_set) # add commands to a group in order, and add the group - group = _ArgumentGroup(self, title=title) + group = argparse._ArgumentGroup(self, title=title) for name in commands: group._add_action(cmds[name]) if name in remaining: @@ -265,7 +265,7 @@ class SpackArgumentParser(ArgumentParser): def make_argument_parser(): """Create an basic argument parser without any subcommands added.""" parser = SpackArgumentParser( - formatter_class=RawTextHelpFormatter, add_help=False, + formatter_class=argparse.RawTextHelpFormatter, add_help=False, description=( "A flexible package manager that supports multiple versions,\n" "configurations, platforms, and compilers.")) @@ -410,8 +410,7 @@ def main(argv=None): # avoid loading all the modules from spack.cmd when we don't need # them, which reduces startup latency. parser = make_argument_parser() - parser.add_argument( - 'command', metavar='COMMAND', nargs='?', action='store') + parser.add_argument('command', nargs=argparse.REMAINDER) args, unknown = parser.parse_known_args(argv) # Just print help and exit if run with no arguments at all @@ -432,13 +431,13 @@ def main(argv=None): # Try to load the particular command the caller asked for. If there # is no module for it, just die. - command_name = args.command.replace('-', '_') + command_name = args.command[0].replace('-', '_') try: parser.add_command(command_name) except ImportError: if spack.debug: raise - tty.die("Unknown command: %s" % args.command) + tty.die("Unknown command: %s" % args.command[0]) # Re-parse with the proper sub-parser added. args, unknown = parser.parse_known_args() diff --git a/lib/spack/spack/test/cmd/flake8.py b/lib/spack/spack/test/cmd/flake8.py index 438791c988..3fad486333 100644 --- a/lib/spack/spack/test/cmd/flake8.py +++ b/lib/spack/spack/test/cmd/flake8.py @@ -81,6 +81,7 @@ def test_changed_files(parser, flake8_package): sys.version_info[:2] <= (2, 6) or (3, 0) <= sys.version_info[:2] <= (3, 3), reason='flake8 no longer supports Python 2.6 or 3.3 and older') +@pytest.mark.skipif(not which('flake8'), reason='flake8 is not installed.') def test_flake8(parser, flake8_package): # Only test the flake8_package that we modified # Otherwise, the unit tests would fail every time |