Module t.m.imap4

Part of twisted.mail View Source

An IMAP4 protocol implementation
Author

Jp Calderone

To do:
 Suspend idle timeout while server is processing
 Use an async message parser instead of buffering in memory
 Figure out a way to not queue multi-message client requests (Flow? A simple callback?)
 Clarify some API docs (Query, etc)
 Make APPEND recognize (again) non-existent mailboxes before accepting the literal
Line # Kind Name Docs
51 Class MessageSet Essentially an infinite bitfield, with some extra features.
254 Class LiteralString No class docstring; 1/3 methods documented
280 Class LiteralFile No class docstring; 1/3 methods documented
313 Class WriteBuffer Buffer up a bunch of writes before sending them all to a transport at once.
335 Class Command Undocumented
377 Class LOGINCredentials Undocumented
392 Class PLAINCredentials Undocumented
408 Class IMAP4Exception Undocumented
412 Class IllegalClientResponse Undocumented
414 Class IllegalOperation Undocumented
416 Class IllegalMailboxEncoding Undocumented
418 Interface IMailboxListener Interface for objects interested in mailbox events
451 Class IMAP4Server Protocol implementation for an IMAP4rev1 server.
1952 Class UnhandledResponse Undocumented
1954 Class NegativeResponse Undocumented
1956 Class NoSupportedAuthentication Undocumented
1967 Class IllegalServerResponse Undocumented
1971 Class IMAP4Client IMAP4 client protocol implementation
3611 Class IllegalIdentifierError Undocumented
3613 Function parseIdList Undocumented
3643 Class IllegalQueryError Undocumented
3654 Function Query Create a query string
3783 Function Or The disjunction of two or more queries
3792 Function Not The negation of a query
3796 Class MismatchedNesting Undocumented
3799 Class MismatchedQuoting Undocumented
3802 Function wildcardToRegexp Undocumented
3810 Function splitQuoted Split a string into whitespace delimited tokens
3856 Function splitOn Undocumented
3871 Function collapseStrings Turns a list of length-one strings and lists into a list of longer
3906 Function parseNestedParens Parse an s-exp-like string into a more useful data structure.
3968 Class DontQuoteMe Undocumented
3996 Function collapseNestedLists Turn a nested list structure into an s-exp-like string.
4036 Interface IClientAuthentication No interface docstring; 2/2 methods documented
4046 Class CramMD5ClientAuthenticator Undocumented
4059 Class LOGINAuthenticator Undocumented
4078 Class PLAINAuthenticator Undocumented
4091 Class MailboxException Undocumented
4093 Class MailboxCollision Undocumented
4097 Class NoSuchMailbox Undocumented
4101 Class ReadOnlyMailbox Undocumented
4106 Interface IAccount Interface for Account classes
4261 Interface INamespacePresenter No interface docstring; 3/3 methods documented
4298 Class MemoryAccount Undocumented
4431 Function statusRequestHelper Undocumented
4437 Function parseAddr Undocumented
4443 Function getEnvelope Undocumented
4459 Function getLineCount Undocumented
4467 Function unquote Undocumented
4472 Function getBodyStructure Undocumented
4565 Interface IMessagePart No interface docstring; 5/5 methods documented
4609 Interface IMessage No interface docstring; 3/3 methods documented
4628 Interface IMessageFile Optional message interface for representing messages as files.
4641 Interface ISearchableMailbox No interface docstring; 1/1 methods documented
4664 Interface IMessageCopier No interface docstring; 1/1 methods documented
4682 Interface IMailboxInfo Interface specifying only the methods required for listMailboxes.
4705 Interface IMailbox No interface docstring; 15/15 methods documented
4877 Interface ICloseableMailbox A supplementary interface for mailboxes which require cleanup on close.
4897 Function subparts Undocumented
4906 Function iterateInReactor Consume an interator at most a single iteration per reactor iteration.
4934 Class MessageProducer No class docstring; 1/3 methods documented
5315 Class FileProducer Undocumented
5358 Function parseTime Undocumented
5386 Function modified_base64 Undocumented
5390 Function modified_unbase64 Undocumented
5394 Function encoder Encode the given unicode string using the IMAP4 specific variation of
5426 Function decoder Decode the given str using the IMAP4 specific variation of UTF-7.
5458 Class StreamReader Undocumented
5462 Class StreamWriter Undocumented
5466 Function imap4_utf_7 Undocumented
3962 Function _quote Undocumented
3965 Function _literal Undocumented
3976 Function _needsQuote Undocumented
3986 Function _prepareMailboxName Undocumented
3992 Function _needsLiteral Undocumented
4891 Function _formatHeaders Undocumented
5001 Class _FetchParser Undocumented
def parseIdList(s): (source)
Undocumented
def Query(sorted=0, **kwarg): (source)

Create a query string

Among the accepted keywords are:
   all         : If set to a true value, search all messages in the
                 current mailbox

   answered    : If set to a true value, search messages flagged with
                 \Answered

   bcc         : A substring to search the BCC header field for

   before      : Search messages with an internal date before this
                 value.  The given date should be a string in the format
                 of 'DD-Mon-YYYY'.  For example, '03-Mar-2003'.

   body        : A substring to search the body of the messages for

   cc          : A substring to search the CC header field for

   deleted     : If set to a true value, search messages flagged with
                 \Deleted

   draft       : If set to a true value, search messages flagged with
                 \Draft

   flagged     : If set to a true value, search messages flagged with
                 \Flagged

   from        : A substring to search the From header field for

   header      : A two-tuple of a header name and substring to search
                 for in that header

   keyword     : Search for messages with the given keyword set

   larger      : Search for messages larger than this number of octets

   messages    : Search only the given message sequence set.

   new         : If set to a true value, search messages flagged with
                 \Recent but not \Seen

   old         : If set to a true value, search messages not flagged with
                 \Recent

   on          : Search messages with an internal date which is on this
                 date.  The given date should be a string in the format
                 of 'DD-Mon-YYYY'.  For example, '03-Mar-2003'.

   recent      : If set to a true value, search for messages flagged with
                 \Recent

   seen        : If set to a true value, search for messages flagged with
                 \Seen

   sentbefore  : Search for messages with an RFC822 'Date' header before
                 this date.  The given date should be a string in the format
                 of 'DD-Mon-YYYY'.  For example, '03-Mar-2003'.

   senton      : Search for messages with an RFC822 'Date' header which is
                 on this date  The given date should be a string in the format
                 of 'DD-Mon-YYYY'.  For example, '03-Mar-2003'.

   sentsince   : Search for messages with an RFC822 'Date' header which is
                 after this date.  The given date should be a string in the format
                 of 'DD-Mon-YYYY'.  For example, '03-Mar-2003'.

   since       : Search for messages with an internal date that is after
                 this date..  The given date should be a string in the format
                 of 'DD-Mon-YYYY'.  For example, '03-Mar-2003'.

   smaller     : Search for messages smaller than this number of octets

   subject     : A substring to search the 'subject' header for

   text        : A substring to search the entire message for

   to          : A substring to search the 'to' header for

   uid         : Search only the messages in the given message set

   unanswered  : If set to a true value, search for messages not
                 flagged with \Answered

   undeleted   : If set to a true value, search for messages not
                 flagged with \Deleted

   undraft     : If set to a true value, search for messages not
                 flagged with \Draft

   unflagged   : If set to a true value, search for messages not
                 flagged with \Flagged

   unkeyword   : Search for messages without the given keyword set

   unseen      : If set to a true value, search for messages not
                 flagged with \Seen
ParameterssortedIf true, the output will be sorted, alphabetically. The standard does not require it, but it makes testing this function easier. The default is zero, and this should be acceptable for any application. (type: bool )
ReturnsThe formatted query string (type: str )
def Or(*args): (source)
The disjunction of two or more queries
def Not(query): (source)
The negation of a query
def wildcardToRegexp(wildcard, delim=None): (source)
Undocumented
def splitQuoted(s): (source)

Split a string into whitespace delimited tokens

Tokens that would otherwise be separated but are surrounded by " remain as a single token. Any token that is not quoted and is equal to "NIL" is tokenized as None.
ParameterssThe string to be split (type: str )
ReturnsA list of the resulting tokens (type: list of str )
RaisesMismatchedQuotingRaised if an odd number of quotes are present
def splitOn(sequence, predicate, transformers): (source)
Undocumented
def collapseStrings(results): (source)

Turns a list of length-one strings and lists into a list of longer strings and lists. For example,

['a', 'b', ['c', 'd']] is returned as ['ab', ['cd']]
ParametersresultsThe list to be collapsed (type: list of str and list )
ReturnsA new list which is the collapsed form of results (type: list of str and list )
def parseNestedParens(s, handleLiteral=1): (source)
Parse an s-exp-like string into a more useful data structure.
ParameterssThe s-exp-like string to parse (type: str )
ReturnsA list containing the tokens present in the input. (type: list of str and list )
RaisesMismatchedNestingRaised if the number or placement of opening or closing parenthesis is invalid.
def _quote(s): (source)
Undocumented
def _literal(s): (source)
Undocumented
def _needsQuote(s): (source)
Undocumented
def _prepareMailboxName(name): (source)
Undocumented
def _needsLiteral(s): (source)
Undocumented
def collapseNestedLists(items): (source)

Turn a nested list structure into an s-exp-like string.

Strings in items will be sent as literals if they contain CR or LF, otherwise they will be quoted. References to None in items will be translated to the atom NIL. Objects with a 'read' attribute will have it called on them with no arguments and the returned string will be inserted into the output as a literal. Integers will be converted to strings and inserted into the output unquoted. Instances of DontQuoteMe will be converted to strings and inserted into the output unquoted.

This function used to be much nicer, and only quote things that really needed to be quoted (and DontQuoteMe did not exist), however, many broken IMAP4 clients were unable to deal with this level of sophistication, forcing the current behavior to be adopted for practical reasons.
Parametersitems (type: Any iterable )
Returns (type: str )
def statusRequestHelper(mbox, names): (source)
Undocumented
def parseAddr(addr): (source)
Undocumented
def getEnvelope(msg): (source)
Undocumented
def getLineCount(msg): (source)
Undocumented
def unquote(s): (source)
Undocumented
def getBodyStructure(msg, extended=False): (source)
Undocumented
def _formatHeaders(headers): (source)
Undocumented
def subparts(m): (source)
Undocumented
def iterateInReactor(i): (source)

Consume an interator at most a single iteration per reactor iteration.

If the iterator produces a Deferred, the next iteration will not occur until the Deferred fires, otherwise the next iteration will be taken in the next reactor iteration.
ReturnsA deferred which fires (with None) when the iterator is exhausted or whose errback is called if there is an exception. (type: Deferred )
def parseTime(s): (source)
Undocumented
def modified_base64(s): (source)
Undocumented
def modified_unbase64(s): (source)
Undocumented
def encoder(s, errors=None): (source)
Encode the given unicode string using the IMAP4 specific variation of UTF-7.
ParameterssThe text to encode. (type: unicode )
errorsPolicy for handling encoding errors. Currently ignored.
Returnstuple of a str giving the encoded bytes and an int giving the number of code units consumed from the input.
def decoder(s, errors=None): (source)
Decode the given str using the IMAP4 specific variation of UTF-7.
ParameterssThe bytes to decode. (type: str )
errorsPolicy for handling decoding errors. Currently ignored.
Returnsa tuple of a unicode string giving the text which was decoded and an int giving the number of bytes consumed from the input.
def imap4_utf_7(name): (source)
Undocumented
API Documentation for Twisted, generated by pydoctor at 2008-10-26 16:12:37.