Exemple #1
0
def set_up_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
    event_file_list = fh.get_training_file_paths()
    #print event_file_list
    # for each training file path
    for event_file_path in event_file_list:
        #print event_file_path
        # open the file and read into a list
        event_list = fh.file_to_list(event_file_path)
#        print 'event_list : ' + str(event_list)
#        print
        game_event_string_list = ut.format_file_list_to_game_string(event_list)
        for game_event_string in game_event_string_list:
            temp_dict_name, temp_dict = convert_str_to_dict(game_event_string, event_file_path)
            all_games_dict[temp_dict_name] = temp_dict
#    for dict_name in all_games_dict.keys():
#        print dict_name
    return all_games_dict
Exemple #2
0
def test_get_excludes():
    DATA_DIR = 'test_data_files'
    fh.set_up_paths(DATA_DIR)
    expected = ['Monday','Tuesday','Wednesday','Thursday','Friday', 'Saturday','Sunday','.','Milford','Doubles', 'Singles', 'Dania', 'All']
    res = get_excludes()
    assert_equal(expected, res)