From 094d66bc33fc39d344153db245192da6caf7c007 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 17 Sep 2024 23:23:38 +0200 Subject: [PATCH] doc/read_file_ --- rwx/fs/__init__.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 374a658..5767015 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -67,18 +67,37 @@ def make_directory(path: Path) -> None: def read_file_bytes(file_path: Path) -> bytes: - """Read whole file bytes.""" + """Read whole file bytes. + + :param file_path: source input file + :type file_path: Path + :rtype: bytes + """ with file_path.open("br") as file_object: return file_object.read() def read_file_lines(file_path: Path, charset: str = CHARSET) -> list[str]: - """Read whole file lines.""" + """Read whole file lines. + + :param file_path: source input file + :type file_path: Path + :param charset: charset to use for decoding input + :type charset: str + :rtype: list[str] + """ return read_file_text(file_path, charset).split(os.linesep) def read_file_text(file_path: Path, charset: str = CHARSET) -> str: - """Read whole file text.""" + """Read whole file text. + + :param file_path: source input file + :type file_path: Path + :param charset: charset to use for decoding input + :type charset: str + :rtype: str + """ return read_file_bytes(file_path).decode(charset)