Package twisted :: Package protocols :: Module imap4

[show private | hide private]
[frames | no frames]

## Module twisted.protocols.imap4

An IMAP4 protocol implementation

API Stability: Semi-stable

Author: Jp Calderone<mailto:exarkun@twistedmatrix.com>

Classes
`IMAP4Server` | Protocol implementation for an IMAP4rev1 server.
`IMAP4Client` | IMAP4 client protocol implementation
`CramMD5ServerAuthenticator` |
`CramMD5ClientAuthenticator` |
`MemoryAccount` |
`Command` |
`CramMD5Identity` |
`StreamReader` |
`StreamWriter` |

Exceptions
`IMAP4Exception` |
`IllegalClientResponse` |
`IllegalOperation` |
`IllegalMailboxEncoding` |
`UnhandledResponse` |
`NegativeResponse` |
`NoSupportedAuthentication` |
`IllegalServerResponse` |
`IllegalIdentifierError` |
`IllegalQueryError` |
`MismatchedNesting` |
`MismatchedQuoting` |
`MailboxException` |
`MailboxCollision` |
`NoSuchMailbox` |
`ReadOnlyMailbox` |

Function Summary
`str` | ``collapseNestedLists`(items)` Turn a nested list structure into an s-exp-like string.
`list` of `str` and `list` | ``collapseStrings`(results)` Turns a list of length-one strings and lists into a list of longer strings and lists.
| `decoder(s)`
| `encoder(s)`
| `imap4_utf_7(name)`
| `modified_base64(s)`
| `modified_unbase64(s)`
| ``Not`(query)` The negation of a query
| ``Or`(*args)` The disjunction of two or more queries
| `parseIdList(s, topValue)`
`list` of `str` and `list` | ``parseNestedParens`(s)` Parse an s-exp-like string into a more useful data structure.
| ``Query`(sorted, **kwarg)` Create a query string
| `splitOn(sequence, predicate, transformers)`
`list` of `str` | ``splitQuoted`(s)` Split a string into whitespace delimited tokens
| `wildcardToRegexp(wildcard, delim)`
| `_needsLiteral(s)`
| `_needsQuote(s)`
| `_quote(s)`

Variable Summary
`MetaInterface` | `IMailboxListener`
`MetaInterface` | `IServerAuthentication`
`MetaInterface` | `IClientAuthentication`
`MetaInterface` | `IAccount`
`MetaInterface` | `IMailbox`
`int` | `False`
`_Feature` | `nested_scopes`
`tuple` | `StringTypes`
`int` | `True`
`str` | `_ATOM_SPECIALS`
`tuple` | `_NO_QUOTES`
`tuple` | `_SIMPLE_BOOL`

Function Details

### collapseNestedLists(items)

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, quoted if they contain other whitespace, or sent unquoted otherwise. References to None in `items` will be translated to the atom NIL.

  Parameters:
    `items`
    (type=Any iterable)
  Returns:
    `str`

### collapseStrings(results)

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']]

  Parameters:
    `results` - The list to be collapsed
    (type=`list` of `str` and `list`)
  Returns:
    A new list which is the collapsed form of `results`
    (type=`list` of `str` and `list`)

### Not(query)

The negation of a query

### Or(*args)

The disjunction of two or more queries

### parseNestedParens(s)

Parse an s-exp-like string into a more useful data structure.

  Parameters:
    `s` - The s-exp-like string to parse
    (type=`str`)
  Returns:
    A list containing the tokens present in the input.
    (type=`list` of `str` and `list`)
  Raises:
    `MismatchedNesting` - Raised if the number or placement of opening or closing parenthesis is invalid.

### Query(sorted=0, **kwarg)

    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

        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

    @type sorted: C{bool}
    @param sorted: If 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.

    @rtype: C{str}
    @return: The formatted query string

### splitQuoted(s)

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`.

  Parameters:
    `s` - The string to be split
    (type=`str`)
  Returns:
    A list of the resulting tokens
    (type=`list` of `str`)
  Raises:
    `MismatchedQuoting` - Raised if an odd number of quotes are present

Variable Details

### False

  Type:
    `int`
  Value:

        0

### IAccount

  Type:
    `MetaInterface`
  Value:

        <class 'twisted.protocols.imap4.IAccount'>

### IClientAuthentication

  Type:
    `MetaInterface`
  Value:

        <class 'twisted.protocols.imap4.IClientAuthentication'>

### IMailbox

  Type:
    `MetaInterface`
  Value:

        <class 'twisted.protocols.imap4.IMailbox'>

### IMailboxListener

  Type:
    `MetaInterface`
  Value:

        <class 'twisted.protocols.imap4.IMailboxListener'>

### IServerAuthentication

  Type:
    `MetaInterface`
  Value:

        <class 'twisted.protocols.imap4.IServerAuthentication'>

### nested_scopes

  Type:
    `_Feature`
  Value:

        _Feature((2, 1, 0, 'beta', 1), (2, 2, 0, 'alpha', 0), 16)

### StringTypes

  Type:
    `tuple`
  Value:

        (<type 'str'>, <type 'unicode'>)

### True

  Type:
    `int`
  Value:

        1

### _ATOM_SPECIALS

  Type:
    `str`
  Value:

        '(){ %*"'

### _NO_QUOTES

  Type:
    `tuple`
  Value:

        ('LARGER', 'SMALLER', 'UID')

### _SIMPLE_BOOL

  Type:
    `tuple`
  Value:

        ('ALL',
         'ANSWERED',
         'DELETED',
         'DRAFT',
         'FLAGGED',
         'NEW',
         'OLD',
         'RECENT',
        ...

Generated by Epydoc 1.1 on Thu May 8 13:18:47 2003 | http://epydoc.sf.net