[Python-ideas] Add a "archive_tree" in the tarfile module

Mathias Panzenböck grosser.meister.morti at gmx.net
Sun May 17 21:27:06 CEST 2009


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



More information about the Python-ideas mailing list