decompress_log.py 456 B

1234567891011121314151617181920
  1. import zlib
  2. import os
  3. import sys
  4. def decompress(args):
  5. decompressor = zlib.decompressobj(-zlib.MAX_WBITS)
  6. src = args[0]
  7. dst = args[1]
  8. _buffer = []
  9. with open(src, "rb") as src_fp:
  10. _buffer = bytearray(os.path.getsize(src))
  11. src_fp.readinto(_buffer)
  12. with open(dst, "w+") as dst_fp:
  13. tmp = decompressor.decompress(str(_buffer))
  14. dst_fp.write(tmp)
  15. if __name__ == "__main__":
  16. decompress(sys.args[1:])