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 <damien@micropython.org>
This commit is contained in:
Damien George 2022-10-27 13:36:20 +11:00
parent 3427e12e8f
commit 3ed017677b

View File

@ -143,6 +143,15 @@ class RemoteFile(uio.IOBase):
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()