Esempio n. 1
0
def parse_arguments(arguments):
    """Parse command-line arguments."""
    option_parser = OptionParser()
    options, arguments = option_parser.parse_args(arguments[1:])
    try:
        connect(options.server)
    except ConnectionError, error:
        option_parser.error(error)
Esempio n. 2
0
def parse_arguments(arguments):
    """Parse command line arguments.  Returns the tuple (options,
    arguments)."""
    option_parser = OptionParser()
    option_parser.add_option("-g", "--gender", action="callback",
                             callback=gender_callback, type="str")
    option_parser.add_option("--school")
    options, arguments = option_parser.parse_args(arguments[1:])
    try:
        connect(options.server)
    except ConnectionError, error:
        option_parser.error(error)
Esempio n. 3
0
def parse_arguments(arguments):
    """Parse command line arguments.  Returns the tuple (options, (school,)).
    May raise a ConnectionError."""
    option_parser = OptionParser("%prog SCHOOL")
    option_parser.add_option("-g", "--sort-by-gender", action="store_true",
                             default=False)
    option_parser.add_option("-y", "--year", default=date.today().year,
                             type="int")
    options, arguments = option_parser.parse_args(arguments[1:])
    try:
        connect(options.server)
    except ConnectionError, error:
        option_parser.error(error)
Esempio n. 4
0
def parse_arguments(arguments):
    """Parse command line arguments.  Returns the tuple (options, arguments)."""
    option_parser = OptionParser()
    option_parser.add_option("-y", "--year", default=date.today().year)
    options, arguments = option_parser.parse_args(arguments[1:])
    try:
        connect(options.server)
    except ConnectionError, error:
        option_parser.error(error)
Esempio n. 5
0
def parse_arguments(arguments):
    """Parse command line arguments.  Returns the tuple (options, runners).
    May raise a ConnectionError"""
    option_parser = OptionParser("%prog RUNNER_ID [RUNNER_IDS...]")
    option_parser.add_option("-t", "--sort-times", action="store_true", default=False)
    options, runner_ids = option_parser.parse_args(arguments[1:])
    try:
        connect(options.server)
    except ConnectionError, error:
        option_parser.error(error)
Esempio n. 6
0
def parse_arguments(arguments):
    """Parse the command-line arguments.  Returns the tuple (options,
    arguments)."""
    option_parser = OptionParser()
    option_parser.add_option("--show-venues", action="store_true",
                             default=False, help="Show the venue where each "
                             "race was held.")
    options, arguments = option_parser.parse_args(arguments[1:])
    try:
        connect(options.server)
    except ConnectionError, error:
        option_parser.error(error)
Esempio n. 7
0
def parse_arguments(arguments):
    """Parse command line arguments.  Returns the tuple (options, arguments)."""
    option_parser = OptionParser()
    option_parser.add_option("-p", "--pretty", action="store_true",
                             default=False, help="Print database ID and "
                             "official name.  If not set, the program prints "
                             "out a list of all nicknames as well.")
    options, arguments = option_parser.parse_args(arguments[1:])
    try:
        connect(options.server)
    except ConnectionError, error:
        option_parser.error(error)
Esempio n. 8
0
def parse_arguments(arguments):
    """Parse command line arguments.  Returns the tuple (options, (name,
    date, venue, city, state))."""
    option_parser = OptionParser()
    option_parser.set_usage("%prog [options] RACE_NAME DATE VENUE")
    option_parser.add_option("-c", "--comments", help="Comments on the race, "
                             "such as conditions, intensity of competition, "
                             "etc.")
    option_parser.add_option("-e", "--elevation", type="int")
    option_parser.add_option("-m", "--mens-distance", help="The length of "
                             "the men's race.", type="int")
    option_parser.add_option("-w", "--womens-distance", help="The length of "
                             "the women's race.", type="int")
    options, arguments = option_parser.parse_args(arguments[1:])
    index = count()
    try:
        connect(options.server)
        race_name = arguments[next(index)]
        date = Date.from_string(arguments[next(index)])
        venue = arguments[next(index)]
        venue = Venues.get(venue)
    except ConnectionError, error:
        option_parser.error(error)