mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Some logical markup, some nits.
This commit is contained in:
parent
20392ccb87
commit
23329d41bc
1 changed files with 24 additions and 23 deletions
|
@ -3,8 +3,6 @@
|
||||||
|
|
||||||
\modulesynopsis{Parse \rfc{822} style mail headers.}
|
\modulesynopsis{Parse \rfc{822} style mail headers.}
|
||||||
|
|
||||||
%\index{RFC!RFC 822}
|
|
||||||
|
|
||||||
This module defines a class, \class{Message}, which represents a
|
This module defines a class, \class{Message}, which represents a
|
||||||
collection of ``email headers'' as defined by the Internet standard
|
collection of ``email headers'' as defined by the Internet standard
|
||||||
\rfc{822}. It is used in various contexts, usually to read such
|
\rfc{822}. It is used in various contexts, usually to read such
|
||||||
|
@ -17,38 +15,41 @@ style mailbox files: \module{mailbox}\refstmodindex{mailbox}.
|
||||||
\begin{classdesc}{Message}{file\optional{, seekable}}
|
\begin{classdesc}{Message}{file\optional{, seekable}}
|
||||||
A \class{Message} instance is instantiated with an input object as
|
A \class{Message} instance is instantiated with an input object as
|
||||||
parameter. Message relies only on the input object having a
|
parameter. Message relies only on the input object having a
|
||||||
\code{readline} method; in particular, ordinary file objects qualify.
|
\method{readline()} method; in particular, ordinary file objects
|
||||||
Instantiation reads headers from the input object up to a delimiter
|
qualify. Instantiation reads headers from the input object up to a
|
||||||
line (normally a blank line) and stores them in the instance.
|
delimiter line (normally a blank line) and stores them in the
|
||||||
|
instance.
|
||||||
|
|
||||||
This class can work with any input object that supports a readline
|
This class can work with any input object that supports a
|
||||||
method. If the input object has seek and tell capability, the
|
\method{readline()} method. If the input object has seek and tell
|
||||||
\code{rewindbody} method will work; also, illegal lines will be pushed back
|
capability, the \method{rewindbody()} method will work; also, illegal
|
||||||
onto the input stream. If the input object lacks seek but has an
|
lines will be pushed back onto the input stream. If the input object
|
||||||
\code{unread} method that can push back a line of input, Message will use
|
lacks seek but has an \method{unread()} method that can push back a
|
||||||
that to push back illegal lines. Thus this class can be used to parse
|
line of input, \class{Message} will use that to push back illegal
|
||||||
messages coming from a buffered stream.
|
lines. Thus this class can be used to parse messages coming from a
|
||||||
|
buffered stream.
|
||||||
|
|
||||||
The optional \code{seekable} argument is provided as a workaround for
|
The optional \var{seekable} argument is provided as a workaround for
|
||||||
certain stdio libraries in which tell() discards buffered data before
|
certain stdio libraries in which \cfunction{tell()} discards buffered
|
||||||
discovering that the \code{lseek()} system call doesn't work. For
|
data before discovering that the \cfunction{lseek()} system call
|
||||||
maximum portability, you should set the seekable argument to zero to
|
doesn't work. For maximum portability, you should set the seekable
|
||||||
prevent that initial \code{tell} when passing in an unseekable object
|
argument to zero to prevent that initial \method{tell()} when passing
|
||||||
such as a a file object created from a socket object.
|
in an unseekable object such as a a file object created from a socket
|
||||||
|
object.
|
||||||
|
|
||||||
Input lines as read from the file may either be terminated by CR-LF or
|
Input lines as read from the file may either be terminated by CR-LF or
|
||||||
by a single linefeed; a terminating CR-LF is replaced by a single
|
by a single linefeed; a terminating CR-LF is replaced by a single
|
||||||
linefeed before the line is stored.
|
linefeed before the line is stored.
|
||||||
|
|
||||||
All header matching is done independent of upper or lower case;
|
All header matching is done independent of upper or lower case;
|
||||||
e.g. \code{\var{m}['From']}, \code{\var{m}['from']} and
|
e.g.\ \code{\var{m}['From']}, \code{\var{m}['from']} and
|
||||||
\code{\var{m}['FROM']} all yield the same result.
|
\code{\var{m}['FROM']} all yield the same result.
|
||||||
\end{classdesc}
|
\end{classdesc}
|
||||||
|
|
||||||
\begin{classdesc}{AddressList}{field}
|
\begin{classdesc}{AddressList}{field}
|
||||||
You may instantiate the AddresssList helper class using a single
|
You may instantiate the AddresssList helper class using a single
|
||||||
string parameter, a comma-separated list of RFC822 addresses to be
|
string parameter, a comma-separated list of \rfc{822} addresses to be
|
||||||
parsed. (The parameter None yields an empty list.)
|
parsed. (The parameter \code{None} yields an empty list.)
|
||||||
\end{classdesc}
|
\end{classdesc}
|
||||||
|
|
||||||
\begin{funcdesc}{parsedate}{date}
|
\begin{funcdesc}{parsedate}{date}
|
||||||
|
@ -144,7 +145,7 @@ be returned when there is no header matching \var{name}.
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
|
||||||
\begin{methoddesc}{get}{name\optional{, default}}
|
\begin{methoddesc}{get}{name\optional{, default}}
|
||||||
An alias for \code{getheader()}, to make the interface more compatible
|
An alias for \method{getheader()}, to make the interface more compatible
|
||||||
with regular dictionaries.
|
with regular dictionaries.
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
|
||||||
|
@ -166,7 +167,7 @@ exact same result.
|
||||||
|
|
||||||
\begin{methoddesc}{getaddrlist}{name}
|
\begin{methoddesc}{getaddrlist}{name}
|
||||||
This is similar to \code{getaddr(\var{list})}, but parses a header
|
This is similar to \code{getaddr(\var{list})}, but parses a header
|
||||||
containing a list of email addresses (e.g. a \code{To} header) and
|
containing a list of email addresses (e.g.\ a \code{To} header) and
|
||||||
returns a list of \code{(\var{full name}, \var{email address})} pairs
|
returns a list of \code{(\var{full name}, \var{email address})} pairs
|
||||||
(even if there was only one address in the header). If there is no
|
(even if there was only one address in the header). If there is no
|
||||||
header matching \var{name}, return an empty list.
|
header matching \var{name}, return an empty list.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue