Beispiel #1
0
def main():
    while (1):
        print("1.Compress\n2.Decompress\n3.Exit")
        choice = int(input("Enter Choice :"))
        if choice == 1:
            fileName = input("Enter file Name: ")
            print("Encoding : ", fileName)
            frequencyObject = Frequency(fileName)
            frequencyTable = frequencyObject.frequencyTable()

            huffmanObject = Huffman(frequencyTable)
            huffmanCodes = huffmanObject.huffman()

            encodeObject = Encode(huffmanCodes, fileName)
            encodeObject.encode()

            print("File Encoded as:" + fileName + ".bv\n\n")

        elif choice == 2:
            fileName = input("Enter file Name: ")
            print("decoding : ", fileName)
            decodeObject = Decode(fileName)
            decodeObject.decode()
            print("\nDecoded as " + fileName + "_new.txt")

        elif choice == 3:
            print("Bye\n")
            return
        else:
            print("Invalid Choice\n")