コード例 #1
0
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))
コード例 #2
0
ファイル: word_data.py プロジェクト: dave31415/decipher
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
コード例 #3
0
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
コード例 #4
0
ファイル: decipher.py プロジェクト: dave31415/decipher
    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)
コード例 #5
0
ファイル: decipher.py プロジェクト: dave31415/decipher
        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)
コード例 #6
0
ファイル: test_fileio.py プロジェクト: dave31415/decipher
 def setUp(self):
     self.text = read_ciphered_text()