INNER CODE UNIT · Python
text_mismatch_diff
uxlfoundation/oneDAL · dev/release_tests/compare_release_trees.py:571
def text_mismatch_diff(make_root, bazel_root, path, context=1, max_lines=12):
"""Return a bounded unified diff of the two files, endings made visible."""
def read_lines(root):
raw = (root / path).read_bytes()
text = raw.decode("utf-8", errors="replace")
# Keep the endings and render them, so a CRLF/LF difference is legible
# instead of invisible.
return [
line.replace("\r", "<CR>").replace("\n", "<LF>")
for line in text.splitlines(keepends=True)
]
diff = difflib.unified_diff(
read_lines(make_root),
read_lines(bazel_root),
fromfile="make",
tofile="bazel",
n=context,