def write_to_tempfile(content, path=None, suffix='', prefix='tmp'):
    if path:
        ensure_tree(path)

    (fd, path) = tempfile.mkstemp(suffix=suffix, dir=path, prefix=prefix)
    try:
        os.write(fd, content)
    finally:
        os.close(fd)
    return path
Create temporary file or use existing file.
dataset/ETHPy150Open openstack/solum/solum/openstack/common/fileutils.py/write_to_tempfile