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:
Sebastian Spaeth 2012-02-05 12:17:02 +01:00
parent 93f4a19778
commit 81fc20c7ca
7 changed files with 6 additions and 31 deletions

View File

@ -23,10 +23,7 @@ import os.path
import re
from sys import exc_info
import traceback
try: # python 2.6 has set() built in
set
except NameError:
from sets import Set as set
class BaseFolder(object):
def __init__(self, name, repository):

View File

@ -24,10 +24,6 @@ from sys import exc_info
from Base import BaseFolder
from offlineimap import imaputil, imaplibutil, OfflineImapError
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):

View File

@ -18,13 +18,10 @@
from Base import BaseFolder
import os
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"
class LocalStatusFolder(BaseFolder):
def __init__(self, name, repository):
self.sep = '.' #needs to be set before super.__init__()

View File

@ -23,10 +23,6 @@ try:
except:
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):
"""LocalStatus backend implemented with an SQLite database

View File

@ -19,6 +19,7 @@ import os
import fcntl
import re
import socket
import ssl
import time
import subprocess
import threading
@ -28,11 +29,6 @@ from offlineimap.ui import getglobalui
from offlineimap import OfflineImapError
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):
def getselectedfolder(self):

View File

@ -27,11 +27,7 @@ import time
import errno
from sys import exc_info
from socket import gaierror
try:
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
from ssl import SSLError, cert_time_to_seconds
try:
# do we have a recent pykerberos?
@ -323,7 +319,7 @@ class IMAPServer:
(self.hostname, self.repos)
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
# happens e.g. when connecting via SSL to a non-SSL service
if self.port != 993:

View File

@ -20,10 +20,7 @@ import re
import string
import types
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
quotere = re.compile(