This commit is contained in:
Marc Beninca 2024-09-14 02:47:52 +02:00
parent cc0b131a56
commit 4e369df232
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

View file

@ -52,18 +52,18 @@ def make_directory(path: Path) -> None:
path.mkdir(exist_ok=True, parents=True)
def read_file_bytes(file_path: str) -> bytes:
def read_file_bytes(file_path: Path) -> bytes:
"""Read whole file bytes."""
with Path(file_path).open("br") as file_object:
with file_path.open("br") as file_object:
return file_object.read()
def read_file_lines(file_path: str, charset: str = CHARSET) -> list[str]:
def read_file_lines(file_path: Path, charset: str = CHARSET) -> list[str]:
"""Read whole file lines."""
return read_file_text(file_path, charset).split(os.linesep)
def read_file_text(file_path: str, charset: str = CHARSET) -> str:
def read_file_text(file_path: Path, charset: str = CHARSET) -> str:
"""Read whole file text."""
return read_file_bytes(file_path).decode(charset)