This module contains function to manipulate archives.
We will always manipulate .tar.gz archives on UNIX, and .zip on windows. (keeping it close to the more common used format of the given platform)
All archives should have a unique top dir.
Just a custom exception
Return the name an archive made from the directory would have. (platform-dependant)
On windows:
>>> archive_name('foo')
foo.zip
Elsewhere:
>>> archive_name('foo')
foo.tar.gz
Extract an archive, calling extract_zip or extract_tar when necessary
The top directory of the archive will be replaced by topdir if it is given
Returns: | path to the extracted archive |
---|
Extract a .tar.gz archive
Returns: | path to the extracted archive (dest_dir/topdir) |
---|
Extract a zip archive :return: path to the extracted archive (dest_dir/topdir)
Return the extracted name from the archive name.
Warning: this assumes the archive is well-formed (ie the root dir of foo.tar.gz is foo)
>>> extracted_name("foo.zip")
'foo'
>>> extracted_name("foo.tar.gz")
'foo'
Zip a directory, using .zip on Windows or .tar.gz otherwise.
Call tar cvfz on a directory
Compress the directory in a .zip file