diff options
author | Campus <campus@ntop.org> | 2017-07-27 13:12:12 +0200 |
---|---|---|
committer | Campus <campus@ntop.org> | 2017-07-27 13:12:12 +0200 |
commit | abf5bea425d5f8ce18c26e18046a0ef42d15a0a7 (patch) | |
tree | 82fc1b058d6b39f722507d23cdd6ba85e5d97ec2 /tests/line_diff.py | |
parent | e6b594a626e5cfb5cd0410336f8c1e12966a27cd (diff) | |
parent | 6ca6d968214d8c23ee9a31b0b5497a3ea24795e8 (diff) |
Merge branch 'MicahLyle-ssl-certificate-fix' into dev
Diffstat (limited to 'tests/line_diff.py')
-rwxr-xr-x | tests/line_diff.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/line_diff.py b/tests/line_diff.py new file mode 100755 index 000000000..1b42f1f2f --- /dev/null +++ b/tests/line_diff.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python +""" +line_diff.py - Simple tool that compares two files with the same number of lines and prints the +characters (if any) on the right line (moving left to right) that are present that +weren't present in the left line +""" + +import sys + +left_file = sys.argv[1] +right_file = sys.argv[2] + +left_lines = [] +right_lines = [] + +with open(left_file) as left: + for line in left.readlines(): + left_lines.append(line.strip()) +with open(right_file) as right: + for line in right.readlines(): + right_lines.append(line.strip()) + +if len(left_lines) != len(right_lines): + print("Files didn't have the same number of lines, exiting...") + sys.exit(0) + +for i in range(len(left_lines)): + left_contents = left_lines[i] + right_contents = right_lines[i] + if len(left_contents) > len(right_contents): + print("Line " + str(i) + " has longer left contents than right contents.") + print("Left contents: " + left_contents) + print("Right contents: " + right_contents) + break + else: + left_list = list(left_contents) + right_list = list(right_contents) + while len(left_list) > 0: + if right_list.pop(0) != left_list.pop(0): + print("Line " + str(i) + ": Right contents that are not a prefix of left contents.") + print("Left contents: " + left_contents) + print("Right contents: " + right_contents) + break + if len(right_list) > 0: + print("Line " + str(i) + ": Right contents have extra characters: " + ''.join(right_list)) |