From 0a414a23426d92dae5ff8d5eaa10cb426ddd13f0 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Wed, 6 Aug 2025 13:50:52 -0700 Subject: [PATCH] Add read_text_file function --- adafruit_shell.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/adafruit_shell.py b/adafruit_shell.py index fb67537..d33c502 100644 --- a/adafruit_shell.py +++ b/adafruit_shell.py @@ -543,6 +543,16 @@ class Shell: with open(self.path(path), mode, encoding="utf-8") as service_file: 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 def is_python3(): "Check if we are running Python 3 or later"