def main(args=None): args = parse_args(args) if args.tournament_state: with open(args.tournament_state) as state_file: tourn = parse_tournament(state_file.read()) else: with open(args.seed_file) as seed_file: tourn = parse_seeds(seed_file.read()) if args.history_file: with open(args.history_file) as history_file: parse_history(tourn, history_file.read()) if args.prelives > 0: filter_players(tourn, args.prelives) pairings, bye = get_pairings(tourn, args) if args.ranks: players = sorted(tourn.players, key=lambda p: tourn.ranks[p]) for p in players: print "#", tourn.ranks[p], p, tourn.player_order[p] pairings, arbitrary = assign_colors(tourn, pairings) pairings.sort(key=lambda pr: min(tourn.ranks[pr[0]], tourn.ranks[pr[1]])) if bye: print "bye", bye for p1, p2 in pairings: if args.show_arbitrary: print "game", p1, p2, "# A" if (p1, p2) in arbitrary else "" else: print "game", p1, p2
def main(args=None): args = parse_args(args) if args.tournament_state: with open(args.tournament_state) as state_file: tourn = parse_tournament(state_file.read()) else: with open(args.seed_file) as seed_file: tourn = parse_seeds(seed_file.read()) if args.history_file: with open(args.history_file) as history_file: parse_history(tourn, history_file.read()) if args.prelives > 0: filter_players(tourn, args.prelives) pairings, bye = get_pairings(tourn, args.virtual) if args.ranks: players = sorted(tourn.players, key=lambda p: tourn.ranks[p]) for p in players: print "#", tourn.ranks[p], p, tourn.player_order[p] pairings, arbitrary = assign_colors(tourn, pairings) if bye: print "bye", bye for p1, p2 in pairings: if args.show_arbitrary: print "game", p1, p2, "A" if (p1, p2) in arbitrary else "" else: print "game", p1, p2
def main(args=None): args = parse_args(args) if args.tournament_state: with open(args.tournament_state) as state_file: tourn = parse_tournament(state_file.read()) else: with open(args.seed_file) as seed_file: seed_data = seed_file.read() tourn = parse_seeds(seed_data) if args.game_file: with open(args.game_file) as history_file: history_data = history_file.read() parse_history(tourn, history_data) if not args.all_games: tourn = filter_games(tourn, args.lives) pairings, bye = get_pairings(tourn, args) if len(pairings) == 0: # tournament is finished, print final ranks print_final_ranking(tourn, args.virtual, args.utpr) if args.ranks: players = sorted(tourn.ranks, key=lambda p: tourn.ranks[p]) for p in players: print "#", tourn.ranks[p], p, tourn.player_order[p][0], for r in tourn.player_order[p][1:]: print -r, print pairings, arbitrary = assign_colors(tourn, pairings) pairings.sort(key=lambda pr: min(tourn.ranks[pr[0]], tourn.ranks[pr[1]])) if bye: print "bye", bye for p1, p2 in pairings: if args.show_arbitrary: print "game", p1, p2, "# A" if (p1, p2) in arbitrary else "" else: print "game", p1, p2
def test_parse_history(self): def test_tourn(): tourn = pair.Tournament() tourn.players = history_players return tourn tourn = test_tourn() pair.parse_history(tourn, history_good) self.assertEqual(tourn.events, history_good_eventlist) self.assertEqual(tourn.games, history_good_games) with self.assertRaises(ValueError): pair.parse_history(test_tourn(), history_removed_player) with self.assertRaises(ValueError): pair.parse_history(test_tourn(), history_bad_winner)