miurahr / py7zr

7zip in python3 with ZStandard, PPMd, LZMA2, LZMA1, Delta, BCJ, BZip2, and Deflate compressions, and AES encryption.

Home Page:https://pypi.org/project/py7zr/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does it support decompression progress display?

boynton89 opened this issue · comments

Does it support decompression progress display?

@boynton89 you can see callback API that give you a way to get a progress.

py7zr/tests/test_misc.py

Lines 129 to 152 in 96c2745

def test_extract_callback(tmp_path):
# test the case when good callback passed.
class ECB(py7zr.callbacks.ExtractCallback):
def __init__(self, ofd):
self.ofd = ofd
def report_start_preparation(self):
self.ofd.write("preparation.\n")
def report_start(self, processing_file_path, processing_bytes):
self.ofd.write('start "{}" (compressed in {} bytes)\n'.format(processing_file_path, processing_bytes))
def report_end(self, processing_file_path, wrote_bytes):
self.ofd.write('end "{}" extracted to {} bytes\n'.format(processing_file_path, wrote_bytes))
def report_postprocess(self):
self.ofd.write("post processing.\n")
def report_warning(self, message):
self.ofd.write("warning: {:s}\n".format(message))
cb = ECB(sys.stdout)
with py7zr.SevenZipFile(open(os.path.join(testdata_path, "test_1.7z"), "rb")) as archive:
archive.extractall(path=tmp_path, callback=cb)

This test case define a class ECB that print callback message to stdout, inherited from ExtractCallBack, and pass its instance to extractall method.

A CLI does not implement it yet.

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days