lint/fs
This commit is contained in:
parent
3e0d5bf2bc
commit
aa1f06c20f
1 changed files with 6 additions and 4 deletions
|
@ -56,15 +56,16 @@ def read_file(file_path: str):
|
|||
return file_object.read()
|
||||
|
||||
|
||||
def read_file_lines(file_path: str, charset=CHARSET):
|
||||
def read_file_lines(file_path: str, charset:str=CHARSET):
|
||||
return read_file_text(file_path).split(os.linesep)
|
||||
|
||||
|
||||
def read_file_text(file_path: str, charset=CHARSET):
|
||||
def read_file_text(file_path: str, charset:str=CHARSET):
|
||||
return read_file(file_path).decode(charset)
|
||||
|
||||
|
||||
def wipe(path: str):
|
||||
def wipe(path: str) -> None:
|
||||
"""Wipe provided path, whether directory or file."""
|
||||
try:
|
||||
shutil.rmtree(path)
|
||||
except NotADirectoryError:
|
||||
|
@ -73,6 +74,7 @@ def wipe(path: str):
|
|||
pass
|
||||
|
||||
|
||||
def write(file_path: str, text: str, charset=CHARSET):
|
||||
def write(file_path: str, text: str, charset:str=CHARSET) -> None:
|
||||
"""Write text into a file."""
|
||||
with open(file_path, "bw") as file_object:
|
||||
file_object.write(text.encode(charset))
|
||||
|
|
Loading…
Reference in a new issue