annotate Doc/libmimetools.tex @ 5817:48b94de85bf3 legacy-trunk

Extensive changes by AMK.
author Guido van Rossum <guido@python.org>
date Thu, 17 Jul 1997 16:29:42 +0000
parents b218f294b726
children 3468ea8645ca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2576
f47bc5554418 mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents: 2453
diff changeset
1 \section{Standard Module \sectcode{mimetools}}
2449
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 \stmodindex{mimetools}
2453
cdd3a721b40e a few typographical changes (e.g. -- => ---) and lots of new stuff in the WWW chapter
Guido van Rossum <guido@python.org>
parents: 2449
diff changeset
3
cdd3a721b40e a few typographical changes (e.g. -- => ---) and lots of new stuff in the WWW chapter
Guido van Rossum <guido@python.org>
parents: 2449
diff changeset
4 \renewcommand{\indexsubitem}{(in module mimetools)}
cdd3a721b40e a few typographical changes (e.g. -- => ---) and lots of new stuff in the WWW chapter
Guido van Rossum <guido@python.org>
parents: 2449
diff changeset
5
2596
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
6 This module defines a subclass of the class \code{rfc822.Message} and
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
7 a number of utility functions that are useful for the manipulation for
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
8 MIME style multipart or encoded message.
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
9
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
10 It defines the following items:
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
11
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
12 \begin{funcdesc}{Message}{fp}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
13 Return a new instance of the \code{mimetools.Message} class. This is
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
14 a subclass of the \code{rfc822.Message} class, with some additional
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
15 methods (see below).
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
16 \end{funcdesc}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
17
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
18 \begin{funcdesc}{choose_boundary}{}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
19 Return a unique string that has a high likelihood of being usable as a
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
20 part boundary. The string has the form
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
21 \code{"\var{hostipaddr}.\var{uid}.\var{pid}.\var{timestamp}.\var{random}"}.
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
22 \end{funcdesc}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
23
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
24 \begin{funcdesc}{decode}{input\, output\, encoding}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
25 Read data encoded using the allowed MIME \var{encoding} from open file
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
26 object \var{input} and write the decoded data to open file object
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
27 \var{output}. Valid values for \var{encoding} include
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
28 \code{"base64"}, \code{"quoted-printable"} and \code{"uuencode"}.
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
29 \end{funcdesc}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
30
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
31 \begin{funcdesc}{encode}{input\, output\, encoding}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
32 Read data from open file object \var{input} and write it encoded using
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
33 the allowed MIME \var{encoding} to open file object \var{output}.
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
34 Valid values for \var{encoding} are the same as for \code{decode()}.
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
35 \end{funcdesc}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
36
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
37 \begin{funcdesc}{copyliteral}{input\, output}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
38 Read lines until EOF from open file \var{input} and write them to open
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
39 file \var{output}.
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
40 \end{funcdesc}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
41
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
42 \begin{funcdesc}{copybinary}{input\, output}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
43 Read blocks until EOF from open file \var{input} and write them to open
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
44 file \var{output}. The block size is currently fixed at 8192.
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
45 \end{funcdesc}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
46
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
47
2609
7ef72873e4d6 restructured library manual accordiung to functional group
Guido van Rossum <guido@python.org>
parents: 2596
diff changeset
48 \subsection{Additional Methods of Message objects}
2596
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
49 \nodename{mimetools.Message Methods}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
50
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
51 The \code{mimetools.Message} class defines the following methods in
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
52 addition to the \code{rfc822.Message} class:
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
53
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
54 \renewcommand{\indexsubitem}{(mimetool.Message method)}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
55
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
56 \begin{funcdesc}{getplist}{}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
57 Return the parameter list of the \code{Content-type} header. This is
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
58 a list if strings. For parameters of the form
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
59 \samp{\var{key}=\var{value}}, \var{key} is converted to lower case but
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
60 \var{value} is not. For example, if the message contains the header
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
61 \samp{Content-type: text/html; spam=1; Spam=2; Spam} then
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
62 \code{getplist()} will return the Python list \code{['spam=1',
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
63 'spam=2', 'Spam']}.
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
64 \end{funcdesc}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
65
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
66 \begin{funcdesc}{getparam}{name}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
67 Return the \var{value} of the first parameter (as returned by
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
68 \code{getplist()} of the form \samp{\var{name}=\var{value}} for the
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
69 given \var{name}. If \var{value} is surrounded by quotes of the form
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
70 \var{<...>} or \var{"..."}, these are removed.
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
71 \end{funcdesc}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
72
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
73 \begin{funcdesc}{getencoding}{}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
74 Return the encoding specified in the \samp{Content-transfer-encoding}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
75 message header. If no such header exists, return \code{"7bit"}. The
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
76 encoding is converted to lower case.
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
77 \end{funcdesc}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
78
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
79 \begin{funcdesc}{gettype}{}
4728
b218f294b726 (lib<all sorts of stuff>.tex):
Fred Drake <fdrake@acm.org>
parents: 2609
diff changeset
80 Return the message type (of the form \samp{\var{type}/\var{subtype}})
2596
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
81 as specified in the \samp{Content-type} header. If no such header
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
82 exists, return \code{"text/plain"}. The type is converted to lower
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
83 case.
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
84 \end{funcdesc}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
85
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
86 \begin{funcdesc}{getmaintype}{}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
87 Return the main type as specified in the \samp{Content-type} header.
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
88 If no such header exists, return \code{"text"}. The main type is
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
89 converted to lower case.
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
90 \end{funcdesc}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
91
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
92 \begin{funcdesc}{getsubtype}{}
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
93 Return the subtype as specified in the \samp{Content-type} header. If
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
94 no such header exists, return \code{"plain"}. The subtype is
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
95 converted to lower case.
31777622ae93 some new material
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
96 \end{funcdesc}