Add read_text_file function
This commit is contained in:
parent
7fc4630f1d
commit
0a414a2342
1 changed files with 10 additions and 0 deletions
|
|
@ -543,6 +543,16 @@ class Shell:
|
||||||
with open(self.path(path), mode, encoding="utf-8") as service_file:
|
with open(self.path(path), mode, encoding="utf-8") as service_file:
|
||||||
service_file.write(content)
|
service_file.write(content)
|
||||||
|
|
||||||
|
def read_text_file(self, path):
|
||||||
|
"""
|
||||||
|
Read the contents of a file at the specified path
|
||||||
|
"""
|
||||||
|
path = self.path(path)
|
||||||
|
if not os.path.exists(path):
|
||||||
|
raise FileNotFoundError(f"File '{path}' does not exist")
|
||||||
|
with open(path, "r", encoding="utf-8") as file:
|
||||||
|
return file.read()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_python3():
|
def is_python3():
|
||||||
"Check if we are running Python 3 or later"
|
"Check if we are running Python 3 or later"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue