#NEWLINE# def countLines( source , endPos ) : #NEWLINE# #INDENT# lines = 0 #NEWLINE# lineBegin = 0 #NEWLINE# lineEnd = 0 #NEWLINE# index = 0 #NEWLINE# while ( index <= endPos ) : #NEWLINE# #INDENT# m = reNewLine . search ( source , index ) #NEWLINE# if ( not m ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# index = m . end ( ) #NEWLINE# lines += 1 #NEWLINE# lineBegin = lineEnd #NEWLINE# lineEnd = index #NEWLINE# #UNINDENT# #UNINDENT# return ( lines , lineBegin , endPos )