From bb48b6deafc0b632bf718e4bbc557e69b3275fe9 Mon Sep 17 00:00:00 2001 From: Vincent Beffara Date: Tue, 22 Mar 2011 15:51:44 +0100 Subject: [PATCH] Get rid of the UsefulIMAP4 classes The three classes with names starting with UsefulIMAP4 were used for two purposes, to include the UsefulIMAPMixIn class and to implement various system-specific kludges. None of these kludges remain, so it is cleaner to include UsefulIMAPMixIn directly in imaplibutil and forget about them for good. Signed-off-by: Vincent Beffara Reviewed-by: Sebastian Spaeth Signed-off-by: Nicolas Sebrecht --- offlineimap/imaplibutil.py | 6 +++--- offlineimap/imapserver.py | 21 ++++++++------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/offlineimap/imaplibutil.py b/offlineimap/imaplibutil.py index 651eb71..14b11c2 100644 --- a/offlineimap/imaplibutil.py +++ b/offlineimap/imaplibutil.py @@ -59,7 +59,7 @@ class UsefulIMAPMixIn: def _mesg(self, s, tn=None, secs=None): new_mesg(self, s, tn, secs) -class IMAP4_Tunnel(IMAP4): +class IMAP4_Tunnel(UsefulIMAPMixIn, IMAP4): """IMAP4 client class over a tunnel Instantiate with: IMAP4_Tunnel(tunnelcmd) @@ -107,7 +107,7 @@ def new_mesg(self, s, tn=None, secs=None): tm = time.strftime('%M:%S', time.localtime(secs)) getglobalui().debug('imap', ' %s.%02d %s %s' % (tm, (secs*100)%100, tn, s)) -class WrappedIMAP4_SSL(IMAP4_SSL): +class WrappedIMAP4_SSL(UsefulIMAPMixIn, IMAP4_SSL): """Provides an improved version of the standard IMAP4_SSL It provides a better readline() implementation as impaplib's @@ -224,7 +224,7 @@ class WrappedIMAP4_SSL(IMAP4_SSL): return ('no matching domain name found in certificate') -class WrappedIMAP4(IMAP4): +class WrappedIMAP4(UsefulIMAPMixIn, IMAP4): """Improved version of imaplib.IMAP4 that can also connect to IPv6""" def open(self, host = '', port = IMAP4_PORT): diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py index 96f0d1f..c474a01 100644 --- a/offlineimap/imapserver.py +++ b/offlineimap/imapserver.py @@ -38,12 +38,6 @@ try: except ImportError: pass -class UsefulIMAP4(imaplibutil.UsefulIMAPMixIn, imaplibutil.WrappedIMAP4): pass - -class UsefulIMAP4_SSL(imaplibutil.UsefulIMAPMixIn, imaplibutil.WrappedIMAP4_SSL): pass - -class UsefulIMAP4_Tunnel(imaplibutil.UsefulIMAPMixIn, imaplibutil.IMAP4_Tunnel): pass - class IMAPServer: GSS_STATE_STEP = 0 GSS_STATE_WRAP = 1 @@ -202,18 +196,19 @@ class IMAPServer: # Generate a new connection. if self.tunnel: self.ui.connecting('tunnel', self.tunnel) - imapobj = UsefulIMAP4_Tunnel(self.tunnel, timeout=socket.getdefaulttimeout()) + imapobj = imaplibutil.IMAP4_Tunnel(self.tunnel, + timeout=socket.getdefaulttimeout()) success = 1 elif self.usessl: self.ui.connecting(self.hostname, self.port) - imapobj = UsefulIMAP4_SSL(self.hostname, self.port, - self.sslclientkey, self.sslclientcert, - timeout=socket.getdefaulttimeout(), - cacertfile = self.sslcacertfile) + imapobj = imaplibutil.WrappedIMAP4_SSL(self.hostname, self.port, + self.sslclientkey, self.sslclientcert, + timeout=socket.getdefaulttimeout(), + cacertfile = self.sslcacertfile) else: self.ui.connecting(self.hostname, self.port) - imapobj = UsefulIMAP4(self.hostname, self.port, - timeout=socket.getdefaulttimeout()) + imapobj = imaplibutil.WrappedIMAP4(self.hostname, self.port, + timeout=socket.getdefaulttimeout()) imapobj.mustquote = imaplibutil.mustquote