When copying large files using shutil.copy(), you get no indication of how the operation is progressing..
I have put together something that works – it uses a simple ProgressBar class (which simple returns a simple ASCII progress bar, as a string), and a loop of open().read() and .write() to do the actual copying. It displays the progress bar using sys.stdout.write('\r%s\r' % (the_progress_bar)) which is a little hackish, but it works.
You can see the code (in context) on github here
Is there any built-in module that will do this better? Is there any improvements that can be made to this code?
Two things:
copy_with_progfunction not output the progress bar itself, but call a callback function so the caller can decide how to display the progress.Perhaps something like this: