Hello,
It happened to me several time : re-write a small function to archive a directory, to mimic "tar -xzvf archive.tgz directory"
What about adding in tarfile this small function:
def archive_tree(archive_name, src_dir [[, add_empty_dir], callable]) -> creates an archive that contains the files in directory, by recursively walking into it.
if add_empty_dir is set to False (default: True), empty directory founded will not be added
if callable is provided, it will be triggered everytime a file is added in the archive and will return True or False
If False, the file will not be added
regards Tarek
On Sun, May 17, 2009, Tarek Ziad? wrote:
It happened to me several time : re-write a small function to archive a directory, to mimic "tar -xzvf archive.tgz directory"
Given that you already have this code, please upload to bugs.python.org (possibly also PyPI and/or Cookbook) so it doesn't get lost.
Tarek Ziadé wrote:
Hello,
It happened to me several time : re-write a small function to archive a directory, to mimic "tar -xzvf archive.tgz directory"
What about adding in tarfile this small function:
def archive_tree(archive_name, src_dir [[, add_empty_dir], callable]) -> creates an archive that contains the files in directory, by recursively walking into it.
if add_empty_dir is set to False (default: True),
empty directory founded will not be added
if callable is provided, it will be triggered
everytime a file is added in the archive and will return True or False
If False, the file will not be added
regards Tarek
I would call the callback-function "filter" or similar.
-panzi