[PATCH 2/3] Move UsefulIMAPMixIn to imaplibutil.py
Vincent Beffara
vbeffara at ens-lyon.fr
Tue Mar 22 14:51:43 GMT 2011
Now that we do not need any system-specific hack, the three UsefulIMAP4
classes have become empty and should be removed. This implies importing
UsefulIMAPMixIn directly from the classes defined in imaplibutil.
Prepare this change by moving the code into imaplibutil.py. Functionally
this is a no-op.
Signed-off-by: Vincent Beffara <vbeffara at ens-lyon.fr>
---
offlineimap/imaplibutil.py | 27 +++++++++++++++++++++++++++
offlineimap/imapserver.py | 33 +++------------------------------
2 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/offlineimap/imaplibutil.py b/offlineimap/imaplibutil.py
index 4273d62..651eb71 100644
--- a/offlineimap/imaplibutil.py
+++ b/offlineimap/imaplibutil.py
@@ -32,6 +32,33 @@ except ImportError:
#fails on python <2.6
pass
+class UsefulIMAPMixIn:
+ def getstate(self):
+ return self.state
+ def getselectedfolder(self):
+ if self.getstate() == 'SELECTED':
+ return self.selectedfolder
+ return None
+
+ def select(self, mailbox='INBOX', readonly=None, force = 0):
+ if (not force) and self.getselectedfolder() == mailbox \
+ and self.is_readonly == readonly:
+ # No change; return.
+ return
+ # Wipe out all old responses, to maintain semantics with old imaplib2
+ del self.untagged_responses[:]
+ result = self.__class__.__bases__[1].select(self, mailbox, readonly)
+ if result[0] != 'OK':
+ raise ValueError, "Error from select: %s" % str(result)
+ if self.getstate() == 'SELECTED':
+ self.selectedfolder = mailbox
+ else:
+ self.selectedfolder = None
+ return result
+
+ def _mesg(self, s, tn=None, secs=None):
+ new_mesg(self, s, tn, secs)
+
class IMAP4_Tunnel(IMAP4):
"""IMAP4 client class over a tunnel
diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py
index fc7a503..96f0d1f 100644
--- a/offlineimap/imapserver.py
+++ b/offlineimap/imapserver.py
@@ -38,38 +38,11 @@ try:
except ImportError:
pass
-class UsefulIMAPMixIn:
- def getstate(self):
- return self.state
- def getselectedfolder(self):
- if self.getstate() == 'SELECTED':
- return self.selectedfolder
- return None
-
- def select(self, mailbox='INBOX', readonly=None, force = 0):
- if (not force) and self.getselectedfolder() == mailbox \
- and self.is_readonly == readonly:
- # No change; return.
- return
- # Wipe out all old responses, to maintain semantics with old imaplib2
- del self.untagged_responses[:]
- result = self.__class__.__bases__[1].select(self, mailbox, readonly)
- if result[0] != 'OK':
- raise ValueError, "Error from select: %s" % str(result)
- if self.getstate() == 'SELECTED':
- self.selectedfolder = mailbox
- else:
- self.selectedfolder = None
- return result
-
- def _mesg(self, s, tn=None, secs=None):
- imaplibutil.new_mesg(self, s, tn, secs)
-
-class UsefulIMAP4(UsefulIMAPMixIn, imaplibutil.WrappedIMAP4): pass
+class UsefulIMAP4(imaplibutil.UsefulIMAPMixIn, imaplibutil.WrappedIMAP4): pass
-class UsefulIMAP4_SSL(UsefulIMAPMixIn, imaplibutil.WrappedIMAP4_SSL): pass
+class UsefulIMAP4_SSL(imaplibutil.UsefulIMAPMixIn, imaplibutil.WrappedIMAP4_SSL): pass
-class UsefulIMAP4_Tunnel(UsefulIMAPMixIn, imaplibutil.IMAP4_Tunnel): pass
+class UsefulIMAP4_Tunnel(imaplibutil.UsefulIMAPMixIn, imaplibutil.IMAP4_Tunnel): pass
class IMAPServer:
GSS_STATE_STEP = 0
--
1.7.4.1
More information about the OfflineIMAP-project
mailing list