(indices, sketch)
return list(set(indices)), list(timelines)
Exclude any deleted search index references.

    Args:
        indices: List of indices from the user
        sketch: A sketch object (instance of models.sketch.Sketch).

    Returns:
        Tuple of two items:
          List of indices with those removed that is not in the sketch
          List of timeline IDs that should be part of the output.
Exclude any deleted search index references.
Exclude any deleted search index references .
def get_validated_indices(indices, sketch):
    """Exclude any deleted search index references.

    Args:
        indices: List of indices from the user
        sketch: A sketch object (instance of models.sketch.Sketch).

    Returns:
        Tuple of two items:
          List of indices with those removed that is not in the sketch
          List of timeline IDs that should be part of the output.
    """
    sketch_structure = {}
    for timeline in sketch.timelines:
        if timeline.get_status.status.lower() != 'ready':
            continue
        index_ = timeline.searchindex.index_name
        sketch_structure.setdefault(index_, [])
        sketch_structure[index_].append({
            'name': timeline.name,
            'id': timeline.id,
        })

    sketch_indices = set(sketch_structure.keys())
    exclude = set(indices) - sketch_indices
    timelines = set()

    if exclude:
        indices = [index for index in indices if index not in exclude]
        for item in exclude:
            for index, timeline_list in sketch_structure.items():
                for timeline_struct in timeline_list:
                    timeline_id = timeline_struct.get('id')
                    timeline_name = timeline_struct.get('name')

                    if not timeline_id:
                        continue

                    if isinstance(item, str) and item.isdigit():
                        item = int(item)

                    if item == timeline_id:
                        timelines.add(timeline_id)
                        indices.append(index)

                    if isinstance(
                            item, str) and item.lower(
                                ) == timeline_name.lower():
                        timelines.add(timeline_id)
                        indices.append(index)

    return list(set(indices)), list(timelines)
def get_validated_indices ( indices , sketch ) : sketch_structure = { } for timeline in sketch . timelines : if timeline . get_status . status . lower ( ) != 'ready' : continue index_ = timeline . searchindex . index_name sketch_structure . setdefault ( index_ , [ ] ) sketch_structure [ index_ ] . append ( { 'name' : timeline . name , 'id' : timeline . id , } ) sketch_indices = set ( sketch_structure . keys ( ) ) exclude = set ( indices ) - sketch_indices timelines = set ( ) if exclude : indices = [ index for index in indices if index not in exclude ] for item in exclude : for index , timeline_list in sketch_structure . items ( ) : for timeline_struct in timeline_list : timeline_id = timeline_struct . get ( 'id' ) timeline_name = timeline_struct . get ( 'name' ) if not timeline_id : continue if isinstance ( item , str ) and item . isdigit ( ) : item = int ( item ) if item == timeline_id : timelines . add ( timeline_id ) indices . append ( index ) if isinstance ( item , str ) and item . lower ( ) == timeline_name . lower ( ) : timelines . add ( timeline_id ) indices . append ( index ) return list ( set ( indices ) ) , list ( timelines )