def do_write(self, ex_command):
        fname = ex_command.command.target_file

        if not ex_command.command.forced:
            if os.path.exists(fname):
                utils.blink()
                show_error(VimError(ERR_FILE_EXISTS))
                return

            if self.check_is_readonly(fname):
                utils.blink()
                show_error(VimError(ERR_READONLY_FILE))
                return

        region = None
        if ex_command.line_range.is_empty:
            # If the user didn't provide any range data, Vim writes whe whole buffer.
            region = R(0, self._view.size())
        else:
            region = ex_command.line_range.resolve(self._view)

        assert region is not None, "range cannot be None"

        try:
            expanded_path = os.path.expandvars(os.path.expanduser(fname))
            expanded_path = os.path.abspath(expanded_path)
            with open(expanded_path, 'wt') as f:
                text = self._view.substr(region)
                f.write(text)
            # FIXME: Does this do what we think it does?
            self._view.retarget(expanded_path)
            self.window.run_command('save')

        except __HOLE__ as e:
            # TODO: Add logging.
            show_error(VimError(ERR_CANT_WRITE_FILE))
            print('Vintageous ==============================================')
            print (e)
            print('=========================================================')
dataset/ETHPy150Open guillermooo/Vintageous/ex_commands.py/ExWriteFile.do_write