Remove python<2.6 import workarounds (set & ssl)
'set' is builtin since python2.6, so remove the imports. Also 'ssl' exists since 2.6 and has everything we need, so no need for conditional import tests here anymore. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
parent
93f4a19778
commit
81fc20c7ca
@ -23,10 +23,7 @@ import os.path
|
|||||||
import re
|
import re
|
||||||
from sys import exc_info
|
from sys import exc_info
|
||||||
import traceback
|
import traceback
|
||||||
try: # python 2.6 has set() built in
|
|
||||||
set
|
|
||||||
except NameError:
|
|
||||||
from sets import Set as set
|
|
||||||
|
|
||||||
class BaseFolder(object):
|
class BaseFolder(object):
|
||||||
def __init__(self, name, repository):
|
def __init__(self, name, repository):
|
||||||
|
@ -24,10 +24,6 @@ from sys import exc_info
|
|||||||
from Base import BaseFolder
|
from Base import BaseFolder
|
||||||
from offlineimap import imaputil, imaplibutil, OfflineImapError
|
from offlineimap import imaputil, imaplibutil, OfflineImapError
|
||||||
from offlineimap.imaplib2 import MonthNames
|
from offlineimap.imaplib2 import MonthNames
|
||||||
try: # python 2.6 has set() built in
|
|
||||||
set
|
|
||||||
except NameError:
|
|
||||||
from sets import Set as set
|
|
||||||
|
|
||||||
|
|
||||||
class IMAPFolder(BaseFolder):
|
class IMAPFolder(BaseFolder):
|
||||||
|
@ -18,13 +18,10 @@
|
|||||||
from Base import BaseFolder
|
from Base import BaseFolder
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
try: # python 2.6 has set() built in
|
|
||||||
set
|
|
||||||
except NameError:
|
|
||||||
from sets import Set as set
|
|
||||||
|
|
||||||
magicline = "OFFLINEIMAP LocalStatus CACHE DATA - DO NOT MODIFY - FORMAT 1"
|
magicline = "OFFLINEIMAP LocalStatus CACHE DATA - DO NOT MODIFY - FORMAT 1"
|
||||||
|
|
||||||
|
|
||||||
class LocalStatusFolder(BaseFolder):
|
class LocalStatusFolder(BaseFolder):
|
||||||
def __init__(self, name, repository):
|
def __init__(self, name, repository):
|
||||||
self.sep = '.' #needs to be set before super.__init__()
|
self.sep = '.' #needs to be set before super.__init__()
|
||||||
|
@ -23,10 +23,6 @@ try:
|
|||||||
except:
|
except:
|
||||||
pass #fail only if needed later on, not on import
|
pass #fail only if needed later on, not on import
|
||||||
|
|
||||||
try: # python 2.6 has set() built in
|
|
||||||
set
|
|
||||||
except NameError:
|
|
||||||
from sets import Set as set
|
|
||||||
|
|
||||||
class LocalStatusSQLiteFolder(LocalStatusFolder):
|
class LocalStatusSQLiteFolder(LocalStatusFolder):
|
||||||
"""LocalStatus backend implemented with an SQLite database
|
"""LocalStatus backend implemented with an SQLite database
|
||||||
|
@ -19,6 +19,7 @@ import os
|
|||||||
import fcntl
|
import fcntl
|
||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
|
import ssl
|
||||||
import time
|
import time
|
||||||
import subprocess
|
import subprocess
|
||||||
import threading
|
import threading
|
||||||
@ -28,11 +29,6 @@ from offlineimap.ui import getglobalui
|
|||||||
from offlineimap import OfflineImapError
|
from offlineimap import OfflineImapError
|
||||||
from offlineimap.imaplib2 import IMAP4, IMAP4_SSL, zlib, IMAP4_PORT, InternalDate, Mon2num
|
from offlineimap.imaplib2 import IMAP4, IMAP4_SSL, zlib, IMAP4_PORT, InternalDate, Mon2num
|
||||||
|
|
||||||
try:
|
|
||||||
import ssl
|
|
||||||
except ImportError:
|
|
||||||
#fails on python <2.6
|
|
||||||
pass
|
|
||||||
|
|
||||||
class UsefulIMAPMixIn(object):
|
class UsefulIMAPMixIn(object):
|
||||||
def getselectedfolder(self):
|
def getselectedfolder(self):
|
||||||
|
@ -27,11 +27,7 @@ import time
|
|||||||
import errno
|
import errno
|
||||||
from sys import exc_info
|
from sys import exc_info
|
||||||
from socket import gaierror
|
from socket import gaierror
|
||||||
try:
|
|
||||||
from ssl import SSLError, cert_time_to_seconds
|
from ssl import SSLError, cert_time_to_seconds
|
||||||
except ImportError:
|
|
||||||
# Protect against python<2.6, use dummy and won't get SSL errors.
|
|
||||||
SSLError = None
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# do we have a recent pykerberos?
|
# do we have a recent pykerberos?
|
||||||
@ -323,7 +319,7 @@ class IMAPServer:
|
|||||||
(self.hostname, self.repos)
|
(self.hostname, self.repos)
|
||||||
raise OfflineImapError(reason, severity)
|
raise OfflineImapError(reason, severity)
|
||||||
|
|
||||||
elif SSLError and isinstance(e, SSLError) and e.errno == 1:
|
elif isinstance(e, SSLError) and e.errno == 1:
|
||||||
# SSL unknown protocol error
|
# SSL unknown protocol error
|
||||||
# happens e.g. when connecting via SSL to a non-SSL service
|
# happens e.g. when connecting via SSL to a non-SSL service
|
||||||
if self.port != 993:
|
if self.port != 993:
|
||||||
|
@ -20,10 +20,7 @@ import re
|
|||||||
import string
|
import string
|
||||||
import types
|
import types
|
||||||
from offlineimap.ui import getglobalui
|
from offlineimap.ui import getglobalui
|
||||||
try: # python 2.6 has set() built in
|
|
||||||
set
|
|
||||||
except NameError:
|
|
||||||
from sets import Set as set
|
|
||||||
|
|
||||||
# find the first quote in a string
|
# find the first quote in a string
|
||||||
quotere = re.compile(
|
quotere = re.compile(
|
||||||
|
Loading…
Reference in New Issue
Block a user