def download_extract_tar(tar_url, folder, tar_filename='<STR_LIT>'):
try:<EOL><INDENT>makedirs(folder)<EOL><DEDENT>except OSError:<EOL><INDENT>if not isdir(folder):<EOL><INDENT>raise<EOL><DEDENT><DEDENT>data_file = tar_filename<EOL>if not data_file:<EOL><INDENT>fd, data_file = mkstemp('<STR_LIT>')<EOL>download(tar_url, os.fdopen(fd, '<STR_LIT:wb>'))<EOL><DEDENT>else:<EOL><INDENT>download(tar_url, data_file)<EOL><DEDENT>with tarfile.open(data_file) as tar:<EOL><INDENT>tar.extractall(path=folder)<EOL><DEDENT>
Download and extract the tar at the url to the given folder

Args:
    tar_url (str): URL of tar file to download
    folder (str): Location of parent directory to extract to. Doesn't have to exist
    tar_filename (str): Location to download tar. Default is to a temp file