Esempio n. 1
0
def load_puzzles():
    """Loads in the JSON files listed in the global PUZZLE_PATHS variable to Puzzle models
    :return: A list of Puzzle objects
    """
    puzzles = []
    for path in PUZZLE_PATHS:
        with open(path, 'r') as f:
            puzzle_dict = json.load(f)
            new_puzzle = Puzzle()
            new_puzzle.input_anagrams = puzzle_dict['input_anagrams']
            new_puzzle.sentence_indices = puzzle_dict['sentence_indices']
            new_puzzle.sentence_word_lengths = puzzle_dict[
                'sentence_word_lengths']
            puzzles.append(new_puzzle)
    return puzzles