Apply the new \mailheader macro where appropriate, and fix a few small
markup inconsistencies.
This commit is contained in:
parent
7eac0cb04c
commit
d86038d1be
|
@ -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
|
||||
Netscape Mail on \UNIX: Why the Content-Length Format is
|
||||
Bad}{A description of problems with relying on the
|
||||
Content-Length header for messages stored in mailbox
|
||||
files.}
|
||||
\mailheader{Content-Length} header for messages stored in
|
||||
mailbox files.}
|
||||
\end{seealso}
|
||||
|
||||
|
||||
|
|
|
@ -68,8 +68,8 @@ The \class{Message} class defines the following methods in
|
|||
addition to the \class{rfc822.Message} methods:
|
||||
|
||||
\begin{methoddesc}{getplist}{}
|
||||
Return the parameter list of the \code{content-type} header. This is
|
||||
a list of strings. For parameters of the form
|
||||
Return the parameter list of the \mailheader{Content-Type} header.
|
||||
This is a list of strings. For parameters of the form
|
||||
\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
|
||||
\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}
|
||||
|
||||
\begin{methoddesc}{getencoding}{}
|
||||
Return the encoding specified in the \code{content-transfer-encoding}
|
||||
message header. If no such header exists, return \code{'7bit'}. The
|
||||
encoding is converted to lower case.
|
||||
Return the encoding specified in the
|
||||
\mailheader{Content-Transfer-Encoding} message header. If no such
|
||||
header exists, return \code{'7bit'}. The encoding is converted to
|
||||
lower case.
|
||||
\end{methoddesc}
|
||||
|
||||
\begin{methoddesc}{gettype}{}
|
||||
Return the message type (of the form \samp{\var{type}/\var{subtype}})
|
||||
as specified in the \code{content-type} header. If no such header
|
||||
exists, return \code{'text/plain'}. The type is converted to lower
|
||||
case.
|
||||
as specified in the \mailheader{Content-Type} header. If no such
|
||||
header exists, return \code{'text/plain'}. The type is converted to
|
||||
lower case.
|
||||
\end{methoddesc}
|
||||
|
||||
\begin{methoddesc}{getmaintype}{}
|
||||
Return the main type as specified in the \code{content-type} header.
|
||||
If no such header exists, return \code{'text'}. The main type is
|
||||
converted to lower case.
|
||||
Return the main type as specified in the \mailheader{Content-Type}
|
||||
header. If no such header exists, return \code{'text'}. The main
|
||||
type is converted to lower case.
|
||||
\end{methoddesc}
|
||||
|
||||
\begin{methoddesc}{getsubtype}{}
|
||||
Return the subtype as specified in the \code{content-type} header. If
|
||||
no such header exists, return \code{'plain'}. The subtype is
|
||||
converted to lower case.
|
||||
Return the subtype as specified in the \mailheader{Content-Type}
|
||||
header. If no such header exists, return \code{'plain'}. The subtype
|
||||
is converted to lower case.
|
||||
\end{methoddesc}
|
||||
|
|
|
@ -20,17 +20,17 @@ module. If the module has not been initialized, they will call
|
|||
|
||||
\begin{funcdesc}{guess_type}{filename}
|
||||
Guess the type of a file based on its filename or URL, given by
|
||||
\var{filename}.
|
||||
The return value is a tuple \code{(\var{type}, \var{encoding})} where
|
||||
\var{type} is \code{None} if the type can't be guessed (no or unknown
|
||||
suffix) or a string of the form \code{'\var{type}/\var{subtype}'},
|
||||
usable for a MIME \code{content-type} header\indexii{MIME}{headers}; and
|
||||
encoding is \code{None} for no encoding or the name of the program used
|
||||
to encode (e.g. \program{compress} or \program{gzip}). The encoding
|
||||
is suitable for use as a \code{content-encoding} header,
|
||||
\emph{not} as a \code{content-transfer-encoding} header. The mappings
|
||||
are table driven. Encoding suffixes are case sensitive; type suffixes
|
||||
are first tried case sensitive, then case insensitive.
|
||||
\var{filename}. The return value is a tuple \code{(\var{type},
|
||||
\var{encoding})} where \var{type} is \code{None} if the type can't be
|
||||
guessed (no or unknown suffix) or a string of the form
|
||||
\code{'\var{type}/\var{subtype}'}, usable for a MIME
|
||||
\mailheader{content-type} header\indexii{MIME}{headers}; and encoding
|
||||
is \code{None} for no encoding or the name of the program used to
|
||||
encode (e.g. \program{compress} or \program{gzip}). The encoding is
|
||||
suitable for use as a \mailheader{Content-Encoding} header, \emph{not}
|
||||
as a \mailheader{Content-Transfer-Encoding} header. The mappings are
|
||||
table driven. Encoding suffixes are case sensitive; type suffixes are
|
||||
first tried case sensitive, then case insensitive.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{guess_extension}{type}
|
||||
|
@ -52,8 +52,8 @@ the behavior of the module.
|
|||
Initialize the internal data structures. If given, \var{files} must
|
||||
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
|
||||
\code{knownfiles}. Each file named in \var{files} or
|
||||
\code{knownfiles} takes precedence over those named before it.
|
||||
\constant{knownfiles}. Each file named in \var{files} or
|
||||
\constant{knownfiles} takes precedence over those named before it.
|
||||
Calling \function{init()} repeatedly is allowed.
|
||||
\end{funcdesc}
|
||||
|
||||
|
|
|
@ -72,18 +72,19 @@ are stripped off.
|
|||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{parseaddr}{address}
|
||||
Parse \var{address}, which should be the value of some address-containing
|
||||
field such as \code{To:} or \code{Cc:}, into its constituent
|
||||
``realname'' and ``email address'' parts. Returns a tuple of that
|
||||
information, unless the parse fails, in which case a 2-tuple of
|
||||
\code{(None, None)} is returned.
|
||||
Parse \var{address}, which should be the value of some
|
||||
address-containing field such as \mailheader{To} or \mailheader{Cc},
|
||||
into its constituent ``realname'' and ``email address'' parts.
|
||||
Returns a tuple of that information, unless the parse fails, in which
|
||||
case a 2-tuple \code{(None, None)} is returned.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{dump_address_pair}{pair}
|
||||
The inverse of \method{parseaddr()}, this takes a 2-tuple of the form
|
||||
\code{(realname, email_address)} and returns the string value suitable
|
||||
for a \code{To:} or \code{Cc:} header. If the first element of
|
||||
\var{pair} is false, then the second element is returned unmodified.
|
||||
\code{(\var{realname}, \var{email_address})} and returns the string
|
||||
value suitable for a \mailheader{To} or \mailheader{Cc} header. If
|
||||
the first element of \var{pair} is false, then the second element is
|
||||
returned unmodified.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{parsedate}{date}
|
||||
|
@ -142,9 +143,9 @@ object is seekable.
|
|||
\begin{methoddesc}{isheader}{line}
|
||||
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
|
||||
returns None (implying that parsing should stop here and the line be
|
||||
pushed back on the input stream). It is sometimes useful to override
|
||||
this method in a subclass.
|
||||
returns \code{None} (implying that parsing should stop here and the
|
||||
line be pushed back on the input stream). It is sometimes useful to
|
||||
override this method in a subclass.
|
||||
\end{methoddesc}
|
||||
|
||||
\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)
|
||||
strings.
|
||||
|
||||
Example: If \var{m}'s first \code{From} header contains the string
|
||||
\code{'jack@cwi.nl (Jack Jansen)'}, then
|
||||
Example: If \var{m}'s first \mailheader{From} header contains the
|
||||
string \code{'jack@cwi.nl (Jack Jansen)'}, then
|
||||
\code{m.getaddr('From')} will yield the pair
|
||||
\code{('Jack Jansen', 'jack@cwi.nl')}.
|
||||
If the header contained
|
||||
|
@ -211,14 +212,14 @@ exact same result.
|
|||
|
||||
\begin{methoddesc}{getaddrlist}{name}
|
||||
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
|
||||
(even if there was only one address in the header). If there is no
|
||||
header matching \var{name}, return an empty list.
|
||||
|
||||
If multiple headers exist that match the named header (e.g. if there
|
||||
are several \code{Cc} headers), all are parsed for addresses. Any
|
||||
continuation lines the named headers contain are also parsed.
|
||||
are several \mailheader{Cc} headers), all are parsed for addresses.
|
||||
Any continuation lines the named headers contain are also parsed.
|
||||
\end{methoddesc}
|
||||
|
||||
\begin{methoddesc}{getdate}{name}
|
||||
|
|
|
@ -168,8 +168,8 @@ subclass of \class{URLopener} or \class{FancyURLopener}, then assign
|
|||
that an instance of that class to the
|
||||
\code{urllib._urlopener} variable before calling the desired function.
|
||||
For example, applications may want to specify a different
|
||||
\code{user-agent} header than \class{URLopener} defines. This can be
|
||||
accomplished with the following code:
|
||||
\mailheader{User-Agent} header than \class{URLopener} defines. This
|
||||
can be accomplished with the following code:
|
||||
|
||||
\begin{verbatim}
|
||||
class AppURLopener(urllib.FancyURLopener):
|
||||
|
@ -187,9 +187,9 @@ opening objects using schemes other than \file{http:}, \file{ftp:},
|
|||
\class{FancyURLopener}.
|
||||
|
||||
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
|
||||
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
|
||||
attribute \member{version} to an appropriate string value before the
|
||||
\method{open()} method is called.
|
||||
|
@ -203,7 +203,7 @@ actually retrieve a resource at an \file{https:} URL.
|
|||
\begin{classdesc}{FancyURLopener}{...}
|
||||
\class{FancyURLopener} subclasses \class{URLopener} providing default
|
||||
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
|
||||
required), basic HTTP authentication is performed. For 301 and 302 response
|
||||
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
|
||||
HTTP\indexii{HTTP}{protocol} protocol provides type information in the
|
||||
reply header, which can be inspected by looking at the
|
||||
\code{content-type} header. For the Gopher\indexii{Gopher}{protocol}
|
||||
protocol, type information is encoded in the URL; there is currently
|
||||
no easy way to extract it. If the returned data is HTML, you can use
|
||||
the module \refmodule{htmllib}\refstmodindex{htmllib} to parse it.
|
||||
\mailheader{Content-Type} header. For the
|
||||
Gopher\indexii{Gopher}{protocol} protocol, type information is encoded
|
||||
in the URL; there is currently no easy way to extract it. If the
|
||||
returned data is HTML, you can use the module
|
||||
\refmodule{htmllib}\refstmodindex{htmllib} to parse it.
|
||||
|
||||
\item
|
||||
This module does not support the use of proxies which require
|
||||
|
|
Loading…
Reference in New Issue