PRESUBMIT.py Fix a couple incorrect usages of f.LocalPath()

LocalPath() should be used in error messages, but never when actually
trying to access a path. For this, you should use AbsoluteLocalPath.

Bug: 768962
Change-Id: I28cd31ca71c24234813bd90bec2be0cffe416777
Reviewed-on: https://chromium-review.googlesource.com/744461
Reviewed-by: Daniel Cheng <[email protected]>
Commit-Queue: agrieve <[email protected]>
Cr-Commit-Position: refs/heads/master@{#512601}
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index f74b057..77338a63 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -924,7 +924,7 @@
   args = [input_api.python_executable, checkperms_tool,
           '--root', input_api.change.RepositoryRoot()]
   for f in input_api.AffectedFiles():
-    args += ['--file', f.LocalPath()]
+    args += ['--file', f.AbsoluteLocalPath()]
   try:
     input_api.subprocess.check_output(args)
     return []
@@ -2669,20 +2669,13 @@
     r'.+%s' % _IMPLEMENTATION_EXTENSIONS
   )
 
-  filter = lambda f: input_api.FilterSourceFile(
-    f, white_list=file_inclusion_pattern, black_list=None)
-  files = [f.LocalPath() for f in
-           input_api.AffectedSourceFiles(filter)]
-
   problems = []
-
-  for file in files:
-    fp = open(file, 'r')
-    for line in fp:
+  source_file_filter = lambda f: input_api.FilterSourceFile(
+      f, white_list=file_inclusion_pattern, black_list=None)
+  for f in input_api.AffectedSourceFiles(source_file_filter):
+    for line_number, line in f.ChangedContents():
       if line.endswith('\r\n'):
-        problems.append(file)
-        break
-    fp.close()
+        problems.append(f.LocalPath())
 
   if problems:
     return [output_api.PresubmitPromptWarning('Are you sure that you want '