summaryrefslogtreecommitdiff
path: root/fs/ftpfs.py
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ftpfs.py')
-rw-r--r--fs/ftpfs.py39
1 files changed, 7 insertions, 32 deletions
diff --git a/fs/ftpfs.py b/fs/ftpfs.py
index 8a32db5..830c119 100644
--- a/fs/ftpfs.py
+++ b/fs/ftpfs.py
@@ -804,40 +804,15 @@ class _FTPFile(object):
pass
self.closed = True
- def __iter__(self):
- return self.next()
-
- @synchronize
def next(self):
- """ Line iterator
+ return self.readline()
+
+ def readline(self, size=None):
+ return next(iotools.line_iterator(self, size))
+
+ def __iter__(self):
+ return iotools.line_iterator(self)
- This isn't terribly efficient. It would probably be better to do
- a read followed by splitlines.
- """
- endings = b('\r\n')
- chars = []
- append = chars.append
- read = self.read
- join = b('').join
- while True:
- char = read(1)
- if not char:
- if chars:
- yield join(chars)
- break
- append(char)
- if char in endings:
- line = join(chars)
- del chars[:]
- c = read(1)
- if not char:
- yield line
- break
- if c in endings and c != char:
- yield line + c
- else:
- yield line
- append(c)
def ftperrors(f):
@wraps(f)