[Python-ideas] Add a "archive_tree" in the tarfile module
Tarek Ziadé
ziade.tarek at gmail.com
Sun May 17 16:52:43 CEST 2009
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
--
Tarek Ziadé | http://ziade.org
More information about the Python-ideas
mailing list