Advertisement
METAJIJI

Untitled

Feb 12th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. import lzma
  2. import os
  3.  
  4.  
  5. def sub3(f_in, f_out):
  6.     with open(f_in, 'rb') as fd_in, open(f_out, 'wb') as fd_out:
  7.         xz = lzma.LZMACompressor()
  8.         file_size = os.path.getsize(f_in)
  9.         file_size_dl = 0
  10.         chunk_len = 1024 * 4
  11.         for chunk in iter(lambda: fd_in.read(chunk_len), b''):
  12.             file_size_dl += len(chunk)
  13.             fd_out.write(xz.compress(chunk))
  14.             print(u'Decompressing {size:4d}MB [{percent:.2f}%] {file_name}'.format(size=file_size_dl/1024,
  15.                                                                                    percent=100.0*file_size_dl/file_size,
  16.                                                                                    file_name=f_in)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement