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)
def main(options, arguments): venues = ivenues(Venues.select()) for row in formatting.Table(venues, column_seperator=" | "): print row