Piers Lauder <piers@cs.su.oz.au>:

I've added an extra comment about quoting arguments to
IMAP4 commands. Also changed the command descriptions
to show optional extra commands where appropriate.

Fred Drake:
Added example usage for the search() method based on comments from
<Lucas.DeJonge@awtpl.com.au>; elaborated error handling information
when arguments are missing from search() and uid().
This commit is contained in:
Fred Drake 2000-05-26 04:08:37 +00:00
parent 6153fa19ce
commit 99d707af47
1 changed files with 29 additions and 8 deletions

View File

@ -96,6 +96,9 @@ passed as an IMAP4 literal. If necessary (the string contains IMAP4
protocol-sensitive characters and isn't enclosed with either protocol-sensitive characters and isn't enclosed with either
parentheses or double quotes) each string is quoted. However, the parentheses or double quotes) each string is quoted. However, the
\var{password} argument to the \samp{LOGIN} command is always quoted. \var{password} argument to the \samp{LOGIN} command is always quoted.
If you want to avoid having an argument string quoted
(eg: the \var{flags} argument to \samp{STORE}) then enclose the string in
parentheses (eg: \code{r'(\e Deleted)'}).
Each command returns a tuple: \code{(\var{type}, [\var{data}, Each command returns a tuple: \code{(\var{type}, [\var{data},
...])} where \var{type} is usually \code{'OK'} or \code{'NO'}, ...])} where \var{type} is usually \code{'OK'} or \code{'NO'},
@ -144,8 +147,10 @@ An \class{IMAP4} instance has the following methods:
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{fetch}{message_set, message_parts} \begin{methoddesc}{fetch}{message_set, message_parts}
Fetch (parts of) messages. Returned data are tuples of message part Fetch (parts of) messages. \var{message_parts} should be
envelope and data. a string of message part names enclosed within parentheses,
eg: \samp{"(UID BODY[TEXT])"}. Returned data are tuples
of message part envelope and data.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{list}{\optional{directory\optional{, pattern}}} \begin{methoddesc}{list}{\optional{directory\optional{, pattern}}}
@ -199,9 +204,23 @@ An \class{IMAP4} instance has the following methods:
\code{None}. Returns the given code, instead of the usual type. \code{None}. Returns the given code, instead of the usual type.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{search}{charset, criteria} \begin{methoddesc}{search}{charset, criterium\optional{, ...}}
Search mailbox for matching messages. Returned data contains a space Search mailbox for matching messages. Returned data contains a space
separated list of matching message numbers. separated list of matching message numbers. \var{charset} may be
\code{None}, in which case no \samp{CHARSET} will be specified in the
request to the server. The IMAP protocol requires that at least one
criterium be specified; an exception will be raised when the server
returns an error.
Example:
\begin{verbatim}
# M is a connected IMAP4 instance...
msgnums = M.search(None, 'FROM', '"LDJ"')
# or:
msgnums = M.search(None, '(FROM "LDJ")')
\end{verbatim}
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{select}{\optional{mailbox\optional{, readonly}}} \begin{methoddesc}{select}{\optional{mailbox\optional{, readonly}}}
@ -227,16 +246,18 @@ An \class{IMAP4} instance has the following methods:
Subscribe to new mailbox. Subscribe to new mailbox.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{uid}{command, args} \begin{methoddesc}{uid}{command, arg\optional{, ...}}
Execute command args with messages identified by UID, rather than Execute command args with messages identified by UID, rather than
message number. Returns response appropriate to command. message number. Returns response appropriate to command. At least
one argument must be supplied; if none are provided, the server will
return an error and an exception will be raised.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{unsubscribe}{mailbox} \begin{methoddesc}{unsubscribe}{mailbox}
Unsubscribe from old mailbox. Unsubscribe from old mailbox.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{xatom}{name\optional{, arg1\optional{, arg2}}} \begin{methoddesc}{xatom}{name\optional{, arg\optional{, ...}}}
Allow simple extension commands notified by server in Allow simple extension commands notified by server in
\samp{CAPABILITY} response. \samp{CAPABILITY} response.
\end{methoddesc} \end{methoddesc}