@contextmanager<EOL>def make_tmp_name(name):
path, base = os.path.split(name)<EOL>tmp_base = "<STR_LIT>" % (base, uuid4().hex)<EOL>tmp_name = os.path.join(path, tmp_base)<EOL>try:<EOL><INDENT>yield tmp_name<EOL><DEDENT>finally:<EOL><INDENT>safe_remove(tmp_name)<EOL><DEDENT>
Generates a tmp name for a file or dir.

    This is a tempname that sits in the same dir as `name`. If it exists on
    disk at context exit time, it is deleted.