Skip to content

Commit 0a414a2

Browse files
committed
Add read_text_file function
1 parent 7fc4630 commit 0a414a2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

adafruit_shell.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,16 @@ def write_text_file(self, path, content, append=True):
543543
with open(self.path(path), mode, encoding="utf-8") as service_file:
544544
service_file.write(content)
545545

546+
def read_text_file(self, path):
547+
"""
548+
Read the contents of a file at the specified path
549+
"""
550+
path = self.path(path)
551+
if not os.path.exists(path):
552+
raise FileNotFoundError(f"File '{path}' does not exist")
553+
with open(path, "r", encoding="utf-8") as file:
554+
return file.read()
555+
546556
@staticmethod
547557
def is_python3():
548558
"Check if we are running Python 3 or later"

0 commit comments

Comments
 (0)