import copy


def filter_parts(settings):
    """
    Remove grouped components and glyphs that have been deleted or split.
    """
    parts = []
    temp = copy.copy(settings['glyphs'])
    for glyph in settings['glyphs']:
        name = glyph['class_name']
        if name.startswith("_split") or name.startswith("_group") or name.startswith("_delete"):
            parts.append(glyph)
            temp.remove(glyph)
    settings['glyphs'] = temp
    # Remove from the training glyphs as well
    temp2 = copy.copy(settings['training_glyphs'])
    for glyph in settings['training_glyphs']:
        name = glyph['class_name']
        if name.startswith("_split") or name.startswith("_group") or name.startswith("_delete"):
            temp2.remove(glyph)
    settings['training_glyphs'] = temp2
    return parts