Пример #1
0
def parse_arguments(arguments):
    "Parse command line arguments.  Returns the tuple (options, (gender,))."
    option_parser = race_display_options(GenderedOptionParser())
    option_parser.add_option("-c", "--conference", help="Include schools from "
                             "only the specified conference.")
    option_parser.add_option("-d", "--dist-limit", help="Minimum race "
                             "distance.", type="int")
    option_parser.add_option("-f", "--filter", help="Include or exclude the "
                             "specified schools.")
    option_parser.add_option("-p", "--previous-years", default=0, type="int")
    option_parser.add_option("-y", "--year", default=date.today().year,
                             type="int")
    options, arguments = option_parser.parse_args(arguments[1:])
    index = count()
    try:
        connect(options.server)
        gender = arguments[next(index)]
    except IndexError:
        option_parser.error("")
    except ConnectionError, error:
        option_parser.error(error)