Apply the new \mailheader macro where appropriate, and fix a few small

markup inconsistencies.
This commit is contained in:
Fred Drake 2001-08-03 18:39:36 +00:00
parent 7eac0cb04c
commit d86038d1be
5 changed files with 57 additions and 54 deletions

View file

@ -94,8 +94,8 @@ messages start with the EOOH line and end with a line containing only
\seetitle[http://home.netscape.com/eng/mozilla/2.0/relnotes/demo/content-length.html]{Configuring \seetitle[http://home.netscape.com/eng/mozilla/2.0/relnotes/demo/content-length.html]{Configuring
Netscape Mail on \UNIX: Why the Content-Length Format is Netscape Mail on \UNIX: Why the Content-Length Format is
Bad}{A description of problems with relying on the Bad}{A description of problems with relying on the
Content-Length header for messages stored in mailbox \mailheader{Content-Length} header for messages stored in
files.} mailbox files.}
\end{seealso} \end{seealso}

View file

@ -68,8 +68,8 @@ The \class{Message} class defines the following methods in
addition to the \class{rfc822.Message} methods: addition to the \class{rfc822.Message} methods:
\begin{methoddesc}{getplist}{} \begin{methoddesc}{getplist}{}
Return the parameter list of the \code{content-type} header. This is Return the parameter list of the \mailheader{Content-Type} header.
a list of strings. For parameters of the form This is a list of strings. For parameters of the form
\samp{\var{key}=\var{value}}, \var{key} is converted to lower case but \samp{\var{key}=\var{value}}, \var{key} is converted to lower case but
\var{value} is not. For example, if the message contains the header \var{value} is not. For example, if the message contains the header
\samp{Content-type: text/html; spam=1; Spam=2; Spam} then \samp{Content-type: text/html; spam=1; Spam=2; Spam} then
@ -85,26 +85,27 @@ given \var{name}. If \var{value} is surrounded by quotes of the form
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{getencoding}{} \begin{methoddesc}{getencoding}{}
Return the encoding specified in the \code{content-transfer-encoding} Return the encoding specified in the
message header. If no such header exists, return \code{'7bit'}. The \mailheader{Content-Transfer-Encoding} message header. If no such
encoding is converted to lower case. header exists, return \code{'7bit'}. The encoding is converted to
lower case.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{gettype}{} \begin{methoddesc}{gettype}{}
Return the message type (of the form \samp{\var{type}/\var{subtype}}) Return the message type (of the form \samp{\var{type}/\var{subtype}})
as specified in the \code{content-type} header. If no such header as specified in the \mailheader{Content-Type} header. If no such
exists, return \code{'text/plain'}. The type is converted to lower header exists, return \code{'text/plain'}. The type is converted to
case. lower case.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{getmaintype}{} \begin{methoddesc}{getmaintype}{}
Return the main type as specified in the \code{content-type} header. Return the main type as specified in the \mailheader{Content-Type}
If no such header exists, return \code{'text'}. The main type is header. If no such header exists, return \code{'text'}. The main
converted to lower case. type is converted to lower case.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{getsubtype}{} \begin{methoddesc}{getsubtype}{}
Return the subtype as specified in the \code{content-type} header. If Return the subtype as specified in the \mailheader{Content-Type}
no such header exists, return \code{'plain'}. The subtype is header. If no such header exists, return \code{'plain'}. The subtype
converted to lower case. is converted to lower case.
\end{methoddesc} \end{methoddesc}

View file

@ -20,17 +20,17 @@ module. If the module has not been initialized, they will call
\begin{funcdesc}{guess_type}{filename} \begin{funcdesc}{guess_type}{filename}
Guess the type of a file based on its filename or URL, given by Guess the type of a file based on its filename or URL, given by
\var{filename}. \var{filename}. The return value is a tuple \code{(\var{type},
The return value is a tuple \code{(\var{type}, \var{encoding})} where \var{encoding})} where \var{type} is \code{None} if the type can't be
\var{type} is \code{None} if the type can't be guessed (no or unknown guessed (no or unknown suffix) or a string of the form
suffix) or a string of the form \code{'\var{type}/\var{subtype}'}, \code{'\var{type}/\var{subtype}'}, usable for a MIME
usable for a MIME \code{content-type} header\indexii{MIME}{headers}; and \mailheader{content-type} header\indexii{MIME}{headers}; and encoding
encoding is \code{None} for no encoding or the name of the program used is \code{None} for no encoding or the name of the program used to
to encode (e.g. \program{compress} or \program{gzip}). The encoding encode (e.g. \program{compress} or \program{gzip}). The encoding is
is suitable for use as a \code{content-encoding} header, suitable for use as a \mailheader{Content-Encoding} header, \emph{not}
\emph{not} as a \code{content-transfer-encoding} header. The mappings as a \mailheader{Content-Transfer-Encoding} header. The mappings are
are table driven. Encoding suffixes are case sensitive; type suffixes table driven. Encoding suffixes are case sensitive; type suffixes are
are first tried case sensitive, then case insensitive. first tried case sensitive, then case insensitive.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{guess_extension}{type} \begin{funcdesc}{guess_extension}{type}
@ -52,8 +52,8 @@ the behavior of the module.
Initialize the internal data structures. If given, \var{files} must Initialize the internal data structures. If given, \var{files} must
be a sequence of file names which should be used to augment the be a sequence of file names which should be used to augment the
default type map. If omitted, the file names to use are taken from default type map. If omitted, the file names to use are taken from
\code{knownfiles}. Each file named in \var{files} or \constant{knownfiles}. Each file named in \var{files} or
\code{knownfiles} takes precedence over those named before it. \constant{knownfiles} takes precedence over those named before it.
Calling \function{init()} repeatedly is allowed. Calling \function{init()} repeatedly is allowed.
\end{funcdesc} \end{funcdesc}

View file

@ -72,18 +72,19 @@ are stripped off.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{parseaddr}{address} \begin{funcdesc}{parseaddr}{address}
Parse \var{address}, which should be the value of some address-containing Parse \var{address}, which should be the value of some
field such as \code{To:} or \code{Cc:}, into its constituent address-containing field such as \mailheader{To} or \mailheader{Cc},
``realname'' and ``email address'' parts. Returns a tuple of that into its constituent ``realname'' and ``email address'' parts.
information, unless the parse fails, in which case a 2-tuple of Returns a tuple of that information, unless the parse fails, in which
\code{(None, None)} is returned. case a 2-tuple \code{(None, None)} is returned.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{dump_address_pair}{pair} \begin{funcdesc}{dump_address_pair}{pair}
The inverse of \method{parseaddr()}, this takes a 2-tuple of the form The inverse of \method{parseaddr()}, this takes a 2-tuple of the form
\code{(realname, email_address)} and returns the string value suitable \code{(\var{realname}, \var{email_address})} and returns the string
for a \code{To:} or \code{Cc:} header. If the first element of value suitable for a \mailheader{To} or \mailheader{Cc} header. If
\var{pair} is false, then the second element is returned unmodified. the first element of \var{pair} is false, then the second element is
returned unmodified.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{parsedate}{date} \begin{funcdesc}{parsedate}{date}
@ -142,9 +143,9 @@ object is seekable.
\begin{methoddesc}{isheader}{line} \begin{methoddesc}{isheader}{line}
Returns a line's canonicalized fieldname (the dictionary key that will Returns a line's canonicalized fieldname (the dictionary key that will
be used to index it) if the line is a legal \rfc{2822} header; otherwise be used to index it) if the line is a legal \rfc{2822} header; otherwise
returns None (implying that parsing should stop here and the line be returns \code{None} (implying that parsing should stop here and the
pushed back on the input stream). It is sometimes useful to override line be pushed back on the input stream). It is sometimes useful to
this method in a subclass. override this method in a subclass.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{islast}{line} \begin{methoddesc}{islast}{line}
@ -200,8 +201,8 @@ header matching \var{name} exists, return \code{(None, None)};
otherwise both the full name and the address are (possibly empty) otherwise both the full name and the address are (possibly empty)
strings. strings.
Example: If \var{m}'s first \code{From} header contains the string Example: If \var{m}'s first \mailheader{From} header contains the
\code{'jack@cwi.nl (Jack Jansen)'}, then string \code{'jack@cwi.nl (Jack Jansen)'}, then
\code{m.getaddr('From')} will yield the pair \code{m.getaddr('From')} will yield the pair
\code{('Jack Jansen', 'jack@cwi.nl')}. \code{('Jack Jansen', 'jack@cwi.nl')}.
If the header contained If the header contained
@ -211,14 +212,14 @@ 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 \mailheader{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.
If multiple headers exist that match the named header (e.g. if there If multiple headers exist that match the named header (e.g. if there
are several \code{Cc} headers), all are parsed for addresses. Any are several \mailheader{Cc} headers), all are parsed for addresses.
continuation lines the named headers contain are also parsed. Any continuation lines the named headers contain are also parsed.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{getdate}{name} \begin{methoddesc}{getdate}{name}

View file

@ -168,8 +168,8 @@ subclass of \class{URLopener} or \class{FancyURLopener}, then assign
that an instance of that class to the that an instance of that class to the
\code{urllib._urlopener} variable before calling the desired function. \code{urllib._urlopener} variable before calling the desired function.
For example, applications may want to specify a different For example, applications may want to specify a different
\code{user-agent} header than \class{URLopener} defines. This can be \mailheader{User-Agent} header than \class{URLopener} defines. This
accomplished with the following code: can be accomplished with the following code:
\begin{verbatim} \begin{verbatim}
class AppURLopener(urllib.FancyURLopener): class AppURLopener(urllib.FancyURLopener):
@ -187,9 +187,9 @@ opening objects using schemes other than \file{http:}, \file{ftp:},
\class{FancyURLopener}. \class{FancyURLopener}.
By default, the \class{URLopener} class sends a By default, the \class{URLopener} class sends a
\code{user-agent} header of \samp{urllib/\var{VVV}}, where \mailheader{User-Agent} header of \samp{urllib/\var{VVV}}, where
\var{VVV} is the \module{urllib} version number. Applications can \var{VVV} is the \module{urllib} version number. Applications can
define their own \code{user-agent} header by subclassing define their own \mailheader{User-Agent} header by subclassing
\class{URLopener} or \class{FancyURLopener} and setting the instance \class{URLopener} or \class{FancyURLopener} and setting the instance
attribute \member{version} to an appropriate string value before the attribute \member{version} to an appropriate string value before the
\method{open()} method is called. \method{open()} method is called.
@ -203,7 +203,7 @@ actually retrieve a resource at an \file{https:} URL.
\begin{classdesc}{FancyURLopener}{...} \begin{classdesc}{FancyURLopener}{...}
\class{FancyURLopener} subclasses \class{URLopener} providing default \class{FancyURLopener} subclasses \class{URLopener} providing default
handling for the following HTTP response codes: 301, 302 or 401. For handling for the following HTTP response codes: 301, 302 or 401. For
301 and 302 response codes, the \code{location} header is used to 301 and 302 response codes, the \mailheader{Location} header is used to
fetch the actual URL. For 401 response codes (authentication fetch the actual URL. For 401 response codes (authentication
required), basic HTTP authentication is performed. For 301 and 302 response required), basic HTTP authentication is performed. For 301 and 302 response
codes, recursion is bounded by the value of the \var{maxtries} attribute, codes, recursion is bounded by the value of the \var{maxtries} attribute,
@ -257,10 +257,11 @@ is the raw data returned by the server. This may be binary data
(e.g. an image), plain text or (for example) HTML\index{HTML}. The (e.g. an image), plain text or (for example) HTML\index{HTML}. The
HTTP\indexii{HTTP}{protocol} protocol provides type information in the HTTP\indexii{HTTP}{protocol} protocol provides type information in the
reply header, which can be inspected by looking at the reply header, which can be inspected by looking at the
\code{content-type} header. For the Gopher\indexii{Gopher}{protocol} \mailheader{Content-Type} header. For the
protocol, type information is encoded in the URL; there is currently Gopher\indexii{Gopher}{protocol} protocol, type information is encoded
no easy way to extract it. If the returned data is HTML, you can use in the URL; there is currently no easy way to extract it. If the
the module \refmodule{htmllib}\refstmodindex{htmllib} to parse it. returned data is HTML, you can use the module
\refmodule{htmllib}\refstmodindex{htmllib} to parse it.
\item \item
This module does not support the use of proxies which require This module does not support the use of proxies which require