Adds or Updates a key/value to the given .env

    If the .env path given doesn't exist, fails instead of risking creating
    an orphan .env somewhere in the file-system

    :param dotenv_path: env path
    :param key_to_set: key
    :param value_to_set: value
    :param quote_mode: quote value in .env file
    :param verbose: verbosity flag, raise warning if path does not exist
    :return: tuple (fail/win, key, value)

def set_key(dotenv_path, key_to_set, value_to_set, quote_mode='always', verbose=False):
    """
    Adds or Updates a key/value to the given .env

    If the .env path given doesn't exist, fails instead of risking creating
    an orphan .env somewhere in the file-system

    :param dotenv_path: env path
    :param key_to_set: key
    :param value_to_set: value
    :param quote_mode: quote value in .env file
    :param verbose: verbosity flag, raise warning if path does not exist
    :return: tuple (fail/win, key, value)
    """
    key_to_set = str(key_to_set)
    value_to_set = str(value_to_set).strip("'").strip('"')
    if not os.path.exists(dotenv_path):
        if verbose:
            warnings.warn(f"Can't write to {dotenv_path}, it doesn't exist.")
        return None, key_to_set, value_to_set

    dotenv_as_dict = OrderedDict(parse_dotenv(dotenv_path))
    dotenv_as_dict[key_to_set] = value_to_set
    success = flatten_and_write(dotenv_path, dotenv_as_dict, quote_mode)

    return success, key_to_set, value_to_set