mypy/fs
This commit is contained in:
parent
cc0b131a56
commit
4e369df232
1 changed files with 4 additions and 4 deletions
|
@ -52,18 +52,18 @@ def make_directory(path: Path) -> None:
|
||||||
path.mkdir(exist_ok=True, parents=True)
|
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."""
|
"""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()
|
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."""
|
"""Read whole file lines."""
|
||||||
return read_file_text(file_path, charset).split(os.linesep)
|
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."""
|
"""Read whole file text."""
|
||||||
return read_file_bytes(file_path).decode(charset)
|
return read_file_bytes(file_path).decode(charset)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue