(
            self, name, description, sketch, index_name='',
            data_label='', extension='')
return searchindex
Returns a SearchIndex object to be used for uploads.

        Args:
            name: the name of the searchindex.
            description: the description of the searchindex.
            sketch: sketch object (instance of Sketch).
            index_name: optional index name, if supplied and if it exists
                then the index associated with that will be returned.
            data_label: optional label of the data, if supplied will be used to
                determine whether an already existing index can be
                used or a new one created.
            extension: optional file extension if a file is being uploaded,
                if supplied and no data label used, then the extension will be
                used as a data label.

        Returns:
            A SearchIndex object.
Returns a SearchIndex object to be used for uploads.
Returns a SearchIndex object to be used for uploads .
def _get_index(
            self, name, description, sketch, index_name='',
            data_label='', extension=''):
        """Returns a SearchIndex object to be used for uploads.

        Args:
            name: the name of the searchindex.
            description: the description of the searchindex.
            sketch: sketch object (instance of Sketch).
            index_name: optional index name, if supplied and if it exists
                then the index associated with that will be returned.
            data_label: optional label of the data, if supplied will be used to
                determine whether an already existing index can be
                used or a new one created.
            extension: optional file extension if a file is being uploaded,
                if supplied and no data label used, then the extension will be
                used as a data label.

        Returns:
            A SearchIndex object.
        """
        if index_name:
            if not isinstance(index_name, str):
                index_name = codecs.decode(index_name, 'utf-8')

            searchindex = SearchIndex.query.filter_by(
                name=name, index_name=index_name).first()

            if searchindex and searchindex.has_permission(
                    permission='write', user=current_user):
                return searchindex

        if extension and not data_label:
            data_label = extension

        if not data_label:
            data_label = 'generic'

        # Since CSV and JSON are basically the same label, we combine it here.
        if data_label in ('csv', 'json', 'jsonl'):
            data_label = 'csv_jsonl'

        indices = [t.searchindex for t in sketch.active_timelines]
        for index in indices:
            if index.has_label(data_label) and sketch.has_permission(
                    permission='write', user=current_user):
                return index

        index_name = index_name or uuid.uuid4().hex
        searchindex = SearchIndex.get_or_create(
            name=name,
            index_name=index_name,
            description=description,
            user=current_user)

        searchindex.grant_permission(permission='read', user=current_user)
        searchindex.grant_permission(permission='write', user=current_user)
        searchindex.grant_permission(permission='delete', user=current_user)
        searchindex.set_status('processing')

        db_session.add(searchindex)
        db_session.commit()

        searchindex.add_label(data_label, user=current_user)

        return searchindex
def _get_index ( self , name , description , sketch , index_name = '' , data_label = '' , extension = '' ) : if index_name : if not isinstance ( index_name , str ) : index_name = codecs . decode ( index_name , 'utf-8' ) searchindex = SearchIndex . query . filter_by ( name = name , index_name = index_name ) . first ( ) if searchindex and searchindex . has_permission ( permission = 'write' , user = current_user ) : return searchindex if extension and not data_label : data_label = extension if not data_label : data_label = 'generic' # Since CSV and JSON are basically the same label, we combine it here. if data_label in ( 'csv' , 'json' , 'jsonl' ) : data_label = 'csv_jsonl' indices = [ t . searchindex for t in sketch . active_timelines ] for index in indices : if index . has_label ( data_label ) and sketch . has_permission ( permission = 'write' , user = current_user ) : return index index_name = index_name or uuid . uuid4 ( ) . hex searchindex = SearchIndex . get_or_create ( name = name , index_name = index_name , description = description , user = current_user ) searchindex . grant_permission ( permission = 'read' , user = current_user ) searchindex . grant_permission ( permission = 'write' , user = current_user ) searchindex . grant_permission ( permission = 'delete' , user = current_user ) searchindex . set_status ( 'processing' ) db_session . add ( searchindex ) db_session . commit ( ) searchindex . add_label ( data_label , user = current_user ) return searchindex