Advertisement
redsees

Untitled

May 24th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. #!/usr/bin/env python2
  2. try:
  3.     from blessings import Terminal
  4.     from MyCompLib import MyCompress
  5. except ImportError:
  6.     print "[!] Error finding one or more libraries\n\n"
  7.     exit(-1)
  8.    
  9.    
  10. if __name__ == "__main__":
  11.    
  12.     t = Terminal()
  13.     Example_str = 'HelloWorld1234HELLOWORLD123498875'
  14.    
  15.     # LZW Compression and Decompression Example
  16.     myinst = MyCompress()
  17.     compressed   = myinst.LZW_Compress(Example_str)
  18.    
  19.     print t.white("Original String: ") + t.green("\n{0}".format(Example_str)) + t.white("\nLength: ") + t.red("{0}\n".format(len(Example_str)))
  20.     print t.white("Compressed String:")
  21.     print (compressed)
  22.     print t.white("Length: ") + t.red("{0}\n".format(len(compressed)))
  23.    
  24.     decompressed = myinst.LZW_Decompress(compressed)
  25.    
  26.     print t.white("Decompressed String:\n") + t.green("{0}".format(decompressed))+ "\n" + t.white("Length: ") + t.red("{0}\n".format(len(decompressed)))
  27.    
  28.     # Huffman Encoding Example
  29.     huff = myinst.HM_Encode(Example_str)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement