Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import lzma
- import os
- def sub3(f_in, f_out):
- with open(f_in, 'rb') as fd_in, open(f_out, 'wb') as fd_out:
- xz = lzma.LZMACompressor()
- file_size = os.path.getsize(f_in)
- file_size_dl = 0
- chunk_len = 1024 * 4
- for chunk in iter(lambda: fd_in.read(chunk_len), b''):
- file_size_dl += len(chunk)
- fd_out.write(xz.compress(chunk))
- print(u'Decompressing {size:4d}MB [{percent:.2f}%] {file_name}'.format(size=file_size_dl/1024,
- percent=100.0*file_size_dl/file_size,
- file_name=f_in)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement