[PATCH 05/13 v2] Remove obsolete read(), readline(), _read_upto() methods

Ethan Glasser-Camp ethan at betacantrips.com
Thu Mar 10 20:36:21 GMT 2011


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 <ethan at betacantrips.com>
---
This deletes the version of read() that is in current master.

 offlineimap/imaplibutil.py |   47 --------------------------------------------
 1 files changed, 0 insertions(+), 47 deletions(-)

diff --git a/offlineimap/imaplibutil.py b/offlineimap/imaplibutil.py
index 2a09208..18c0ff6 100644
--- a/offlineimap/imaplibutil.py
+++ b/offlineimap/imaplibutil.py
@@ -177,53 +177,6 @@ class WrappedIMAP4_SSL(IMAP4_SSL):
                 return ('certificate is for %s') % certname
         return ('no commonName 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"""
 
-- 
1.7.1





More information about the OfflineIMAP-project mailing list