[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: output-distance: treat non-existent files as empty string (issue 583
From: |
hanwenn |
Subject: |
Re: output-distance: treat non-existent files as empty string (issue 583590043 by address@hidden) |
Date: |
Sat, 29 Feb 2020 04:49:11 -0800 |
Reviewers: hahnjo, Dan Eble,
Message:
On 2020/02/28 23:33:32, Dan Eble wrote:
> On 2020/02/28 23:31:17, Dan Eble wrote:
> > This does not look good. I expect this change to break the feature
I added in
> > 0d72930e579a5784ecb26da2f9880d8c9da05e71 (Issue 5635). Well, a call
to strip
> > (None) is possibly evidence that someone already broke it, but let's
at least
> > avoid making it worse.
> >
> > I don't believe you really want a validator to pretend that a
missing file
> > exists.
>
> [now with the "send mail" option checked]
done.
Description:
output-distance: treat non-existent files as empty string
This avoids callings strip() on None
Please review this at https://codereview.appspot.com/583590043/
Affected files (+5, -6 lines):
M scripts/build/output-distance.py
Index: scripts/build/output-distance.py
diff --git a/scripts/build/output-distance.py b/scripts/build/output-distance.py
index
b7a4dd61eb3526fb15a05b2f9ac9f93d8b348fcb..3e60d5f2dbea2336e17395bb74e1a87e74cdcb0a
100755
--- a/scripts/build/output-distance.py
+++ b/scripts/build/output-distance.py
@@ -6,6 +6,7 @@ import optparse
import os
import math
import re
+import difflib
import html
from functools import reduce
@@ -496,7 +497,7 @@ class FileCompareLink (FileLink):
return codecs.open (name, 'r', 'utf-8').read ()
except IOError as e:
if e.errno == errno.ENOENT:
- return None
+ return ""
else:
raise
@@ -529,8 +530,7 @@ class TextFileCompareLink (FileCompareLink):
# wants to see the content, he can click through the link.
self.diff_lines = []
return 100
-
- import difflib
+
# Extract the old and the new hashed snippet names from the log file
# and replace the old by the new, so file name changes don't show
# up as log differences...
@@ -569,7 +569,7 @@ class LogFileCompareLink (TextFileCompareLink):
class ProfileFileLink (FileCompareLink):
HEADINGS = ('time', 'cells')
-
+
def __init__ (self, f1, f2):
FileCompareLink.__init__ (self, f1, f2)
self.results = [{}, {}]
@@ -805,7 +805,7 @@ class SignatureFileLink (FileLink):
num_systems = (sum(1 for x in list(self.system_links.values ()) if
x.system1),
sum(1 for x in list(self.system_links.values ()) if
x.system2))
expect_compare = options.compare_images and num_systems[0] and oldnew
-
+
base = os.path.splitext (self.file_names[oldnew])[0]
if expect_compare:
@@ -1600,4 +1600,3 @@ def main ():
if __name__ == '__main__':
main ()
-