six: changed offlineimap/folder/IMAP.py

This patch removes the library six, compatible with python2.

I need change these re-raise calls.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
This commit is contained in:
Rodolfo García Peñas (kix) 2020-09-03 20:53:33 +02:00
parent ba11b2d684
commit cefac73af4

View File

@ -20,8 +20,6 @@ import binascii
import re import re
import time import time
from sys import exc_info from sys import exc_info
import six
from offlineimap import imaputil, imaplibutil, emailutil, OfflineImapError from offlineimap import imaputil, imaplibutil, emailutil, OfflineImapError
from offlineimap import globals from offlineimap import globals
from imaplib2 import MonthNames from imaplib2 import MonthNames
@ -115,11 +113,10 @@ class IMAPFolder(BaseFolder):
def getmaxage(self): def getmaxage(self):
if self.config.getdefault("Account %s" % if self.config.getdefault("Account %s" %
self.accountname, "maxage", None): self.accountname, "maxage", None):
six.reraise(OfflineImapError, raise OfflineImapError(
OfflineImapError( "maxage is not supported on IMAP-IMAP sync",
"maxage is not supported on IMAP-IMAP sync", OfflineImapError.ERROR.REPO,
OfflineImapError.ERROR.REPO), exc_info()[2])
exc_info()[2])
# Interface from BaseFolder # Interface from BaseFolder
def getinstancelimitnamespace(self): def getinstancelimitnamespace(self):
@ -690,13 +687,14 @@ class IMAPFolder(BaseFolder):
self.imapserver.releaseconnection(imapobj, True) self.imapserver.releaseconnection(imapobj, True)
imapobj = self.imapserver.acquireconnection() imapobj = self.imapserver.acquireconnection()
if not retry_left: if not retry_left:
six.reraise(OfflineImapError, raise OfflineImapError(
OfflineImapError("Saving msg (%s) in folder '%s', " "Saving msg (%s) in folder '%s', "
"repository '%s' failed (abort). Server responded: %s\n" "repository '%s' failed (abort). Server responded: %s\n"
"Message content was: %s" % "Message content was: %s" %
(msg_id, self, self.getrepository(), str(e), dbg_output), (msg_id, self, self.getrepository(), str(e), dbg_output),
OfflineImapError.ERROR.MESSAGE), OfflineImapError.ERROR.MESSAGE,
exc_info()[2]) exc_info()[2])
# XXX: is this still needed? # XXX: is this still needed?
self.ui.error(e, exc_info()[2]) self.ui.error(e, exc_info()[2])
except imapobj.error as e: # APPEND failed except imapobj.error as e: # APPEND failed
@ -705,12 +703,13 @@ class IMAPFolder(BaseFolder):
# drop conn, it might be bad. # drop conn, it might be bad.
self.imapserver.releaseconnection(imapobj, True) self.imapserver.releaseconnection(imapobj, True)
imapobj = None imapobj = None
six.reraise(OfflineImapError, raise OfflineImapError(
OfflineImapError("Saving msg (%s) folder '%s', repo '%s'" "Saving msg (%s) folder '%s', repo '%s'"
"failed (error). Server responded: %s\nMessage content was: " "failed (error). Server responded: %s\nMessage content was: "
"%s" % (msg_id, self, self.getrepository(), str(e), dbg_output), "%s" % (msg_id, self, self.getrepository(), str(e), dbg_output),
OfflineImapError.ERROR.MESSAGE), OfflineImapError.ERROR.MESSAGE,
exc_info()[2]) exc_info()[2])
# Checkpoint. Let it write out stuff, etc. Eg searches for # Checkpoint. Let it write out stuff, etc. Eg searches for
# just uploaded messages won't work if we don't do this. # just uploaded messages won't work if we don't do this.
(typ, dat) = imapobj.check() (typ, dat) = imapobj.check()