#NEWLINE# def find_insertion_point( module_text , contents_signature , block_marker , force ) : #NEWLINE# #INDENT# block_marker_line = ( block_marker + '\n' ) #NEWLINE# start_index = module_text . find ( contents_signature ) #NEWLINE# if ( start_index == ( - 1 ) ) : #NEWLINE# #INDENT# if force : #NEWLINE# #INDENT# start_index = find_likely_insertion_point ( module_text ) #NEWLINE# end_index = start_index #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise Exception ( ( ( "couldn't find contents block in file\nplease insert after imports:\n" + contents_signature ) + block_marker ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# end_index = module_text . find ( force , ( start_index + 1 ) ) #NEWLINE# if ( end_index == ( - 1 ) ) : #NEWLINE# #INDENT# raise Exception ( ( 'contents block is unterminated in file\nplease terminate with this line:\n' + block_marker ) ) #NEWLINE# #UNINDENT# end_index += len ( block_marker_line ) #NEWLINE# #UNINDENT# return ( start_index , end_index )