Closed andrewleech closed 8 years ago
Thank you for your nice work!! @andrewleech ;) What are you thinking of the use case of this changes? logging ??
I don't think of anything now... sorry.
I'm using pyminizip in a thread in a python gui application with a progress() function which updates a progress bar on the gui while it's compressing a large folder of text files.
But similarly, in a command line python script the progress function could be used like:
from __future__ import print_function
import os
import pyminizip
files = [f for f in os.listdir('.') if os.path.isfile(f)]
def progress(count):
percent = 100.0 * count / len(files)
prog = '#' * int(percent)
prog += ' ' * (100 - len(prog))
print ('\r[%s] %0.2f%%' % (prog, percent), end="")
pyminizip.compress_multiple(files, "archive.zip", "1233", 4, progress)
This displays a nice pretty progress bar on the command line while it's compressing all the files in the current folder.
Oh I see. It may be able to use on webapplication's progress bar too. Thank you for your nice commit!
This patch allows the progress of a compress_multiple() to be monitored. The optional new argument to compress_multiple is a function that accepts one argument, the count of files currently processed.
Usage is as such: