INNER CODE UNIT · Python

read_normalized_text

uxlfoundation/oneDAL · dev/release_tests/compare_release_trees.py:447

def read_normalized_text(root, path):
    # `newline=""` keeps each line's own ending. Without it Python's universal
    # newline translation folds CRLF to LF, which would make the files listed in
    # NORMALIZED_TEXT_LINES the only released text files where a line-ending
    # difference is invisible -- every other one is compared byte for byte.
    # `Path.read_text` only grew a `newline` parameter in Python 3.13, and CI
    # still runs 3.12, so go through `open`.
    with (root / path).open(
        encoding="utf-8",
        errors="surrogateescape",
        newline="",
    ) as handle:
        content = handle.read()
    prefixes = NORMALIZED_TEXT_LINES.get(path, ())
    if not prefixes:
        return content
    normalized = []
    for line in content.splitlines(keepends=True):

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…