INNER CODE UNIT · Python
read
labsai/EDDI · scripts/bump-version.py:88
def read(path: Path) -> str:
# newline="" keeps CRLF as CRLF, so a rewrite changes only the version.
with path.open(encoding="utf-8", newline="") as f:
return f.read()
def write(path: Path, text: str) -> None:
with path.open("w", encoding="utf-8", newline="") as f:
f.write(text)
def lines_of(text: str) -> list[str]:
"""Lines split on "\\n" only, each keeping its terminator. str.splitlines()
also splits on form feeds and other separators Java's String.lines() does
not, which would number lines differently from ReleaseVersionSourceTest."""
return re.split(r"(?<=\n)", text)