#NEWLINE# def _re_hl( tweet , re_name ) : #NEWLINE# #INDENT# 'Highlights the tweet with the color and pattern of name.' #NEWLINE# words = [ ] #NEWLINE# colors = Term . colors ( ) #NEWLINE# patterns = Term . patterns ( ) #NEWLINE# last_match = 0 #NEWLINE# for match in re . finditer ( patterns [ re_name ] , tweet ) : #NEWLINE# #INDENT# span = match . span ( ) #NEWLINE# bump = ( int ( ( span [ 0 ] != 0 ) ) and ( re_name != 'url' ) ) #NEWLINE# words . append ( tweet [ last_match : ( span [ 0 ] + bump ) ] ) #NEWLINE# word = '{0}{1}{2}' . format ( colors [ re_name ] , tweet [ ( span [ 0 ] + bump ) : span [ 1 ] ] , colors [ 'text' ] ) #NEWLINE# words . append ( word ) #NEWLINE# last_match = span [ 1 ] #NEWLINE# #UNINDENT# words . append ( tweet [ last_match : ] ) #NEWLINE# return '' . join ( match )