def compress(d, output, fmt='<STR_LIT>', logger=None):
if not logger:<EOL><INDENT>logger = log.get_logger('<STR_LIT>')<EOL><DEDENT>if type(d) not in [list, tuple]:<EOL><INDENT>d = [d, ]<EOL><DEDENT>d = [os.path.expanduser(_d) for _d in d]<EOL>print_compress_info(d, output, compress, logger)<EOL>if fmt.lower() == '<STR_LIT:none>':<EOL><INDENT>fmt = '<STR_LIT>'<EOL><DEDENT>elif fmt.lower() not in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>logger.info('<STR_LIT>'.format(fmt))<EOL>fmt = '<STR_LIT>'<EOL><DEDENT>output = os.path.expanduser(output)<EOL>tar = tarfile.open(output, '<STR_LIT>'.format(fmt))<EOL>for obj in d:<EOL><INDENT>tar.add(obj)<EOL><DEDENT>tar.close()<EOL>return output<EOL>
Creates a compressed/uncompressed tar file.

Args:

    d: Can be one of three things:

        1. the path to a single file, as a string

        2. the path to a single directory, as a string

        3. an iterable of file or directory paths

    output (str): Output file path.

    fmt: Compression method. Options are ``'gz'`` (gzip),
        ``'bz2'`` (bzip2) and ``'none'`` (uncompressed). Default is ``'gz'``.