def _handle_event_colors(color_dict, unique_events, event_id):
    'Create event-integer-to-color mapping, assigning defaults as needed.'
    default_colors = dict(zip(sorted(unique_events), cycle(_get_color_list())))
    if (color_dict is None):
        if (len(unique_events) > len(_get_color_list())):
            warn('More events than default colors available. You should pass a list of unique colors.')
    else:
        custom_colors = dict()
        for (key, color) in color_dict.items():
            if (key in unique_events):
                custom_colors[key] = color
            elif (key in event_id):
                custom_colors[event_id[key]] = color
            else:
                warn(('Event ID %s is in the color dict but is not present in events or event_id.' % str(key)))
        unassigned = sorted((set(unique_events) - set(custom_colors)))
        if len(unassigned):
            unassigned_str = ', '.join((str(e) for e in unassigned))
            warn(('Color was not assigned for event%s %s. Default colors will be used.' % (_pl(unassigned), unassigned_str)))
        default_colors.update(custom_colors)
    return default_colors
Create event-integer-to-color mapping, assigning defaults as needed.
def _handle_event_colors(color_dict, unique_events, event_id):
    
    default_colors = dict(zip(sorted(unique_events), cycle(_get_color_list())))
    if (color_dict is None):
        if (len(unique_events) > len(_get_color_list())):
            warn('More events than default colors available. You should pass a list of unique colors.')
    else:
        custom_colors = dict()
        for (key, color) in color_dict.items():
            if (key in unique_events):
                custom_colors[key] = color
            elif (key in event_id):
                custom_colors[event_id[key]] = color
            else:
                warn(('Event ID %s is in the color dict but is not present in events or event_id.' % str(key)))
        unassigned = sorted((set(unique_events) - set(custom_colors)))
        if len(unassigned):
            unassigned_str = ', '.join((str(e) for e in unassigned))
            warn(('Color was not assigned for event%s %s. Default colors will be used.' % (_pl(unassigned), unassigned_str)))
        default_colors.update(custom_colors)
    return default_colors