Back to index

python3.2  3.2.2
Classes | Functions | Variables
imaplib Namespace Reference

Classes

class  IMAP4_SSL
class  IMAP4_stream
class  _Authenticator

Functions

def __getattr__
def _create_socket
def open
def read
def readline
def send
def shutdown
def socket
def recent
def response
def append
def authenticate
def capability
def check
def close
def copy
def create
def delete
def deleteacl
def expunge
def fetch
def getacl
def getannotation
def getquota
def getquotaroot
def list
def login
def login_cram_md5
def _CRAM_MD5_AUTH
def logout
def lsub
def myrights
def namespace
def noop
def partial
def proxyauth
def rename
def search
def select
def setacl
def setannotation
def setquota
def sort
def starttls
def status
def store
def subscribe
def thread
def uid
def unsubscribe
def xatom
def _append_untagged
def _check_bye
def _command
def _command_complete
def _get_capabilities
def _get_response
def _get_tagged_response
def _get_line
def _match
def _new_tag
def _quote
def _simple_command
def _untagged_response
def _mesg
def _dump_ur
def _log
def print_log
def Internaldate2tuple
def Int2AP
def ParseFlags
def Time2Internaldate
def run

Variables

string __version__ = "2.58"
 HAVE_SSL = True
list __all__
string CRLF = '\r\n'
int Debug = 0
int IMAP4_PORT = 143
int IMAP4_SSL_PORT = 993
tuple AllowedVersions = ('IMAP4REV1', 'IMAP4')
dictionary Commands
tuple Continuation = re.compile(br'\+( (?P<data>.*))?')
tuple Flags = re.compile(br'.*FLAGS \((?P<flags>[^\)]*)\)
dictionary Mon2num
 stream_command = None
list host = args[0]
tuple USER = getpass.getuser()
tuple PASSWD = getpass.getpass("IMAP password for %s on %s: " % (USER, host or "localhost"))
string test_mesg = 'From: %(user)s@localhost%(lf)sSubject: IMAP4 test%(lf)s%(lf)sdata...%(lf)s'
tuple test_seq1
tuple test_seq2
tuple M = IMAP4_stream(stream_command)
tuple mo = re.match(r'.*"([^"]+)
 port
 sock
 file
 literal
 state
 password
 untagged_responses
 is_readonly
 _tls_established
 capabilities
 continuation_response
 tagnum
 _cmd_log_idx

Detailed Description

IMAP4 client.

Based on RFC 2060.

Public class:           IMAP4
Public variable:        Debug
Public functions:       Internaldate2tuple
                Int2AP
                ParseFlags
                Time2Internaldate

Function Documentation

def imaplib.__getattr__ (   self,
  attr 
)

Definition at line 224 of file imaplib.py.

00224 
00225     def __getattr__(self, attr):
00226         #       Allow UPPERCASE variants of IMAP4 command methods.
00227         if attr in Commands:
00228             return getattr(self, attr.lower())
00229         raise AttributeError("Unknown IMAP4 command: '%s'" % attr)
00230 
00231 

Here is the call graph for this function:

def imaplib._append_untagged (   self,
  typ,
  dat 
) [private]

Definition at line 847 of file imaplib.py.

00847 
00848     def _append_untagged(self, typ, dat):
00849         if dat is None:
00850             dat = b''
00851         ur = self.untagged_responses
00852         if __debug__:
00853             if self.debug >= 5:
00854                 self._mesg('untagged_responses[%s] %s += ["%r"]' %
00855                         (typ, len(ur.get(typ,'')), dat))
00856         if typ in ur:
00857             ur[typ].append(dat)
00858         else:
00859             ur[typ] = [dat]
00860 

Here is the call graph for this function:

def imaplib._check_bye (   self) [private]

Definition at line 861 of file imaplib.py.

00861 
00862     def _check_bye(self):
00863         bye = self.untagged_responses.get('BYE')
00864         if bye:
00865             raise self.abort(bye[-1].decode('ascii', 'replace'))
00866 

Here is the call graph for this function:

def imaplib._command (   self,
  name,
  args 
) [private]

Definition at line 867 of file imaplib.py.

00867 
00868     def _command(self, name, *args):
00869 
00870         if self.state not in Commands[name]:
00871             self.literal = None
00872             raise self.error("command %s illegal in state %s, "
00873                              "only allowed in states %s" %
00874                              (name, self.state,
00875                               ', '.join(Commands[name])))
00876 
00877         for typ in ('OK', 'NO', 'BAD'):
00878             if typ in self.untagged_responses:
00879                 del self.untagged_responses[typ]
00880 
00881         if 'READ-ONLY' in self.untagged_responses \
00882         and not self.is_readonly:
00883             raise self.readonly('mailbox status changed to READ-ONLY')
00884 
00885         tag = self._new_tag()
00886         name = bytes(name, 'ASCII')
00887         data = tag + b' ' + name
00888         for arg in args:
00889             if arg is None: continue
00890             if isinstance(arg, str):
00891                 arg = bytes(arg, "ASCII")
00892             data = data + b' ' + arg
00893 
00894         literal = self.literal
00895         if literal is not None:
00896             self.literal = None
00897             if type(literal) is type(self._command):
00898                 literator = literal
00899             else:
00900                 literator = None
00901                 data = data + bytes(' {%s}' % len(literal), 'ASCII')
00902 
00903         if __debug__:
00904             if self.debug >= 4:
00905                 self._mesg('> %r' % data)
00906             else:
00907                 self._log('> %r' % data)
00908 
00909         try:
00910             self.send(data + CRLF)
00911         except (socket.error, OSError) as val:
00912             raise self.abort('socket error: %s' % val)
00913 
00914         if literal is None:
00915             return tag
00916 
00917         while 1:
00918             # Wait for continuation response
00919 
00920             while self._get_response():
00921                 if self.tagged_commands[tag]:   # BAD/NO?
00922                     return tag
00923 
00924             # Send literal
00925 
00926             if literator:
00927                 literal = literator(self.continuation_response)
00928 
00929             if __debug__:
00930                 if self.debug >= 4:
00931                     self._mesg('write literal size %s' % len(literal))
00932 
00933             try:
00934                 self.send(literal)
00935                 self.send(CRLF)
00936             except (socket.error, OSError) as val:
00937                 raise self.abort('socket error: %s' % val)
00938 
00939             if not literator:
00940                 break
00941 
00942         return tag
00943 

def imaplib._command_complete (   self,
  name,
  tag 
) [private]

Definition at line 944 of file imaplib.py.

00944 
00945     def _command_complete(self, name, tag):
00946         # BYE is expected after LOGOUT
00947         if name != 'LOGOUT':
00948             self._check_bye()
00949         try:
00950             typ, data = self._get_tagged_response(tag)
00951         except self.abort as val:
00952             raise self.abort('command: %s => %s' % (name, val))
00953         except self.error as val:
00954             raise self.error('command: %s => %s' % (name, val))
00955         if name != 'LOGOUT':
00956             self._check_bye()
00957         if typ == 'BAD':
00958             raise self.error('%s command error: %s %s' % (name, typ, data))
00959         return typ, data
00960 

def imaplib._CRAM_MD5_AUTH (   self,
  challenge 
) [private]
Authobject to use with CRAM-MD5 authentication. 

Definition at line 546 of file imaplib.py.

00546 
00547     def _CRAM_MD5_AUTH(self, challenge):
00548         """ Authobject to use with CRAM-MD5 authentication. """
00549         import hmac
00550         return self.user + " " + hmac.HMAC(self.password, challenge).hexdigest()
00551 

def imaplib._create_socket (   self) [private]

Definition at line 235 of file imaplib.py.

00235 
00236     def _create_socket(self):
00237         return socket.create_connection((self.host, self.port))

Here is the call graph for this function:

def imaplib._dump_ur (   self,
  dict 
) [private]

Definition at line 1145 of file imaplib.py.

01145 
01146         def _dump_ur(self, dict):
01147             # Dump untagged responses (in `dict').
01148             l = dict.items()
01149             if not l: return
01150             t = '\n\t\t'
01151             l = map(lambda x:'%s: "%s"' % (x[0], x[1][0] and '" "'.join(x[1]) or ''), l)
01152             self._mesg('untagged responses dump:%s%s' % (t, t.join(l)))

def imaplib._get_capabilities (   self) [private]

Definition at line 961 of file imaplib.py.

00961 
00962     def _get_capabilities(self):
00963         typ, dat = self.capability()
00964         if dat == [None]:
00965             raise self.error('no CAPABILITY response from server')
00966         dat = str(dat[-1], "ASCII")
00967         dat = dat.upper()
00968         self.capabilities = tuple(dat.split())
00969 

def imaplib._get_line (   self) [private]

Definition at line 1072 of file imaplib.py.

01072 
01073     def _get_line(self):
01074 
01075         line = self.readline()
01076         if not line:
01077             raise self.abort('socket error: EOF')
01078 
01079         # Protocol mandates all lines terminated by CRLF
01080         if not line.endswith(b'\r\n'):
01081             raise self.abort('socket error: unterminated line')
01082 
01083         line = line[:-2]
01084         if __debug__:
01085             if self.debug >= 4:
01086                 self._mesg('< %r' % line)
01087             else:
01088                 self._log('< %r' % line)
01089         return line
01090 

def imaplib._get_response (   self) [private]

Definition at line 970 of file imaplib.py.

00970 
00971     def _get_response(self):
00972 
00973         # Read response and store.
00974         #
00975         # Returns None for continuation responses,
00976         # otherwise first response line received.
00977 
00978         resp = self._get_line()
00979 
00980         # Command completion response?
00981 
00982         if self._match(self.tagre, resp):
00983             tag = self.mo.group('tag')
00984             if not tag in self.tagged_commands:
00985                 raise self.abort('unexpected tagged response: %s' % resp)
00986 
00987             typ = self.mo.group('type')
00988             typ = str(typ, 'ASCII')
00989             dat = self.mo.group('data')
00990             self.tagged_commands[tag] = (typ, [dat])
00991         else:
00992             dat2 = None
00993 
00994             # '*' (untagged) responses?
00995 
00996             if not self._match(Untagged_response, resp):
00997                 if self._match(Untagged_status, resp):
00998                     dat2 = self.mo.group('data2')
00999 
01000             if self.mo is None:
01001                 # Only other possibility is '+' (continuation) response...
01002 
01003                 if self._match(Continuation, resp):
01004                     self.continuation_response = self.mo.group('data')
01005                     return None     # NB: indicates continuation
01006 
01007                 raise self.abort("unexpected response: '%s'" % resp)
01008 
01009             typ = self.mo.group('type')
01010             typ = str(typ, 'ascii')
01011             dat = self.mo.group('data')
01012             if dat is None: dat = b''        # Null untagged response
01013             if dat2: dat = dat + b' ' + dat2
01014 
01015             # Is there a literal to come?
01016 
01017             while self._match(Literal, dat):
01018 
01019                 # Read literal direct from connection.
01020 
01021                 size = int(self.mo.group('size'))
01022                 if __debug__:
01023                     if self.debug >= 4:
01024                         self._mesg('read literal size %s' % size)
01025                 data = self.read(size)
01026 
01027                 # Store response with literal as tuple
01028 
01029                 self._append_untagged(typ, (dat, data))
01030 
01031                 # Read trailer - possibly containing another literal
01032 
01033                 dat = self._get_line()
01034 
01035             self._append_untagged(typ, dat)
01036 
01037         # Bracketed response information?
01038 
01039         if typ in ('OK', 'NO', 'BAD') and self._match(Response_code, dat):
01040             typ = self.mo.group('type')
01041             typ = str(typ, "ASCII")
01042             self._append_untagged(typ, self.mo.group('data'))
01043 
01044         if __debug__:
01045             if self.debug >= 1 and typ in ('NO', 'BAD', 'BYE'):
01046                 self._mesg('%s response: %r' % (typ, dat))
01047 
01048         return resp
01049 

def imaplib._get_tagged_response (   self,
  tag 
) [private]

Definition at line 1050 of file imaplib.py.

01050 
01051     def _get_tagged_response(self, tag):
01052 
01053         while 1:
01054             result = self.tagged_commands[tag]
01055             if result is not None:
01056                 del self.tagged_commands[tag]
01057                 return result
01058 
01059             # Some have reported "unexpected response" exceptions.
01060             # Note that ignoring them here causes loops.
01061             # Instead, send me details of the unexpected response and
01062             # I'll update the code in `_get_response()'.
01063 
01064             try:
01065                 self._get_response()
01066             except self.abort as val:
01067                 if __debug__:
01068                     if self.debug >= 1:
01069                         self.print_log()
01070                 raise
01071 

def imaplib._log (   self,
  line 
) [private]

Definition at line 1153 of file imaplib.py.

01153 
01154         def _log(self, line):
01155             # Keep log of last `_cmd_log_len' interactions for debugging.
01156             self._cmd_log[self._cmd_log_idx] = (line, time.time())
01157             self._cmd_log_idx += 1
01158             if self._cmd_log_idx >= self._cmd_log_len:
01159                 self._cmd_log_idx = 0

Here is the caller graph for this function:

def imaplib._match (   self,
  cre,
  s 
) [private]

Definition at line 1091 of file imaplib.py.

01091 
01092     def _match(self, cre, s):
01093 
01094         # Run compiled regular expression match method on 's'.
01095         # Save result, return success.
01096 
01097         self.mo = cre.match(s)
01098         if __debug__:
01099             if self.mo is not None and self.debug >= 5:
01100                 self._mesg("\tmatched r'%r' => %r" % (cre.pattern, self.mo.groups()))
01101         return self.mo is not None
01102 

def imaplib._mesg (   self,
  s,
  secs = None 
) [private]

Definition at line 1138 of file imaplib.py.

01138 
01139         def _mesg(self, s, secs=None):
01140             if secs is None:
01141                 secs = time.time()
01142             tm = time.strftime('%M:%S', time.localtime(secs))
01143             sys.stderr.write('  %s.%02d %s\n' % (tm, (secs*100)%100, s))
01144             sys.stderr.flush()

def imaplib._new_tag (   self) [private]

Definition at line 1103 of file imaplib.py.

01103 
01104     def _new_tag(self):
01105 
01106         tag = self.tagpre + bytes(str(self.tagnum), 'ASCII')
01107         self.tagnum = self.tagnum + 1
01108         self.tagged_commands[tag] = None
01109         return tag
01110 

def imaplib._quote (   self,
  arg 
) [private]

Definition at line 1111 of file imaplib.py.

01111 
01112     def _quote(self, arg):
01113 
01114         arg = arg.replace('\\', '\\\\')
01115         arg = arg.replace('"', '\\"')
01116 
01117         return '"' + arg + '"'
01118 

def imaplib._simple_command (   self,
  name,
  args 
) [private]

Definition at line 1119 of file imaplib.py.

01119 
01120     def _simple_command(self, name, *args):
01121 
01122         return self._command_complete(name, self._command(name, *args))
01123 

def imaplib._untagged_response (   self,
  typ,
  dat,
  name 
) [private]

Definition at line 1124 of file imaplib.py.

01124 
01125     def _untagged_response(self, typ, dat, name):
01126         if typ == 'NO':
01127             return typ, dat
01128         if not name in self.untagged_responses:
01129             return typ, [None]
01130         data = self.untagged_responses.pop(name)
01131         if __debug__:
01132             if self.debug >= 5:
01133                 self._mesg('untagged_responses[%s] => %s' % (name, data))
01134         return typ, data
01135 

def imaplib.append (   self,
  mailbox,
  flags,
  date_time,
  message 
)
Append message to named mailbox.

(typ, [data]) = <instance>.append(mailbox, flags, date_time, message)

        All args except `message' can be None.

Definition at line 329 of file imaplib.py.

00329 
00330     def append(self, mailbox, flags, date_time, message):
00331         """Append message to named mailbox.
00332 
00333         (typ, [data]) = <instance>.append(mailbox, flags, date_time, message)
00334 
00335                 All args except `message' can be None.
00336         """
00337         name = 'APPEND'
00338         if not mailbox:
00339             mailbox = 'INBOX'
00340         if flags:
00341             if (flags[0],flags[-1]) != ('(',')'):
00342                 flags = '(%s)' % flags
00343         else:
00344             flags = None
00345         if date_time:
00346             date_time = Time2Internaldate(date_time)
00347         else:
00348             date_time = None
00349         self.literal = MapCRLF.sub(CRLF, message)
00350         return self._simple_command(name, mailbox, flags, date_time)
00351 

Here is the call graph for this function:

def imaplib.authenticate (   self,
  mechanism,
  authobject 
)
Authenticate command - requires response processing.

'mechanism' specifies which authentication mechanism is to
be used - it must appear in <instance>.capabilities in the
form AUTH=<mechanism>.

'authobject' must be a callable object:

        data = authobject(response)

It will be called to process server continuation responses.
It should return data that will be encoded and sent to server.
It should return None if the client abort response '*' should
be sent instead.

Definition at line 352 of file imaplib.py.

00352 
00353     def authenticate(self, mechanism, authobject):
00354         """Authenticate command - requires response processing.
00355 
00356         'mechanism' specifies which authentication mechanism is to
00357         be used - it must appear in <instance>.capabilities in the
00358         form AUTH=<mechanism>.
00359 
00360         'authobject' must be a callable object:
00361 
00362                 data = authobject(response)
00363 
00364         It will be called to process server continuation responses.
00365         It should return data that will be encoded and sent to server.
00366         It should return None if the client abort response '*' should
00367         be sent instead.
00368         """
00369         mech = mechanism.upper()
00370         # XXX: shouldn't this code be removed, not commented out?
00371         #cap = 'AUTH=%s' % mech
00372         #if not cap in self.capabilities:       # Let the server decide!
00373         #    raise self.error("Server doesn't allow %s authentication." % mech)
00374         self.literal = _Authenticator(authobject).process
00375         typ, dat = self._simple_command('AUTHENTICATE', mech)
00376         if typ != 'OK':
00377             raise self.error(dat[-1])
00378         self.state = 'AUTH'
00379         return typ, dat
00380 

def imaplib.capability (   self)
(typ, [data]) = <instance>.capability()
Fetch capabilities list from server.

Definition at line 381 of file imaplib.py.

00381 
00382     def capability(self):
00383         """(typ, [data]) = <instance>.capability()
00384         Fetch capabilities list from server."""
00385 
00386         name = 'CAPABILITY'
00387         typ, dat = self._simple_command(name)
00388         return self._untagged_response(typ, dat, name)
00389 

def imaplib.check (   self)
Checkpoint mailbox on server.

(typ, [data]) = <instance>.check()

Definition at line 390 of file imaplib.py.

00390 
00391     def check(self):
00392         """Checkpoint mailbox on server.
00393 
00394         (typ, [data]) = <instance>.check()
00395         """
00396         return self._simple_command('CHECK')
00397 

Here is the caller graph for this function:

def imaplib.close (   self)
Close currently selected mailbox.

Deleted messages are removed from writable mailbox.
This is the recommended command before 'LOGOUT'.

(typ, [data]) = <instance>.close()

Definition at line 398 of file imaplib.py.

00398 
00399     def close(self):
00400         """Close currently selected mailbox.
00401 
00402         Deleted messages are removed from writable mailbox.
00403         This is the recommended command before 'LOGOUT'.
00404 
00405         (typ, [data]) = <instance>.close()
00406         """
00407         try:
00408             typ, dat = self._simple_command('CLOSE')
00409         finally:
00410             self.state = 'AUTH'
00411         return typ, dat
00412 

def imaplib.copy (   self,
  message_set,
  new_mailbox 
)
Copy 'message_set' messages onto end of 'new_mailbox'.

(typ, [data]) = <instance>.copy(message_set, new_mailbox)

Definition at line 413 of file imaplib.py.

00413 
00414     def copy(self, message_set, new_mailbox):
00415         """Copy 'message_set' messages onto end of 'new_mailbox'.
00416 
00417         (typ, [data]) = <instance>.copy(message_set, new_mailbox)
00418         """
00419         return self._simple_command('COPY', message_set, new_mailbox)
00420 

def imaplib.create (   self,
  mailbox 
)
Create new mailbox.

(typ, [data]) = <instance>.create(mailbox)

Definition at line 421 of file imaplib.py.

00421 
00422     def create(self, mailbox):
00423         """Create new mailbox.
00424 
00425         (typ, [data]) = <instance>.create(mailbox)
00426         """
00427         return self._simple_command('CREATE', mailbox)
00428 

def imaplib.delete (   self,
  mailbox 
)
Delete old mailbox.

(typ, [data]) = <instance>.delete(mailbox)

Definition at line 429 of file imaplib.py.

00429 
00430     def delete(self, mailbox):
00431         """Delete old mailbox.
00432 
00433         (typ, [data]) = <instance>.delete(mailbox)
00434         """
00435         return self._simple_command('DELETE', mailbox)

Here is the caller graph for this function:

def imaplib.deleteacl (   self,
  mailbox,
  who 
)
Delete the ACLs (remove any rights) set for who on mailbox.

(typ, [data]) = <instance>.deleteacl(mailbox, who)

Definition at line 436 of file imaplib.py.

00436 
00437     def deleteacl(self, mailbox, who):
00438         """Delete the ACLs (remove any rights) set for who on mailbox.
00439 
00440         (typ, [data]) = <instance>.deleteacl(mailbox, who)
00441         """
00442         return self._simple_command('DELETEACL', mailbox, who)

def imaplib.expunge (   self)
Permanently remove deleted items from selected mailbox.

Generates 'EXPUNGE' response for each deleted message.

(typ, [data]) = <instance>.expunge()

'data' is list of 'EXPUNGE'd message numbers in order received.

Definition at line 443 of file imaplib.py.

00443 
00444     def expunge(self):
00445         """Permanently remove deleted items from selected mailbox.
00446 
00447         Generates 'EXPUNGE' response for each deleted message.
00448 
00449         (typ, [data]) = <instance>.expunge()
00450 
00451         'data' is list of 'EXPUNGE'd message numbers in order received.
00452         """
00453         name = 'EXPUNGE'
00454         typ, dat = self._simple_command(name)
00455         return self._untagged_response(typ, dat, name)
00456 

def imaplib.fetch (   self,
  message_set,
  message_parts 
)
Fetch (parts of) messages.

(typ, [data, ...]) = <instance>.fetch(message_set, message_parts)

'message_parts' should be a string of selected parts
enclosed in parentheses, eg: "(UID BODY[TEXT])".

'data' are tuples of message part envelope and data.

Definition at line 457 of file imaplib.py.

00457 
00458     def fetch(self, message_set, message_parts):
00459         """Fetch (parts of) messages.
00460 
00461         (typ, [data, ...]) = <instance>.fetch(message_set, message_parts)
00462 
00463         'message_parts' should be a string of selected parts
00464         enclosed in parentheses, eg: "(UID BODY[TEXT])".
00465 
00466         'data' are tuples of message part envelope and data.
00467         """
00468         name = 'FETCH'
00469         typ, dat = self._simple_command(name, message_set, message_parts)
00470         return self._untagged_response(typ, dat, name)
00471 

def imaplib.getacl (   self,
  mailbox 
)
Get the ACLs for a mailbox.

(typ, [data]) = <instance>.getacl(mailbox)

Definition at line 472 of file imaplib.py.

00472 
00473     def getacl(self, mailbox):
00474         """Get the ACLs for a mailbox.
00475 
00476         (typ, [data]) = <instance>.getacl(mailbox)
00477         """
00478         typ, dat = self._simple_command('GETACL', mailbox)
00479         return self._untagged_response(typ, dat, 'ACL')
00480 

def imaplib.getannotation (   self,
  mailbox,
  entry,
  attribute 
)
(typ, [data]) = <instance>.getannotation(mailbox, entry, attribute)
Retrieve ANNOTATIONs.

Definition at line 481 of file imaplib.py.

00481 
00482     def getannotation(self, mailbox, entry, attribute):
00483         """(typ, [data]) = <instance>.getannotation(mailbox, entry, attribute)
00484         Retrieve ANNOTATIONs."""
00485 
00486         typ, dat = self._simple_command('GETANNOTATION', mailbox, entry, attribute)
00487         return self._untagged_response(typ, dat, 'ANNOTATION')
00488 

def imaplib.getquota (   self,
  root 
)
Get the quota root's resource usage and limits.

Part of the IMAP4 QUOTA extension defined in rfc2087.

(typ, [data]) = <instance>.getquota(root)

Definition at line 489 of file imaplib.py.

00489 
00490     def getquota(self, root):
00491         """Get the quota root's resource usage and limits.
00492 
00493         Part of the IMAP4 QUOTA extension defined in rfc2087.
00494 
00495         (typ, [data]) = <instance>.getquota(root)
00496         """
00497         typ, dat = self._simple_command('GETQUOTA', root)
00498         return self._untagged_response(typ, dat, 'QUOTA')
00499 

def imaplib.getquotaroot (   self,
  mailbox 
)
Get the list of quota roots for the named mailbox.

(typ, [[QUOTAROOT responses...], [QUOTA responses]]) = <instance>.getquotaroot(mailbox)

Definition at line 500 of file imaplib.py.

00500 
00501     def getquotaroot(self, mailbox):
00502         """Get the list of quota roots for the named mailbox.
00503 
00504         (typ, [[QUOTAROOT responses...], [QUOTA responses]]) = <instance>.getquotaroot(mailbox)
00505         """
00506         typ, dat = self._simple_command('GETQUOTAROOT', mailbox)
00507         typ, quota = self._untagged_response(typ, dat, 'QUOTA')
00508         typ, quotaroot = self._untagged_response(typ, dat, 'QUOTAROOT')
00509         return typ, [quotaroot, quota]
00510 

def imaplib.Int2AP (   num)
Convert integer to A-P string representation.

Definition at line 1359 of file imaplib.py.

01359 
01360 def Int2AP(num):
01361 
01362     """Convert integer to A-P string representation."""
01363 
01364     val = b''; AP = b'ABCDEFGHIJKLMNOP'
01365     num = int(abs(num))
01366     while num:
01367         num, mod = divmod(num, 16)
01368         val = AP[mod:mod+1] + val
01369     return val
01370 
01371 

Here is the call graph for this function:

Parse an IMAP4 INTERNALDATE string.

Return corresponding local time.  The return value is a
time.struct_time tuple or None if the string has wrong format.

Definition at line 1314 of file imaplib.py.

01314 
01315 def Internaldate2tuple(resp):
01316     """Parse an IMAP4 INTERNALDATE string.
01317 
01318     Return corresponding local time.  The return value is a
01319     time.struct_time tuple or None if the string has wrong format.
01320     """
01321 
01322     mo = InternalDate.match(resp)
01323     if not mo:
01324         return None
01325 
01326     mon = Mon2num[mo.group('mon')]
01327     zonen = mo.group('zonen')
01328 
01329     day = int(mo.group('day'))
01330     year = int(mo.group('year'))
01331     hour = int(mo.group('hour'))
01332     min = int(mo.group('min'))
01333     sec = int(mo.group('sec'))
01334     zoneh = int(mo.group('zoneh'))
01335     zonem = int(mo.group('zonem'))
01336 
01337     # INTERNALDATE timezone must be subtracted to get UT
01338 
01339     zone = (zoneh*60 + zonem)*60
01340     if zonen == b'-':
01341         zone = -zone
01342 
01343     tt = (year, mon, day, hour, min, sec, -1, -1, -1)
01344 
01345     utc = time.mktime(tt)
01346 
01347     # Following is necessary because the time module has no 'mkgmtime'.
01348     # 'mktime' assumes arg in local timezone, so adds timezone/altzone.
01349 
01350     lt = time.localtime(utc)
01351     if time.daylight and lt[-1]:
01352         zone = zone + time.altzone
01353     else:
01354         zone = zone + time.timezone
01355 
01356     return time.localtime(utc - zone)
01357 
01358 

Here is the caller graph for this function:

def imaplib.list (   self,
  directory = '""',
  pattern = '*' 
)
List mailbox names in directory matching pattern.

(typ, [data]) = <instance>.list(directory='""', pattern='*')

'data' is list of LIST responses.

Definition at line 511 of file imaplib.py.

00511 
00512     def list(self, directory='""', pattern='*'):
00513         """List mailbox names in directory matching pattern.
00514 
00515         (typ, [data]) = <instance>.list(directory='""', pattern='*')
00516 
00517         'data' is list of LIST responses.
00518         """
00519         name = 'LIST'
00520         typ, dat = self._simple_command(name, directory, pattern)
00521         return self._untagged_response(typ, dat, name)
00522 

def imaplib.login (   self,
  user,
  password 
)
Identify client using plaintext password.

(typ, [data]) = <instance>.login(user, password)

NB: 'password' will be quoted.

Definition at line 523 of file imaplib.py.

00523 
00524     def login(self, user, password):
00525         """Identify client using plaintext password.
00526 
00527         (typ, [data]) = <instance>.login(user, password)
00528 
00529         NB: 'password' will be quoted.
00530         """
00531         typ, dat = self._simple_command('LOGIN', user, self._quote(password))
00532         if typ != 'OK':
00533             raise self.error(dat[-1])
00534         self.state = 'AUTH'
00535         return typ, dat
00536 

def imaplib.login_cram_md5 (   self,
  user,
  password 
)
Force use of CRAM-MD5 authentication.

(typ, [data]) = <instance>.login_cram_md5(user, password)

Definition at line 537 of file imaplib.py.

00537 
00538     def login_cram_md5(self, user, password):
00539         """ Force use of CRAM-MD5 authentication.
00540 
00541         (typ, [data]) = <instance>.login_cram_md5(user, password)
00542         """
00543         self.user, self.password = user, password
00544         return self.authenticate('CRAM-MD5', self._CRAM_MD5_AUTH)
00545 

def imaplib.logout (   self)
Shutdown connection to server.

(typ, [data]) = <instance>.logout()

Returns server 'BYE' response.

Definition at line 552 of file imaplib.py.

00552 
00553     def logout(self):
00554         """Shutdown connection to server.
00555 
00556         (typ, [data]) = <instance>.logout()
00557 
00558         Returns server 'BYE' response.
00559         """
00560         self.state = 'LOGOUT'
00561         try: typ, dat = self._simple_command('LOGOUT')
00562         except: typ, dat = 'NO', ['%s: %s' % sys.exc_info()[:2]]
00563         self.shutdown()
00564         if 'BYE' in self.untagged_responses:
00565             return 'BYE', self.untagged_responses['BYE']
00566         return typ, dat
00567 

def imaplib.lsub (   self,
  directory = '""',
  pattern = '*' 
)
List 'subscribed' mailbox names in directory matching pattern.

(typ, [data, ...]) = <instance>.lsub(directory='""', pattern='*')

'data' are tuples of message part envelope and data.

Definition at line 568 of file imaplib.py.

00568 
00569     def lsub(self, directory='""', pattern='*'):
00570         """List 'subscribed' mailbox names in directory matching pattern.
00571 
00572         (typ, [data, ...]) = <instance>.lsub(directory='""', pattern='*')
00573 
00574         'data' are tuples of message part envelope and data.
00575         """
00576         name = 'LSUB'
00577         typ, dat = self._simple_command(name, directory, pattern)
00578         return self._untagged_response(typ, dat, name)

def imaplib.myrights (   self,
  mailbox 
)
Show my ACLs for a mailbox (i.e. the rights that I have on mailbox).

(typ, [data]) = <instance>.myrights(mailbox)

Definition at line 579 of file imaplib.py.

00579 
00580     def myrights(self, mailbox):
00581         """Show my ACLs for a mailbox (i.e. the rights that I have on mailbox).
00582 
00583         (typ, [data]) = <instance>.myrights(mailbox)
00584         """
00585         typ,dat = self._simple_command('MYRIGHTS', mailbox)
00586         return self._untagged_response(typ, dat, 'MYRIGHTS')

def imaplib.namespace (   self)
Returns IMAP namespaces ala rfc2342

(typ, [data, ...]) = <instance>.namespace()

Definition at line 587 of file imaplib.py.

00587 
00588     def namespace(self):
00589         """ Returns IMAP namespaces ala rfc2342
00590 
00591         (typ, [data, ...]) = <instance>.namespace()
00592         """
00593         name = 'NAMESPACE'
00594         typ, dat = self._simple_command(name)
00595         return self._untagged_response(typ, dat, name)
00596 

def imaplib.noop (   self)
Send NOOP command.

(typ, [data]) = <instance>.noop()

Definition at line 597 of file imaplib.py.

00597 
00598     def noop(self):
00599         """Send NOOP command.
00600 
00601         (typ, [data]) = <instance>.noop()
00602         """
00603         if __debug__:
00604             if self.debug >= 3:
00605                 self._dump_ur(self.untagged_responses)
00606         return self._simple_command('NOOP')
00607 

def imaplib.open (   self,
  host = '',
  port = IMAP4_PORT 
)
Setup connection to remote server on "host:port"
    (default: localhost:standard IMAP4 port).
This connection will be used by the routines:
    read, readline, send, shutdown.

Definition at line 238 of file imaplib.py.

00238 
00239     def open(self, host = '', port = IMAP4_PORT):
00240         """Setup connection to remote server on "host:port"
00241             (default: localhost:standard IMAP4 port).
00242         This connection will be used by the routines:
00243             read, readline, send, shutdown.
00244         """
00245         self.host = host
00246         self.port = port
00247         self.sock = self._create_socket()
00248         self.file = self.sock.makefile('rb')
00249 

def imaplib.ParseFlags (   resp)
Convert IMAP4 flags response to python tuple.

Definition at line 1372 of file imaplib.py.

01372 
01373 def ParseFlags(resp):
01374 
01375     """Convert IMAP4 flags response to python tuple."""
01376 
01377     mo = Flags.match(resp)
01378     if not mo:
01379         return ()
01380 
01381     return tuple(mo.group('flags').split())
01382 

Here is the call graph for this function:

def imaplib.partial (   self,
  message_num,
  message_part,
  start,
  length 
)
Fetch truncated part of a message.

(typ, [data, ...]) = <instance>.partial(message_num, message_part, start, length)

'data' is tuple of message part envelope and data.

Definition at line 608 of file imaplib.py.

00608 
00609     def partial(self, message_num, message_part, start, length):
00610         """Fetch truncated part of a message.
00611 
00612         (typ, [data, ...]) = <instance>.partial(message_num, message_part, start, length)
00613 
00614         'data' is tuple of message part envelope and data.
00615         """
00616         name = 'PARTIAL'
00617         typ, dat = self._simple_command(name, message_num, message_part, start, length)
00618         return self._untagged_response(typ, dat, 'FETCH')
00619 

Here is the caller graph for this function:

def imaplib.print_log (   self)

Definition at line 1160 of file imaplib.py.

01160 
01161         def print_log(self):
01162             self._mesg('last %d IMAP4 interactions:' % len(self._cmd_log))
01163             i, n = self._cmd_log_idx, self._cmd_log_len
01164             while n:
01165                 try:
01166                     self._mesg(*self._cmd_log[i])
01167                 except:
01168                     pass
01169                 i += 1
01170                 if i >= self._cmd_log_len:
01171                     i = 0
01172                 n -= 1
01173 

def imaplib.proxyauth (   self,
  user 
)
Assume authentication as "user".

Allows an authorised administrator to proxy into any user's
mailbox.

(typ, [data]) = <instance>.proxyauth(user)

Definition at line 620 of file imaplib.py.

00620 
00621     def proxyauth(self, user):
00622         """Assume authentication as "user".
00623 
00624         Allows an authorised administrator to proxy into any user's
00625         mailbox.
00626 
00627         (typ, [data]) = <instance>.proxyauth(user)
00628         """
00629 
00630         name = 'PROXYAUTH'
00631         return self._simple_command('PROXYAUTH', user)
00632 

def imaplib.read (   self,
  size 
)
Read 'size' bytes from remote.

Definition at line 250 of file imaplib.py.

00250 
00251     def read(self, size):
00252         """Read 'size' bytes from remote."""
00253         chunks = []
00254         read = 0
00255         while read < size:
00256             data = self.file.read(min(size-read, 4096))
00257             if not data:
00258                 break
00259             read += len(data)
00260             chunks.append(data)
00261         return b''.join(chunks)
00262 

def imaplib.readline (   self)
Read line from remote.

Definition at line 263 of file imaplib.py.

00263 
00264     def readline(self):
00265         """Read line from remote."""
00266         return self.file.readline()
00267 

def imaplib.recent (   self)
Return most recent 'RECENT' responses if any exist,
else prompt server for an update using the 'NOOP' command.

(typ, [data]) = <instance>.recent()

'data' is None if no new messages,
else list of RECENT responses, most recent last.

Definition at line 298 of file imaplib.py.

00298 
00299     def recent(self):
00300         """Return most recent 'RECENT' responses if any exist,
00301         else prompt server for an update using the 'NOOP' command.
00302 
00303         (typ, [data]) = <instance>.recent()
00304 
00305         'data' is None if no new messages,
00306         else list of RECENT responses, most recent last.
00307         """
00308         name = 'RECENT'
00309         typ, dat = self._untagged_response('OK', [None], name)
00310         if dat[-1]:
00311             return typ, dat
00312         typ, dat = self.noop()  # Prod server for response
00313         return self._untagged_response(typ, dat, name)
00314 

def imaplib.rename (   self,
  oldmailbox,
  newmailbox 
)
Rename old mailbox name to new.

(typ, [data]) = <instance>.rename(oldmailbox, newmailbox)

Definition at line 633 of file imaplib.py.

00633 
00634     def rename(self, oldmailbox, newmailbox):
00635         """Rename old mailbox name to new.
00636 
00637         (typ, [data]) = <instance>.rename(oldmailbox, newmailbox)
00638         """
00639         return self._simple_command('RENAME', oldmailbox, newmailbox)
00640 

def imaplib.response (   self,
  code 
)
Return data for response 'code' if received, or None.

Old value for response 'code' is cleared.

(code, [data]) = <instance>.response(code)

Definition at line 315 of file imaplib.py.

00315 
00316     def response(self, code):
00317         """Return data for response 'code' if received, or None.
00318 
00319         Old value for response 'code' is cleared.
00320 
00321         (code, [data]) = <instance>.response(code)
00322         """
00323         return self._untagged_response(code, [None], code.upper())
00324 
00325 

Here is the caller graph for this function:

def imaplib.run (   cmd,
  args 
)

Definition at line 1471 of file imaplib.py.

01471 
01472     def run(cmd, args):
01473         M._mesg('%s %s' % (cmd, args))
01474         typ, dat = getattr(M, cmd)(*args)
01475         M._mesg('%s => %s %s' % (cmd, typ, dat))
01476         if typ == 'NO': raise dat[0]
01477         return dat

Here is the call graph for this function:

def imaplib.search (   self,
  charset,
  criteria 
)
Search mailbox for matching messages.

(typ, [data]) = <instance>.search(charset, criterion, ...)

'data' is space separated list of matching message numbers.

Definition at line 641 of file imaplib.py.

00641 
00642     def search(self, charset, *criteria):
00643         """Search mailbox for matching messages.
00644 
00645         (typ, [data]) = <instance>.search(charset, criterion, ...)
00646 
00647         'data' is space separated list of matching message numbers.
00648         """
00649         name = 'SEARCH'
00650         if charset:
00651             typ, dat = self._simple_command(name, 'CHARSET', charset, *criteria)
00652         else:
00653             typ, dat = self._simple_command(name, *criteria)
00654         return self._untagged_response(typ, dat, name)
00655 

def imaplib.select (   self,
  mailbox = 'INBOX',
  readonly = False 
)
Select a mailbox.

Flush all untagged responses.

(typ, [data]) = <instance>.select(mailbox='INBOX', readonly=False)

'data' is count of messages in mailbox ('EXISTS' response).

Mandated responses are ('FLAGS', 'EXISTS', 'RECENT', 'UIDVALIDITY'), so
other responses should be obtained via <instance>.response('FLAGS') etc.

Definition at line 656 of file imaplib.py.

00656 
00657     def select(self, mailbox='INBOX', readonly=False):
00658         """Select a mailbox.
00659 
00660         Flush all untagged responses.
00661 
00662         (typ, [data]) = <instance>.select(mailbox='INBOX', readonly=False)
00663 
00664         'data' is count of messages in mailbox ('EXISTS' response).
00665 
00666         Mandated responses are ('FLAGS', 'EXISTS', 'RECENT', 'UIDVALIDITY'), so
00667         other responses should be obtained via <instance>.response('FLAGS') etc.
00668         """
00669         self.untagged_responses = {}    # Flush old responses.
00670         self.is_readonly = readonly
00671         if readonly:
00672             name = 'EXAMINE'
00673         else:
00674             name = 'SELECT'
00675         typ, dat = self._simple_command(name, mailbox)
00676         if typ != 'OK':
00677             self.state = 'AUTH'     # Might have been 'SELECTED'
00678             return typ, dat
00679         self.state = 'SELECTED'
00680         if 'READ-ONLY' in self.untagged_responses \
00681                 and not readonly:
00682             if __debug__:
00683                 if self.debug >= 1:
00684                     self._dump_ur(self.untagged_responses)
00685             raise self.readonly('%s is not writable' % mailbox)
00686         return typ, self.untagged_responses.get('EXISTS', [None])
00687 

Here is the caller graph for this function:

def imaplib.send (   self,
  data 
)
Send data to remote.

Definition at line 268 of file imaplib.py.

00268 
00269     def send(self, data):
00270         """Send data to remote."""
00271         self.sock.sendall(data)
00272 

def imaplib.setacl (   self,
  mailbox,
  who,
  what 
)
Set a mailbox acl.

(typ, [data]) = <instance>.setacl(mailbox, who, what)

Definition at line 688 of file imaplib.py.

00688 
00689     def setacl(self, mailbox, who, what):
00690         """Set a mailbox acl.
00691 
00692         (typ, [data]) = <instance>.setacl(mailbox, who, what)
00693         """
00694         return self._simple_command('SETACL', mailbox, who, what)
00695 

def imaplib.setannotation (   self,
  args 
)
(typ, [data]) = <instance>.setannotation(mailbox[, entry, attribute]+)
Set ANNOTATIONs.

Definition at line 696 of file imaplib.py.

00696 
00697     def setannotation(self, *args):
00698         """(typ, [data]) = <instance>.setannotation(mailbox[, entry, attribute]+)
00699         Set ANNOTATIONs."""
00700 
00701         typ, dat = self._simple_command('SETANNOTATION', *args)
00702         return self._untagged_response(typ, dat, 'ANNOTATION')
00703 

def imaplib.setquota (   self,
  root,
  limits 
)
Set the quota root's resource limits.

(typ, [data]) = <instance>.setquota(root, limits)

Definition at line 704 of file imaplib.py.

00704 
00705     def setquota(self, root, limits):
00706         """Set the quota root's resource limits.
00707 
00708         (typ, [data]) = <instance>.setquota(root, limits)
00709         """
00710         typ, dat = self._simple_command('SETQUOTA', root, limits)
00711         return self._untagged_response(typ, dat, 'QUOTA')
00712 

def imaplib.shutdown (   self)
Close I/O established in "open".

Definition at line 273 of file imaplib.py.

00273 
00274     def shutdown(self):
00275         """Close I/O established in "open"."""
00276         self.file.close()
00277         try:
00278             self.sock.shutdown(socket.SHUT_RDWR)
00279         except socket.error as e:
00280             # The server might already have closed the connection
00281             if e.errno != errno.ENOTCONN:
00282                 raise
00283         finally:
00284             self.sock.close()
00285 

Here is the caller graph for this function:

def imaplib.socket (   self)
Return socket instance used to connect to IMAP4 server.

socket = <instance>.socket()

Definition at line 286 of file imaplib.py.

00286 
00287     def socket(self):
00288         """Return socket instance used to connect to IMAP4 server.
00289 
00290         socket = <instance>.socket()
00291         """
00292         return self.sock
00293 
00294 

Here is the caller graph for this function:

def imaplib.sort (   self,
  sort_criteria,
  charset,
  search_criteria 
)
IMAP4rev1 extension SORT command.

(typ, [data]) = <instance>.sort(sort_criteria, charset, search_criteria, ...)

Definition at line 713 of file imaplib.py.

00713 
00714     def sort(self, sort_criteria, charset, *search_criteria):
00715         """IMAP4rev1 extension SORT command.
00716 
00717         (typ, [data]) = <instance>.sort(sort_criteria, charset, search_criteria, ...)
00718         """
00719         name = 'SORT'
00720         #if not name in self.capabilities:      # Let the server decide!
00721         #       raise self.error('unimplemented extension command: %s' % name)
00722         if (sort_criteria[0],sort_criteria[-1]) != ('(',')'):
00723             sort_criteria = '(%s)' % sort_criteria
00724         typ, dat = self._simple_command(name, sort_criteria, charset, *search_criteria)
00725         return self._untagged_response(typ, dat, name)
00726 

def imaplib.starttls (   self,
  ssl_context = None 
)

Definition at line 727 of file imaplib.py.

00727 
00728     def starttls(self, ssl_context=None):
00729         name = 'STARTTLS'
00730         if not HAVE_SSL:
00731             raise self.error('SSL support missing')
00732         if self._tls_established:
00733             raise self.abort('TLS session already established')
00734         if name not in self.capabilities:
00735             raise self.abort('TLS not supported by server')
00736         # Generate a default SSL context if none was passed.
00737         if ssl_context is None:
00738             ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
00739             # SSLv2 considered harmful.
00740             ssl_context.options |= ssl.OP_NO_SSLv2
00741         typ, dat = self._simple_command(name)
00742         if typ == 'OK':
00743             self.sock = ssl_context.wrap_socket(self.sock)
00744             self.file = self.sock.makefile('rb')
00745             self._tls_established = True
00746             self._get_capabilities()
00747         else:
00748             raise self.error("Couldn't establish TLS session")
00749         return self._untagged_response(typ, dat, name)
00750 

def imaplib.status (   self,
  mailbox,
  names 
)
Request named status conditions for mailbox.

(typ, [data]) = <instance>.status(mailbox, names)

Definition at line 751 of file imaplib.py.

00751 
00752     def status(self, mailbox, names):
00753         """Request named status conditions for mailbox.
00754 
00755         (typ, [data]) = <instance>.status(mailbox, names)
00756         """
00757         name = 'STATUS'
00758         #if self.PROTOCOL_VERSION == 'IMAP4':   # Let the server decide!
00759         #    raise self.error('%s unimplemented in IMAP4 (obtain IMAP4rev1 server, or re-code)' % name)
00760         typ, dat = self._simple_command(name, mailbox, names)
00761         return self._untagged_response(typ, dat, name)
00762 

def imaplib.store (   self,
  message_set,
  command,
  flags 
)
Alters flag dispositions for messages in mailbox.

(typ, [data]) = <instance>.store(message_set, command, flags)

Definition at line 763 of file imaplib.py.

00763 
00764     def store(self, message_set, command, flags):
00765         """Alters flag dispositions for messages in mailbox.
00766 
00767         (typ, [data]) = <instance>.store(message_set, command, flags)
00768         """
00769         if (flags[0],flags[-1]) != ('(',')'):
00770             flags = '(%s)' % flags  # Avoid quoting the flags
00771         typ, dat = self._simple_command('STORE', message_set, command, flags)
00772         return self._untagged_response(typ, dat, 'FETCH')
00773 

Here is the caller graph for this function:

def imaplib.subscribe (   self,
  mailbox 
)
Subscribe to new mailbox.

(typ, [data]) = <instance>.subscribe(mailbox)

Definition at line 774 of file imaplib.py.

00774 
00775     def subscribe(self, mailbox):
00776         """Subscribe to new mailbox.
00777 
00778         (typ, [data]) = <instance>.subscribe(mailbox)
00779         """
00780         return self._simple_command('SUBSCRIBE', mailbox)
00781 

def imaplib.thread (   self,
  threading_algorithm,
  charset,
  search_criteria 
)
IMAPrev1 extension THREAD command.

(type, [data]) = <instance>.thread(threading_algorithm, charset, search_criteria, ...)

Definition at line 782 of file imaplib.py.

00782 
00783     def thread(self, threading_algorithm, charset, *search_criteria):
00784         """IMAPrev1 extension THREAD command.
00785 
00786         (type, [data]) = <instance>.thread(threading_algorithm, charset, search_criteria, ...)
00787         """
00788         name = 'THREAD'
00789         typ, dat = self._simple_command(name, threading_algorithm, charset, *search_criteria)
00790         return self._untagged_response(typ, dat, name)
00791 

def imaplib.Time2Internaldate (   date_time)
Convert date_time to IMAP4 INTERNALDATE representation.

Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"'.  The
date_time argument can be a number (int or float) represening
seconds since epoch (as returned by time.time()), a 9-tuple
representing local time (as returned by time.localtime()), or a
double-quoted string.  In the last case, it is assumed to already
be in the correct format.

Definition at line 1383 of file imaplib.py.

01383 
01384 def Time2Internaldate(date_time):
01385 
01386     """Convert date_time to IMAP4 INTERNALDATE representation.
01387 
01388     Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"'.  The
01389     date_time argument can be a number (int or float) represening
01390     seconds since epoch (as returned by time.time()), a 9-tuple
01391     representing local time (as returned by time.localtime()), or a
01392     double-quoted string.  In the last case, it is assumed to already
01393     be in the correct format.
01394     """
01395 
01396     if isinstance(date_time, (int, float)):
01397         tt = time.localtime(date_time)
01398     elif isinstance(date_time, (tuple, time.struct_time)):
01399         tt = date_time
01400     elif isinstance(date_time, str) and (date_time[0],date_time[-1]) == ('"','"'):
01401         return date_time        # Assume in correct format
01402     else:
01403         raise ValueError("date_time not of a known type")
01404 
01405     dt = time.strftime("%d-%b-%Y %H:%M:%S", tt)
01406     if dt[0] == '0':
01407         dt = ' ' + dt[1:]
01408     if time.daylight and tt[-1]:
01409         zone = -time.altzone
01410     else:
01411         zone = -time.timezone
01412     return '"' + dt + " %+03d%02d" % divmod(zone//60, 60) + '"'
01413 
01414 

Here is the call graph for this function:

Here is the caller graph for this function:

def imaplib.uid (   self,
  command,
  args 
)
Execute "command arg ..." with messages identified by UID,
        rather than message number.

(typ, [data]) = <instance>.uid(command, arg1, arg2, ...)

Returns response appropriate to 'command'.

Definition at line 792 of file imaplib.py.

00792 
00793     def uid(self, command, *args):
00794         """Execute "command arg ..." with messages identified by UID,
00795                 rather than message number.
00796 
00797         (typ, [data]) = <instance>.uid(command, arg1, arg2, ...)
00798 
00799         Returns response appropriate to 'command'.
00800         """
00801         command = command.upper()
00802         if not command in Commands:
00803             raise self.error("Unknown IMAP4 UID command: %s" % command)
00804         if self.state not in Commands[command]:
00805             raise self.error("command %s illegal in state %s, "
00806                              "only allowed in states %s" %
00807                              (command, self.state,
00808                               ', '.join(Commands[command])))
00809         name = 'UID'
00810         typ, dat = self._simple_command(name, command, *args)
00811         if command in ('SEARCH', 'SORT', 'THREAD'):
00812             name = command
00813         else:
00814             name = 'FETCH'
00815         return self._untagged_response(typ, dat, name)
00816 

Here is the caller graph for this function:

def imaplib.unsubscribe (   self,
  mailbox 
)
Unsubscribe from old mailbox.

(typ, [data]) = <instance>.unsubscribe(mailbox)

Definition at line 817 of file imaplib.py.

00817 
00818     def unsubscribe(self, mailbox):
00819         """Unsubscribe from old mailbox.
00820 
00821         (typ, [data]) = <instance>.unsubscribe(mailbox)
00822         """
00823         return self._simple_command('UNSUBSCRIBE', mailbox)
00824 

def imaplib.xatom (   self,
  name,
  args 
)
Allow simple extension commands
        notified by server in CAPABILITY response.

Assumes command is legal in current state.

(typ, [data]) = <instance>.xatom(name, arg, ...)

Returns response appropriate to extension command `name'.

Definition at line 825 of file imaplib.py.

00825 
00826     def xatom(self, name, *args):
00827         """Allow simple extension commands
00828                 notified by server in CAPABILITY response.
00829 
00830         Assumes command is legal in current state.
00831 
00832         (typ, [data]) = <instance>.xatom(name, arg, ...)
00833 
00834         Returns response appropriate to extension command `name'.
00835         """
00836         name = name.upper()
00837         #if not name in self.capabilities:      # Let the server decide!
00838         #    raise self.error('unknown extension command: %s' % name)
00839         if not name in Commands:
00840             Commands[name] = (self.state,)
00841         return self._simple_command(name, *args)
00842 
00843 


Variable Documentation

Initial value:
00001 ["IMAP4", "IMAP4_stream", "Internaldate2tuple",
00002            "Int2AP", "ParseFlags", "Time2Internaldate"]

Definition at line 33 of file imaplib.py.

Definition at line 23 of file imaplib.py.

Definition at line 1158 of file imaplib.py.

Definition at line 744 of file imaplib.py.

tuple imaplib.AllowedVersions = ('IMAP4REV1', 'IMAP4')

Definition at line 42 of file imaplib.py.

Definition at line 967 of file imaplib.py.

Definition at line 46 of file imaplib.py.

tuple imaplib.Continuation = re.compile(br'\+( (?P<data>.*))?')

Definition at line 91 of file imaplib.py.

Definition at line 1003 of file imaplib.py.

Definition at line 38 of file imaplib.py.

tuple imaplib.Debug = 0

Definition at line 39 of file imaplib.py.

Definition at line 247 of file imaplib.py.

tuple imaplib.Flags = re.compile(br'.*FLAGS \((?P<flags>[^\)]*)\)

Definition at line 92 of file imaplib.py.

Definition at line 29 of file imaplib.py.

Definition at line 1438 of file imaplib.py.

Definition at line 40 of file imaplib.py.

Definition at line 41 of file imaplib.py.

Definition at line 669 of file imaplib.py.

Definition at line 348 of file imaplib.py.

Definition at line 1480 of file imaplib.py.

imaplib.mo = re.match(r'.*"([^"]+)

Definition at line 1492 of file imaplib.py.

Initial value:
00001 {b'Jan': 1, b'Feb': 2, b'Mar': 3, b'Apr': 4, b'May': 5, b'Jun': 6,
00002            b'Jul': 7, b'Aug': 8, b'Sep': 9, b'Oct': 10, b'Nov': 11, b'Dec': 12}

Definition at line 1311 of file imaplib.py.

tuple imaplib.PASSWD = getpass.getpass("IMAP password for %s on %s: " % (USER, host or "localhost"))

Definition at line 1441 of file imaplib.py.

Definition at line 542 of file imaplib.py.

Definition at line 245 of file imaplib.py.

Definition at line 246 of file imaplib.py.

Definition at line 377 of file imaplib.py.

Definition at line 1428 of file imaplib.py.

Definition at line 1106 of file imaplib.py.

string imaplib.test_mesg = 'From: %(user)s@localhost%(lf)sSubject: IMAP4 test%(lf)s%(lf)sdata...%(lf)s'

Definition at line 1443 of file imaplib.py.

Initial value:
00001 (
00002     ('login', (USER, PASSWD)),
00003     ('create', ('/tmp/xxx 1',)),
00004     ('rename', ('/tmp/xxx 1', '/tmp/yyy')),
00005     ('CREATE', ('/tmp/yyz 2',)),
00006     ('append', ('/tmp/yyz 2', None, None, test_mesg)),
00007     ('list', ('/tmp', 'yy*')),
00008     ('select', ('/tmp/yyz 2',)),
00009     ('search', (None, 'SUBJECT', 'test')),
00010     ('fetch', ('1', '(FLAGS INTERNALDATE RFC822)')),
00011     ('store', ('1', 'FLAGS', '(\Deleted)')),
00012     ('namespace', ()),
00013     ('expunge', ()),
00014     ('recent', ()),
00015     ('close', ()),
00016     )

Definition at line 1444 of file imaplib.py.

Initial value:
00001 (
00002     ('select', ()),
00003     ('response',('UIDVALIDITY',)),
00004     ('uid', ('SEARCH', 'ALL')),
00005     ('response', ('EXISTS',)),
00006     ('append', (None, None, None, test_mesg)),
00007     ('recent', ()),
00008     ('logout', ()),
00009     )

Definition at line 1461 of file imaplib.py.

Definition at line 668 of file imaplib.py.

Definition at line 1440 of file imaplib.py.