#NEWLINE# def near( self , line , near , error_type = ERROR , word_re = None ) : #NEWLINE# #INDENT# '\n        Mark a range of text near a given word.\n\n        line, error_type and word_re are the same as in range().\n\n        If near is enclosed by quotes, they are stripped. The first occurrence\n        of near in the given line of code is matched. If the first and last\n        characters of near are word characters, a match occurs only if near\n        is a complete word.\n\n        The position at which near is found is returned, or zero if there\n        is no match.\n\n        ' #NEWLINE# if ( not near ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# ( start , end ) = self . full_line ( line ) #NEWLINE# text = self . code [ start : end ] #NEWLINE# near = self . strip_quotes ( near ) #NEWLINE# fence = [ '' , '' ] #NEWLINE# for ( i , pos ) in enumerate ( ( 0 , ( - 1 ) ) ) : #NEWLINE# #INDENT# if ( near [ pos ] . isalnum ( ) or ( near [ pos ] == '_' ) ) : #NEWLINE# #INDENT# fence [ i ] = '\\b' #NEWLINE# #UNINDENT# #UNINDENT# pattern = NEAR_RE_TEMPLATE . format ( fence [ 0 ] , re . escape ( near ) , fence [ 1 ] ) #NEWLINE# match = re . search ( pattern , text ) #NEWLINE# if match : #NEWLINE# #INDENT# start = match . start ( 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# start = ( - 1 ) #NEWLINE# #UNINDENT# if ( start != ( - 1 ) ) : #NEWLINE# #INDENT# self . range ( line , start , len ( near ) , error_type = error_type , word_re = word_re ) #NEWLINE# return start #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return 0