parameters: (expected_path, actual_data)
return_statement: return '\n'.join(diff)
docstring: Check file contents for equality and return the diff or None.
docstring_summary: Check file contents for equality and return the diff or None.
docstring_tokens: Check file contents for equality and return the diff or None .
function: def _DiffFileContents(expected_path, actual_data):
    """Check file contents for equality and return the diff or None."""
    # Remove all trailing whitespace and add it explicitly in the end.
    with open(expected_path) as f_expected:
      expected_lines = [l.rstrip() for l in f_expected.readlines()]
    actual_lines = [
        _SkipOmitted(line).rstrip() for line in actual_data.splitlines()
    ]
  
    if expected_lines == actual_lines:
      return None
  
    expected_path = os.path.relpath(expected_path, build_utils.DIR_SOURCE_ROOT)
  
    diff = difflib.unified_diff(
        expected_lines,
        actual_lines,
        fromfile=os.path.join('before', expected_path),
        tofile=os.path.join('after', expected_path),
        n=0,
        lineterm='',
    )
  
    return '\n'.join(diff)
function_tokens: def _DiffFileContents ( expected_path , actual_data ) : # Remove all trailing whitespace and add it explicitly in the end. with open ( expected_path ) as f_expected : expected_lines = [ l . rstrip ( ) for l in f_expected . readlines ( ) ] actual_lines = [ _SkipOmitted ( line ) . rstrip ( ) for line in actual_data . splitlines ( ) ] if expected_lines == actual_lines : return None expected_path = os . path . relpath ( expected_path , build_utils . DIR_SOURCE_ROOT ) diff = difflib . unified_diff ( expected_lines , actual_lines , fromfile = os . path . join ( 'before' , expected_path ) , tofile = os . path . join ( 'after' , expected_path ) , n = 0 , lineterm = '' , ) return '\n' . join ( diff )