def show_deciphered_text(translate): """ Displays the translated text for debugging :param translate: """ divider = "\n%s\n" % ("=" * 60) text = read_ciphered_text() deciphered_text = translate(text) logger.debug("%s\tDeciphered text%s" % (divider, divider)) logger.debug("\n\n%s%s" % (deciphered_text, divider))
def get_input_data(): """ :return: dictionary that has the cypher text and some items calculated from it that are needed various places """ ciphered_text = read_ciphered_text() ciphered_words = [process_word(word) for word in ciphered_text.split()] input_data = {'ciphered_text': ciphered_text, 'ciphered_words': ciphered_words} return input_data
def get_input_data(): """ :return: dictionary that has the cypher text and some items calculated from it that are needed various places """ ciphered_text = read_ciphered_text() ciphered_words = [process_word(word) for word in ciphered_text.split()] input_data = { 'ciphered_text': ciphered_text, 'ciphered_words': ciphered_words } return input_data
logger.info('Final solution\n-------------------\n') true_translation = true_translation_dictionary() for k, v in translate.items(): if k in input_data['ciphered_text']: logger.info("%s, %s, %s" % (k, v, (v == true_translation[k]))) logger.debug("Finished decipher") return translate if __name__ == "__main__": start = time.time() translate_solution = decipher_file() true_translation = true_translation_dictionary() ciphered_text = fileio.read_ciphered_text() success = True for letter in alphabet: if letter in ciphered_text: result = translate_solution(letter) expected = true_translation[letter] if result != expected: print "Incorrect: letter=%s, expected=%s, result=%s" \ % (letter, expected, result) success = False assert success fileio.write_solution(translate_solution) finish = time.time() runtime = finish - start logger.info("Success") logger.info("runtime: %0.1f seconds" % runtime)
solve.modify_each_letter(translate, input_data, word_data) logger.info('Final solution\n-------------------\n') true_translation = true_translation_dictionary() for k, v in translate.items(): if k in input_data['ciphered_text']: logger.info("%s, %s, %s" % (k, v, (v == true_translation[k]))) logger.debug("Finished decipher") return translate if __name__ == "__main__": start = time.time() translate_solution = decipher_file() true_translation = true_translation_dictionary() ciphered_text = fileio.read_ciphered_text() success = True for letter in alphabet: if letter in ciphered_text: result = translate_solution(letter) expected = true_translation[letter] if result != expected: print "Incorrect: letter=%s, expected=%s, result=%s" \ % (letter, expected, result) success = False assert success fileio.write_solution(translate_solution) finish = time.time() runtime = finish - start logger.info("Success") logger.info("runtime: %0.1f seconds" % runtime)
def setUp(self): self.text = read_ciphered_text()