This repository serve as a backup for my Maxwell-TD code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

48 lines
1.3 KiB

#!/usr/bin/env python3
import sys
def compare_logs(file1, file2, N):
marker = "Local Time-Stepping Loop"
lines1, lines2 = [], []
# Find section in file1
with open(file1, "r") as f1:
for line in f1:
if marker in line:
# Skip marker line and break
break
# Read next N lines
for _ in range(N):
l = f1.readline()
if not l:
break
lines1.append(l.strip())
# Find section in file2
with open(file2, "r") as f2:
for line in f2:
if marker in line:
break
for _ in range(N):
l = f2.readline()
if not l:
break
lines2.append(l.strip())
# Compare
print(f"Comparing {len(lines1)} lines from {file1} with {len(lines2)} lines from {file2}:\n")
for i, (l1, l2) in enumerate(zip(lines1, lines2), start=1):
if l1 == l2:
print(f"Line {i}: SAME")
else:
print(f"Line {i}: DIFFERENT")
print(f" {file1}: {l1}")
print(f" {file2}: {l2}")
if __name__ == "__main__":
if len(sys.argv) != 4:
print(f"Usage: {sys.argv[0]} <file1> <file2> <N>")
sys.exit(1)
file1, file2, N = sys.argv[1], sys.argv[2], int(sys.argv[3])
compare_logs(file1, file2, N)