def print_file_diffs(self):
for name in self.diff_files:
if name.split('.') and name.split('.')[-1] in ['js', 'txt', 'html',
'json', 'css']:
d = difflib.Differ()
left_lines = open(os.path.join(self.left, name)).readlines()
right_lines = open(os.path.join(self.right, name)).readlines()
result = d.compare(left_lines, right_lines)
print("Diff between files {} and {}".format(
os.path.join(self.left, name),
os.path.join(self.right, name)))
print("")
sys.stdout.writelines(result)
else:
left_sha1 = hashlib.sha1(
open(os.path.join(self.left, name)).read()).hexdigest()
right_sha1 = hashlib.sha1(
open(os.path.join(self.right, name)).read()).hexdigest()
if left_sha1 != right_sha1:
print("Shasum mismatch between files {} and {}".format(
os.path.join(self.left, name),
os.path.join(self.right, name)))
for name in self.left_only:
print("Expected file {} not generated.".format(
os.path.join(self.left, name)))
for name in self.right_only:
print("Unexpected file {} generated.".format(
os.path.join(self.right, name)))
for name in self.funny_files:
print("Could not read the file {}".format(name))
评论列表
文章目录