From 197030da1aad3a4d5b0ae343fcf0feeced077e5d Mon Sep 17 00:00:00 2001 From: Ethan Glasser-Camp Date: Tue, 8 Mar 2011 10:05:18 -0500 Subject: [PATCH] Remove obsolete read(), readline(), _read_upto() methods For read(), the imaplib2 version seems to work perfectly well. The others aren't used any more, either by imaplib2, nor by us, so we may as well get rid of them. Signed-off-by: Ethan Glasser-Camp Signed-off-by: Nicolas Sebrecht --- offlineimap/imaplibutil.py | 47 -------------------------------------- 1 file changed, 47 deletions(-) diff --git a/offlineimap/imaplibutil.py b/offlineimap/imaplibutil.py index f902fce..3bd33ea 100644 --- a/offlineimap/imaplibutil.py +++ b/offlineimap/imaplibutil.py @@ -194,53 +194,6 @@ class WrappedIMAP4_SSL(IMAP4_SSL): return ('no matching domain name found in certificate') - def _read_upto (self, n): - """Read up to n bytes, emptying existing _readbuffer first""" - bytesfrombuf = min(n, len(self._readbuf)) - if bytesfrombuf: - # Return the stuff in readbuf, even if less than n. - # It might contain the rest of the line, and if we try to - # read more, might block waiting for data that is not - # coming to arrive. - retval = self._readbuf[:bytesfrombuf] - self._readbuf = self._readbuf[bytesfrombuf:] - return retval - return self.sslobj.read(min(n, 16384)) - - def read(self, n): - """Read exactly n bytes - - As done in IMAP4_SSL.read() API. If read returns less than n - bytes, things break left and right.""" - chunks = [] - read = 0 - while read < n: - data = self._read_upto (n-read) - if not data: - break - read += len(data) - chunks.append(data) - - return ''.join(chunks) - - def readline(self): - """Get the next line. This implementation is more efficient - than IMAP4_SSL.readline() which reads one char at a time and - reassembles the string by appending those chars. Uggh.""" - retval = '' - while 1: - linebuf = self._read_upto(1024) - if not linebuf: - return retval - nlindex = linebuf.find("\n") - if nlindex != -1: - retval += linebuf[:nlindex + 1] - self._readbuf = linebuf[nlindex + 1:] + self._readbuf - return retval - else: - retval += linebuf - - class WrappedIMAP4(IMAP4): """Improved version of imaplib.IMAP4 that can also connect to IPv6"""