]> scripts.mit.edu Git - wizard.git/blob - wizard/command/summary/__init__.py
Refactor get*() to .() with property decorator.
[wizard.git] / wizard / command / summary / __init__.py
1 import optparse
2 import os
3
4 from wizard.command import _command
5
6 # submodules
7 import list
8 import list_errors
9 import version
10 import count_exists
11
12 def main(argv, baton):
13     usage = """usage: %prog summary [ARGS] APPS
14
15 Scans all of the collected data from parallel-find.pl, and
16 calculates interesting information about them.
17
18 Its subcommands are:
19     count-exists    Counts how many autoinstalls contain a file
20     list            Prints the locations of all autoinstalls
21     list-errors     Prints all errors that occurred during parsing
22     version         Breakdown of autoinstalls by version (default)
23
24 Use %prog summary SUBCOMMAND --help for more information."""
25     parser = _command.WizardOptionParser(usage)
26     parser.disable_interspersed_args()
27     baton.push(parser, "versions_path")
28     _, args = parser.parse_all(argv)
29     rest_argv = args[1:]
30     try:
31         command = args[0]
32     except IndexError:
33         command = "version"
34     def get_command(name):
35         return globals()[name.replace("-", "_")]
36     if command == "help":
37         try:
38             get_command(rest_argv[0]).main(['--help'], baton)
39         except KeyError:
40             parser.error("invalid action")
41         except IndexError:
42             parser.print_help()
43             raise SystemExit(1)
44     try:
45         command_module = get_command(command)
46     except KeyError:
47         parser.error("invalid action")
48     command_module.main(rest_argv, baton)
49