__version__ = _imapclient_version_string(version_info)
__author__ = 'Menno Smits <menno@freshfoo.com>'
-from imapclient import *
-from response_parser import *
-import imaplib_ssl_fix
+from .imapclient import *
+from .response_parser import *
+
+from .imaplib_ssl_fix import apply_patch
+apply_patch()
# Released subject to the New BSD License
# Please see http://en.wikipedia.org/wiki/BSD_licenses
+import imaplib
import select
import socket
import sys
from datetime import datetime
from operator import itemgetter
-import imaplib
-import response_lexer
-
+from . import response_lexer
try:
import oauth2
except ImportError:
oauth2 = None
-import imap_utf7
-from fixed_offset import FixedOffset
+from . import imap_utf7
+from .fixed_offset import FixedOffset
__all__ = ['IMAPClient', 'DELETED', 'SEEN', 'ANSWERED', 'FLAGGED', 'DRAFT', 'RECENT']
-from response_parser import parse_response, parse_fetch_response
+from .response_parser import parse_response, parse_fetch_response
# We also offer the gmail-specific XLIST command...
if 'XLIST' not in imaplib.Commands:
_fixed_readline.patched = True # Marker to indicate patched version
-
ssl_class = imaplib.IMAP4_SSL
-if _is_affected_version(sys.version_info) and not hasattr(ssl_class.readline, 'patched'):
- ssl_class.readline = _fixed_readline
+def apply_patch():
+ if _is_affected_version(sys.version_info) and not hasattr(ssl_class.readline, 'patched'):
+ ssl_class.readline = _fixed_readline
def __iter__(self):
return self.src
-
+
+CTRL_CHARS = ''.join([chr(ch) for ch in range(32)])
+SPECIALS = r' ()%"[' + CTRL_CHARS
+ALL_CHARS = [chr(ch) for ch in range(256)]
+NON_SPECIALS = frozenset([ch for ch in ALL_CHARS if ch not in SPECIALS])
+WHITESPACE = frozenset(' \t\r\n')
class Lexer(object):
"A lexical analyzer class for IMAP"
- CTRL_CHARS = ''.join([chr(ch) for ch in range(32)])
- SPECIALS = r' ()%"[' + CTRL_CHARS
- ALL_CHARS = [chr(ch) for ch in range(256)]
- NON_SPECIALS = frozenset([ch for ch in ALL_CHARS if ch not in SPECIALS])
- WHITESPACE = frozenset(' \t\r\n')
def __init__(self):
self.sources = None
return token + end_char
def read_token_stream(self, stream_i):
- whitespace = self.WHITESPACE
- wordchars = self.NON_SPECIALS
+ whitespace = WHITESPACE
+ wordchars = NON_SPECIALS
read_until = self.read_until
while True:
#TODO more exact error reporting
+import sys
from datetime import datetime
-from fixed_offset import FixedOffset
-from response_lexer import TokenSource
+
+from .fixed_offset import FixedOffset
+from .response_lexer import TokenSource
try:
import imaplib2 as imaplib
if not text:
return
src = TokenSource(text)
-
+
token = None
try:
for token in src:
yield atom(src, token)
except ParseError:
raise
- except ValueError, err:
+ except ValueError:
+ _, err, _ = sys.exc_info()
raise ParseError("%s: %s" % (str(err), token))