<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write(to, _vars, _secrets, path, env, y):
 """Writes data to specific source"""

    _vars = split_vars(_vars)
    _secrets = split_vars(_secrets)
    loader = importlib.import_module("dynaconf.loaders.{}_loader".format(to))

    if to in EXTS:

        # Lets write to a file
        path = Path(path)

        if str(path).endswith(constants.ALL_EXTENSIONS + ("py",)):
            settings_path = path
            secrets_path = path.parent / ".secrets.{}".format(to)
        else:
            if to == "env":
                if str(path) in (".env", "./.env"):  # pragma: no cover
                    settings_path = path
                elif str(path).endswith("/.env"):
                    settings_path = path
                elif str(path).endswith(".env"):
                    settings_path = path.parent / ".env"
                else:
                    settings_path = path / ".env"
                Path.touch(settings_path)
                secrets_path = None
                _vars.update(_secrets)
            else:
                settings_path = path / "settings.{}".format(to)
                secrets_path = path / ".secrets.{}".format(to)

        if (
            _vars and not y and settings_path and settings_path.exists()
        ):  # pragma: no cover  # noqa
            click.confirm(
                "{} exists do you want to overwrite it?".format(settings_path),
                abort=True,
            )

        if (
            _secrets and not y and secrets_path and secrets_path.exists()
        ):  # pragma: no cover  # noqa
            click.confirm(
                "{} exists do you want to overwrite it?".format(secrets_path),
                abort=True,
            )

        if to not in ["py", "env"]:
            if _vars:
                _vars = {env: _vars}
            if _secrets:
                _secrets = {env: _secrets}

        if _vars and settings_path:
            loader.write(settings_path, _vars, merge=True)
            click.echo("Data successful written to {}".format(settings_path))

        if _secrets and secrets_path:
            loader.write(secrets_path, _secrets, merge=True)
            click.echo("Data successful written to {}".format(secrets_path))

    else:  # pragma: no cover
        # lets write to external source
        with settings.using_env(env):
            # make sure we're in the correct environment
            loader.write(settings, _vars, **_secrets)
        click.echo("Data successful written to {}".format(to))