For use in a with statement, this function returns a context manager that
    yields a path directly under root guaranteed to be unique by using the uuid
    module.  This path is not created.  However if the path is an existing file
    when the with statement is exited, the file will be removed.

    This function is useful if you want to use a file temporarily but do not
    want to write boilerplate to make sure it is removed when you are done with
    it.

    Example:

        with temps.tmpfile() as path:
            do_stuff(path)

def tmpfile(root=TEMPS_DIR, prefix=TEMPS_PREFIX, suffix=TEMPS_SUFFIX):
    '''
    For use in a with statement, this function returns a context manager that
    yields a path directly under root guaranteed to be unique by using the uuid
    module.  This path is not created.  However if the path is an existing file
    when the with statement is exited, the file will be removed.

    This function is useful if you want to use a file temporarily but do not
    want to write boilerplate to make sure it is removed when you are done with
    it.

    Example:

        with temps.tmpfile() as path:
            do_stuff(path)
    '''
    path = tmppath(root, prefix, suffix)
    try:
        yield path
    finally:
        if os.path.isfile(path):
            # try to delete the file
            os.unlink(path)