def _assign_curtailment(curtailment, edisgo, generators, curtailment_key):
    """
    Helper function to write curtailment time series to generator objects.

    This function also writes a list of the curtailed generators to curtailment
    in :class:`edisgo.grid.network.TimeSeries` and
    :class:`edisgo.grid.network.Results`.

    Parameters
    ----------
    curtailment : :pandas:`pandas.DataFrame<dataframe>`
        Dataframe containing the curtailment in kW per generator and time step
        for all generators of the type (and in weather cell) specified in
        `curtailment_key` parameter. Index is a
        :pandas:`pandas.DatetimeIndex<datetimeindex>`, columns are the
        generator representatives.
    edisgo : :class:`edisgo.grid.network.EDisGo`
    generators : :pandas:`pandas.DataFrame<dataframe>`
        Dataframe with all generators of the type (and in weather cell)
        specified in `curtailment_key` parameter. See return value of
        :func:`edisgo.grid.tools.get_gen_info` for more information.
    curtailment_key : :obj:`str` or :obj:`tuple` with :obj:`str`
        The technology and weather cell ID if :obj:`tuple` or only
        the technology if :obj:`str` the curtailment is specified for.

    """
    gen_object_list = []
    for gen in curtailment.columns:
        gen_object = generators.loc[generators.gen_repr == gen].index[0]
        gen_object.curtailment = curtailment.loc[:, (gen)]
        gen_object_list.append(gen_object)
    if edisgo.network.timeseries._curtailment:
        edisgo.network.timeseries._curtailment.extend(gen_object_list)
        edisgo.network.results._curtailment[curtailment_key] = gen_object_list
    else:
        edisgo.network.timeseries._curtailment = gen_object_list
        edisgo.network.results._curtailment = {curtailment_key:
            gen_object_list.copy()}
