def copy_to_tmp(source):
tmp_dir = tempfile.mkdtemp()<EOL>p = pathlib.Path(source)<EOL>dirname = p.name or '<STR_LIT>'<EOL>new_dir = os.path.join(tmp_dir, dirname)<EOL>if os.path.isdir(source):<EOL><INDENT>shutil.copytree(source, new_dir)<EOL><DEDENT>else:<EOL><INDENT>shutil.copy2(source, new_dir)<EOL><DEDENT>return new_dir<EOL>
Copies ``source`` to a temporary directory, and returns the copied
location.

If source is a file, the copied location is also a file.