Skip to content

Commit

Permalink
Feature 852 series by same name (#868)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgemccabe authored Apr 12, 2021
1 parent 02ff221 commit 4e3827c
Show file tree
Hide file tree
Showing 8 changed files with 848 additions and 530 deletions.
43 changes: 38 additions & 5 deletions ci/util/diff_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import numpy

IMAGE_EXTENSIONS = [
'.png',
'.jpg',
'.jpeg',
]
Expand All @@ -17,6 +16,7 @@

SKIP_EXTENSIONS = [
'.zip',
'.png',
]

PDF_EXTENSIONS = [
Expand Down Expand Up @@ -308,12 +308,43 @@ def compare_txt_files(filepath_a, filepath_b, dir_a=None, dir_b=None):
print("Comparing stat file")
header_a = lines_a.pop(0).split()[1:]
header_b = lines_b.pop(0).split()[1:]
else:
header_a = header_b = None

if len(lines_a) != len(lines_b):
print(f"ERROR: Different number of lines in {filepath_b}")
print(f" File_A: {len(lines_a)}\n File_B: {len(lines_b)}")
return False

all_good = diff_text_lines(lines_a,
lines_b,
dir_a=dir_a,
dir_b=dir_b,
print_error=False,
is_file_list=is_file_list,
is_stat_file=is_stat_file,
header_a=header_a)

# if differences found in text file, sort and try again
if not all_good:
lines_a.sort()
lines_b.sort()
all_good = diff_text_lines(lines_a,
lines_b,
dir_a=dir_a,
dir_b=dir_b,
print_error=True,
is_file_list=is_file_list,
is_stat_file=is_stat_file,
header_a=header_a)

return all_good

def diff_text_lines(lines_a, lines_b,
dir_a=None, dir_b=None,
print_error=False,
is_file_list=False, is_stat_file=False,
header_a=None):
all_good = True
for line_a, line_b in zip(lines_a, lines_b):
compare_a = line_a
Expand All @@ -331,12 +362,14 @@ def compare_txt_files(filepath_a, filepath_b, dir_a=None, dir_b=None):
cols_b = compare_b.split()[1:]
for col_a, col_b, label in zip(cols_a, cols_b, header_a):
if col_a != col_b:
print(f"ERROR: {label} differs:\n"
f" A: {col_a}\n B: {col_b}")
if print_error:
print(f"ERROR: {label} differs:\n"
f" A: {col_a}\n B: {col_b}")
all_good = False
else:
print(f"ERROR: Line in {filepath_b} differs\n"
f" A: {compare_a}\n B: {compare_b}")
if print_error:
print(f"ERROR: Line differs\n"
f" A: {compare_a}\n B: {compare_b}")
all_good = False

return all_good
Expand Down
Loading

0 comments on commit 4e3827c

Please sign in to comment.