def set_up_res_games_dicts(DATA_DIR, sch_games_dicts):
    """
    
    """
    fin_all_results_games_dict = {}
    all_results_games_dict = {}
    fh.set_up_paths(DATA_DIR)
    # Get a list of paths to training files
    results_file_list = fh.get_results_file_paths()
    #print scheduled_file_list
    # for each training file path
    for results_file_path in results_file_list:
#        #print event_file_path
#        # open the file and read into a list
        results_list = fh.file_to_list(results_file_path)
        #print 'schedule_list : ' + str(schedule_list)
##        print
        game_event_string_list = ut.format_file_list_to_game_string(results_list)
        #print game_event_string_list
        for game_event_string in game_event_string_list:
            temp_dict_name, temp_dict = dp.convert_str_to_dict(game_event_string, results_file_path)
            all_results_games_dict[temp_dict_name] = temp_dict
    #print all_games_dict
#    for dict_name,v in all_results_games_dict.items():
#        print dict_name,v
    # ENSURE THAT ANY RESULTS FILES DO RELATE TO A SCHEDULE FILE
    for dict_name, dict_data in sch_games_dicts.items():
        test_name = dict_name.replace("sch", "res")
        if all_results_games_dict.get(test_name) != None:
            fin_all_results_games_dict[test_name] = all_results_games_dict[test_name]
    
#    for dict_name,v in fin_all_results_games_dict.items():
#        print dict_name,v        
        
    return fin_all_results_games_dict
def set_up_sch_game_dicts(DATA_DIR):
    """
    Returns a dictionary of game dictionaries
    The dictionary keys look like: 'ma-01-01-1998_sch_Milford_1'
    The dict of dicts looks like:
    all_games_dict = {'ma-01-01-1998_sch_Milford_1':{'POS-1': ['Ara'], 'POS-2': ['Douglas'], 'POS-3': ['Liam'], 'POS-4': ['Tino'], 'S/D': 'Doubles', 'POS-6': ['Aitor'], 'POS-7': ['Zarandona'], 'POS-8': ['Eggy'], 'GAME': 1, 'DATE': '01/01/1998', 'POS-5': ['Aja'], 'POS-6-ID': [52], 'POS-SUB': ['Altuna'], 'POINTS': 7, 'DAY': 'Thursday', 'GAME-COUNT': 15, 'POS-4-ID': [17], 'POS-8-ID':[2], 'POS-SUB-ID':[15], 'POS-3-ID': [9], 'POS-7-ID': [38], 'FRONTON': 'Milford', 'POS-5-ID': [13], 'ABSOLUTE-DATE': 35795, 'POS-2-ID': [42], 'POS-1-ID':[4]},'ma-01-01-1998_res_Milford_2':{'POS-1': ['Ara'], 'POS-2': ['Douglas'], 'POS-3': ['Liam'], 'POS-4': ['Tino'], 'S/D': 'Doubles', 'POS-6': ['Aitor'], 'POS-7': ['Zarandona'], 'POS-8': ['Eggy'], 'GAME': 1, 'DATE': '01/01/1998', 'POS-5': ['Aja'], 'POS-6-ID': [52], 'POS-SUB': ['Altuna'], 'POINTS': 7, 'DAY': 'Thursday', 'GAME-COUNT': 15, 'POS-4-ID': [17], 'POS-8-ID':[2], 'POS-SUB-ID':[15], 'POS-3-ID': [9], 'POS-7-ID': [38], 'FRONTON': 'Milford', 'POS-5-ID': [13], 'ABSOLUTE-DATE': 35795, 'POS-2-ID': [42], 'POS-1-ID':[4]}}
    """
    all_games_dict = {}
    fh.set_up_paths(DATA_DIR)
    # Get a list of paths to training files
    scheduled_file_list = fh.get_scheduled_file_paths()
    #print scheduled_file_list
    # for each training file path
    for scheduled_file_path in scheduled_file_list:
#        #print event_file_path
#        # open the file and read into a list
        schedule_list = fh.file_to_list(scheduled_file_path)
        #print 'schedule_list : ' + str(schedule_list)
##        print
        game_event_string_list = ut.format_file_list_to_game_string(schedule_list)
        #print game_event_string_list
        for game_event_string in game_event_string_list:
            temp_dict_name, temp_dict = dp.convert_str_to_dict(game_event_string, scheduled_file_path)
            all_games_dict[temp_dict_name] = temp_dict
    #print all_games_dict
    #for dict_name in all_games_dict.keys():
        #print dict_name
    ####### REMOVE GAMES WITH KNOWN SUBSTITUTIONS

        #if get_player_game_result(gamedict_res, player)
            
            
    ############ -------------#############        
    return all_games_dict
def get_roster_list():
    """
    Tested
    Accepts a top level data directory
    If the roster list does not exist for the top level data directory
    it is created, otherwise it is just returned from a file location
    Returns a list of lists with each player, and 2 player team in a list :
    [['player1'],['player2','player3'], ....]    
    """
    fh.set_up_paths(DATA_DIR)
    roster_list = []
    temp_list = []
    fin_list = []
    if fh.file_exists(fh.roster_list_file):
        roster_list = fh.file_to_list(fh.roster_list_file)
        for l in roster_list:
            #print l
            temp_list.append(l)
        for ll in temp_list:
#            print 'll : '+ str(ll),
#            print ll.split(':')
            roster_list.append(ll.split(':'))
        ret_roster_list = dp.get_names_from_list(roster_list)
        for name in ret_roster_list:
            if name not in roster_list:
                fin_list.append(name)
    else:
        fin_list = create_roster_list()
        fh.write_list_of_lists_file(fin_list, fh.roster_list_file)
#    print fin_list
    return fin_list