Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import zlib
- from sys import argv
- def decode(s):
- dec = zlib.decompress(s)
- res = dec.decode("utf-8")
- return res
- def encode(s):
- enc = zlib.compress(s)
- return enc
- if __name__ == "__main__":
- with open(argv[1], "rb") as fi:
- s = fi.read()
- if argv[1][-4:] == ".xml":
- out = encode(s)
- with open(argv[1][:-4], "wb") as fo:
- fo.write(out)
- else:
- out = decode(s)
- with open(argv[1] + ".xml", "w", encoding="utf-8") as fo:
- fo.write(out)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement