This commit is contained in:
Marc Beninca 2024-09-13 17:13:37 +02:00
parent aa1f06c20f
commit 3393f09907
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F
2 changed files with 4 additions and 3 deletions

View file

@ -1,4 +1,5 @@
"""Handle errors.""" """Handle errors."""
class Error(Exception): class Error(Exception):
"""Parent class for all errors.""" """Parent class for all errors."""

View file

@ -56,11 +56,11 @@ def read_file(file_path: str):
return file_object.read() return file_object.read()
def read_file_lines(file_path: str, charset:str=CHARSET): def read_file_lines(file_path: str, charset: str = CHARSET):
return read_file_text(file_path).split(os.linesep) return read_file_text(file_path).split(os.linesep)
def read_file_text(file_path: str, charset:str=CHARSET): def read_file_text(file_path: str, charset: str = CHARSET):
return read_file(file_path).decode(charset) return read_file(file_path).decode(charset)
@ -74,7 +74,7 @@ def wipe(path: str) -> None:
pass pass
def write(file_path: str, text: str, charset:str=CHARSET) -> None: def write(file_path: str, text: str, charset: str = CHARSET) -> None:
"""Write text into a file.""" """Write text into a file."""
with open(file_path, "bw") as file_object: with open(file_path, "bw") as file_object:
file_object.write(text.encode(charset)) file_object.write(text.encode(charset))