
Hey, For large archives, I want to display a progress bar while the archive is being extracted with: https://docs.python.org/3/library/tarfile.html#tarfile.TarFile.extractall I could write my own version of extractall() to do this, or maybe we could introduce a callback option that gets called everytime .extract() is called in extractall() The callback can receive the tarinfo object and where it's being extracted. This is enough to plug a progress bar and avoid reinventing .extractall() I can add a ticket and maybe a patch if people think this is a good little enhancement Cheers Tarek -- Tarek Ziadé | coding: https://ziade.org | running: https://foule.es | twitter: @tarek_ziade

Hi! On Fri, Sep 01, 2017 at 01:50:13PM +0200, Tarek Ziad?? <tarek@ziade.org> wrote:
What is "where" here? I think it should be 2 parameters -- position in the file (in bytes) and total file size; the total could be None if the size is unknown (the tar is piped from network or a (g/bz)zip subprocess).
I can add a ticket and maybe a patch if people think this is a good little enhancement
Definitely a good idea!
Oleg. -- Oleg Broytman http://phdru.name/ phd@phdru.name Programmers don't die, they just GOSUB without RETURN.

On Fri, Sep 1, 2017, at 02:04 PM, Oleg Broytman wrote:
Interesting. In my mind, I was thinking about a high level callable that would just let me count the files and directory that are being extracted, my hackish implementation with clint: with tarfile.open(file, "r:gz") as tar: size = len(list(tar)) with progress.Bar(expected_size=size) as bar: def _extract(self, *args, **kw): bar.show(bar.last_progress + 1) return self.old(*args, **kw) tar.old = tar.extract tar.extract = functools.partial(_extract, tar) tar.extractall(profile_dir) What I would expect to be able to do with the new option, something like: with tarfile.open(file, "r:gz") as tar: size = len(list(tar)) with progress.Bar(expected_size=size) as bar: def _progress(tarinfo): bar.show(bar.last_progress + 1) tar.extractall(profile_dir, onextracted=_progress)

Hi,
For large archives, I want to display a progress bar while the archive is being extracted with:
Should it, in the case of just on big file, be the progress 0% (start) or 100% (done) ? or there's a way to see some progress in that case ? or is irrelevant for that case ? Thanks in advance! --francis

01.09.17 14:50, Tarek Ziadé пише:
This is not enough if extract large files. In that case you perhaps want to update the progress bar more often. If add this feature to tarfile, it may be worth to add it to zipfile and shutil functions (copytree, rmtree). And if call a callback for every extracted/copied entity, it may be worth to use its result for filtering.

Hi! On Fri, Sep 01, 2017 at 01:50:13PM +0200, Tarek Ziad?? <tarek@ziade.org> wrote:
What is "where" here? I think it should be 2 parameters -- position in the file (in bytes) and total file size; the total could be None if the size is unknown (the tar is piped from network or a (g/bz)zip subprocess).
I can add a ticket and maybe a patch if people think this is a good little enhancement
Definitely a good idea!
Oleg. -- Oleg Broytman http://phdru.name/ phd@phdru.name Programmers don't die, they just GOSUB without RETURN.

On Fri, Sep 1, 2017, at 02:04 PM, Oleg Broytman wrote:
Interesting. In my mind, I was thinking about a high level callable that would just let me count the files and directory that are being extracted, my hackish implementation with clint: with tarfile.open(file, "r:gz") as tar: size = len(list(tar)) with progress.Bar(expected_size=size) as bar: def _extract(self, *args, **kw): bar.show(bar.last_progress + 1) return self.old(*args, **kw) tar.old = tar.extract tar.extract = functools.partial(_extract, tar) tar.extractall(profile_dir) What I would expect to be able to do with the new option, something like: with tarfile.open(file, "r:gz") as tar: size = len(list(tar)) with progress.Bar(expected_size=size) as bar: def _progress(tarinfo): bar.show(bar.last_progress + 1) tar.extractall(profile_dir, onextracted=_progress)

Hi,
For large archives, I want to display a progress bar while the archive is being extracted with:
Should it, in the case of just on big file, be the progress 0% (start) or 100% (done) ? or there's a way to see some progress in that case ? or is irrelevant for that case ? Thanks in advance! --francis

01.09.17 14:50, Tarek Ziadé пише:
This is not enough if extract large files. In that case you perhaps want to update the progress bar more often. If add this feature to tarfile, it may be worth to add it to zipfile and shutil functions (copytree, rmtree). And if call a callback for every extracted/copied entity, it may be worth to use its result for filtering.
participants (5)
-
francismb
-
Oleg Broytman
-
Paul Moore
-
Serhiy Storchaka
-
Tarek Ziadé