#NEWLINE# def _filter_coverage_for_added_lines( self , diff , coverage ) : #NEWLINE# #INDENT# '\n        This function takes a diff (text based) and a map of file names to the coverage for those files and\n        returns an ordered list of the coverage for each "addition" line in the diff.\n\n        If we don\'t have coverage for a specific file, we just mark the lines in those files as unknown or \'N\'.\n        ' #NEWLINE# if ( not diff ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# diff_lines = diff . splitlines ( ) #NEWLINE# current_file = None #NEWLINE# line_number = None #NEWLINE# coverage_by_added_line = [ ] #NEWLINE# for line in diff_lines : #NEWLINE# #INDENT# if line . startswith ( 'diff' ) : #NEWLINE# #INDENT# current_file = None #NEWLINE# line_number = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( current_file is None ) and ( current_file is None ) and ( line . startswith ( '+++' ) or line . startswith ( '---' ) ) ) : #NEWLINE# #INDENT# if line . startswith ( '+++ b/' ) : #NEWLINE# #INDENT# line = line . split ( '\t' ) [ 0 ] #NEWLINE# current_file = unicode ( line [ 6 : ] ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if line . startswith ( '@@' ) : #NEWLINE# #INDENT# line_num_info = line . split ( '+' ) [ 1 ] #NEWLINE# line_num_info = line_num_info . rstrip ( '@ ' ) #NEWLINE# line_number = ( int ( line_num_info . split ( ',' ) [ 0 ] ) - 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( current_file is not None ) and ( line_number is not None ) ) : #NEWLINE# #INDENT# if line . startswith ( '+' ) : #NEWLINE# #INDENT# cov = 'N' #NEWLINE# if ( current_file in coverage ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# cov = coverage [ current_file ] [ line_number ] #NEWLINE# #UNINDENT# except IndexError : #NEWLINE# #INDENT# logger = logging . getLogger ( 'coverage' ) #NEWLINE# logger . info ( ( 'Missing code coverage for line %d of file %s' % ( line_number , current_file ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# coverage_by_added_line . append ( cov ) #NEWLINE# #UNINDENT# if ( not line . startswith ( '-' ) ) : #NEWLINE# #INDENT# line_number += 1 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return coverage_by_added_line