import os
from distutils.errors import DistutilsExecError
from distutils.spawn import spawn
-
+from distutils.dir_util import mkpath
def make_tarball (base_name, base_dir, compress="gzip",
verbose=0, dry_run=0):
"bad value for 'compress': must be None, 'gzip', or 'compress'"
archive_name = base_name + ".tar"
+ mkpath(os.path.dirname(archive_name), verbose=verbose, dry_run=dry_run)
cmd = ["tar", "-cf", archive_name, base_dir]
spawn (cmd, verbose=verbose, dry_run=dry_run)
# no changes needed!
zip_filename = base_name + ".zip"
+ mkpath(os.path.dirname(zip_filename), verbose=verbose, dry_run=dry_run)
try:
spawn (["zip", "-rq", zip_filename, base_dir],
verbose=verbose, dry_run=dry_run)
'bztar': (make_tarball, [('compress', 'bzip2')], "bzip2'ed tar-file"),
'ztar': (make_tarball, [('compress', 'compress')], "compressed tar file"),
'tar': (make_tarball, [('compress', None)], "uncompressed tar file"),
- 'zip': (make_zipfile, [],"zip-file")
+ 'zip': (make_zipfile, [],"ZIP file")
}
def check_archive_formats (formats):