SHARE
TWEET

Untitled

a guest Mar 20th, 2019 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import zlib
  2. from sys import argv
  3.  
  4.  
  5. def decode(s):
  6.     dec = zlib.decompress(s)
  7.     res = dec.decode("utf-8")
  8.     return res
  9.  
  10.  
  11. def encode(s):
  12.     enc = zlib.compress(s)
  13.     return enc
  14.  
  15.  
  16. if __name__ == "__main__":
  17.  
  18.     with open(argv[1], "rb") as fi:
  19.         s = fi.read()
  20.  
  21.     if argv[1][-4:] == ".xml":
  22.         out = encode(s)
  23.  
  24.         with open(argv[1][:-4], "wb") as fo:
  25.             fo.write(out)
  26.  
  27.     else:
  28.         out = decode(s)
  29.  
  30.         with open(argv[1] + ".xml", "w", encoding="utf-8") as fo:
  31.             fo.write(out)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top