def _write_file(path, content, permissions=DEFAULT_PERMISSIONS,
                open_mode="wb"):
    """Writes a file with the given content.

    Also the function sets the file mode as specified.
    The function arguments are the following:
        path: The absolute path to the location on the filesystem where
        the file should be written.
        content: The content that should be placed in the file.
        permissions:The octal permissions set that should be given for
        this file.
        open_mode: The open mode used when opening the file.
    """
    dirname = os.path.dirname(path)
    if not os.path.isdir(dirname):
        try:
            os.makedirs(dirname)
        except __HOLE__ as exc:
            LOG.exception(exc)
            return False

    with open(path, open_mode) as file_handle:
        file_handle.write(content)
        file_handle.flush()

    os.chmod(path, permissions)
    return True
dataset/ETHPy150Open openstack/cloudbase-init/cloudbaseinit/plugins/common/userdataplugins/cloudconfigplugins/write_files.py/_write_file