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
def create_roster_list(): """ Tested Creates a roster list from scratch A roster list looks like: [['Ara'], ['Douglas', 'Ara'], ['Liam'],['Tino'],['Aitor'],['Zarandona'], ['Eggy'], ['Aja'], ['Altuna']] The items within the list are alpha sorted, and the roster list is sorted after any inserts or updates. This is to [prvent a duplicate item being entered into the list """ all_game_dicts = {} roster_list = [] test_list = [] all_game_dicts = dp.set_up_game_dicts(DATA_DIR) for game_dict in all_game_dicts.values(): #print game_dict for val in game_dict.values(): test_list.append(val) #print test_list name_list = dp.get_names_from_list(test_list) for name in name_list: if name not in roster_list: roster_list.append(name) return roster_list