def find_next(lines, find_str, start_index):
    """
    Find the next instance of find_str from lines starting from start_index.

    :param lines: Lines to look through
    :param find_str: String or Invert to look for
    :param start_index: Index to start from
    :return: (boolean, index, line)
    """
    mode = None
    if isinstance(find_str, basestring):
        mode = 'normal'
        message = find_str
    elif isinstance(find_str, Invert):
        mode = 'invert'
        message = str(find_str)
    else:
        raise TypeError("Unsupported message type")
    for i in range(start_index, len(lines)):
        if re.search(message, lines[i]):
            return mode == 'normal', i, lines[i]
        elif message in lines[i]:
            return mode == 'normal', i, lines[i]
    if mode == 'invert':
        return True, len(lines), None
    raise LookupError("Not found")
def find_next ( lines , find_str , start_index ) : mode = None if isinstance ( find_str , basestring ) : mode = 'normal' message = find_str elif isinstance ( find_str , Invert ) : mode = 'invert' message = str ( find_str ) else : raise TypeError ( "Unsupported message type" ) for i in range ( start_index , len ( lines ) ) : if re . search ( message , lines [ i ] ) : return mode == 'normal' , i , lines [ i ] elif message in lines [ i ] : return mode == 'normal' , i , lines [ i ] if mode == 'invert' : return True , len ( lines ) , None raise LookupError ( "Not found" )
Find the next instance of find_str from lines starting from start_index.

    :param lines: Lines to look through
    :param find_str: String or Invert to look for
    :param start_index: Index to start from
    :return: (boolean, index, line)