for c in permute(candidate): if c in already: continue yield c already.add(c) def generate_all_sentence_candidates(dictionary_file): already = set() for line in open(dictionary_file): line = line.strip() candidates = permute(line) for c in candidates: if c in already: continue yield c already.add(c) def try_all(dictionary_file): #for c in generate_all_sentence_candidates(dictionary_file): for c in generate_all_candidates_of_length(dictionary_file): print '> ', c if try_candidate(c): return c return '' try_all(DICTIONARY_FILE) truecrypt.dismount() os.rmdir(MOUNT_PT)
def tearDown(self): truecrypt.dismount() os.rmdir(test_mount)