def make_tarball(base_name, base_dir, compress='<STR_LIT>',<EOL>verbose=False, dry_run=False):
<EOL>compress_ext = { '<STR_LIT>': "<STR_LIT>",<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': "<STR_LIT>" }<EOL>tarfile_compress_flag = {'<STR_LIT>':'<STR_LIT>', '<STR_LIT>':'<STR_LIT>'}<EOL>compress_flags = {'<STR_LIT>': ["<STR_LIT>"]}<EOL>if compress is not None and compress not in compress_ext.keys():<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>archive_name = base_name + "<STR_LIT>"<EOL>if compress and compress in tarfile_compress_flag:<EOL><INDENT>archive_name += compress_ext[compress]<EOL><DEDENT>mode = '<STR_LIT>' + tarfile_compress_flag.get(compress, '<STR_LIT>')<EOL>mkpath(os.path.dirname(archive_name), dry_run=dry_run)<EOL>log.info('<STR_LIT>' % (archive_name, mode))<EOL>if not dry_run:<EOL><INDENT>tar = tarfile.open(archive_name, mode=mode)<EOL>tar.add(base_dir)<EOL>tar.close()<EOL><DEDENT>if compress and compress not in tarfile_compress_flag:<EOL><INDENT>spawn([compress] + compress_flags[compress] + [archive_name],<EOL>dry_run=dry_run)<EOL>return archive_name + compress_ext[compress]<EOL><DEDENT>else:<EOL><INDENT>return archive_name<EOL><DEDENT>
Create a tar file from all the files under 'base_dir'.
    This file may be compressed.

    :param compress: Compression algorithms. Supported algorithms are:
        'gzip': (the default)
        'compress'
        'bzip2'
        None
    For 'gzip' and 'bzip2' the internal tarfile module will be used.
    For 'compress' the .tar will be created using tarfile, and then
    we will spawn 'compress' afterwards.
    The output tar file will be named 'base_name' + ".tar", 
    possibly plus the appropriate compression extension (".gz",
    ".bz2" or ".Z").  Return the output filename.