From 3ed017677b7a955098b51ebbabaa445ebc0a5bbd Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 27 Oct 2022 13:36:20 +1100 Subject: [PATCH] tools/mpremote: Make RemoteFile objects iterable. So that filesystems mounted with "mpremote mount" can have their files iterated over, making them consistent with other files. Signed-off-by: Damien George --- tools/mpremote/mpremote/pyboardextended.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/mpremote/mpremote/pyboardextended.py b/tools/mpremote/mpremote/pyboardextended.py index 075b95ae558e..dba8172b848a 100644 --- a/tools/mpremote/mpremote/pyboardextended.py +++ b/tools/mpremote/mpremote/pyboardextended.py @@ -143,6 +143,15 @@ def __enter__(self): def __exit__(self, a, b, c): self.close() + def __iter__(self): + return self + + def __next__(self): + l = self.readline() + if not l: + raise StopIteration + return l + def ioctl(self, request, arg): if request == 1: # FLUSH self.flush()