Move UsefulIMAPMixIn to imaplibutil.py
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@ens-lyon.fr> Reviewed-by: Sebastian Spaeth <Sebastian@SSpaeth.de> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
9a277cfd02
commit
9f03f41b70
@ -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
|
||||
|
||||
|
@ -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
|
||||
class UsefulIMAP4(imaplibutil.UsefulIMAPMixIn, imaplibutil.WrappedIMAP4): pass
|
||||
|
||||
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
|
||||
class UsefulIMAP4_SSL(imaplibutil.UsefulIMAPMixIn, imaplibutil.WrappedIMAP4_SSL): pass
|
||||
|
||||
def _mesg(self, s, tn=None, secs=None):
|
||||
imaplibutil.new_mesg(self, s, tn, secs)
|
||||
|
||||
class UsefulIMAP4(UsefulIMAPMixIn, imaplibutil.WrappedIMAP4): pass
|
||||
|
||||
class UsefulIMAP4_SSL(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
|
||||
|
Loading…
Reference in New Issue
Block a user