annotate Doc/lib/libmailcap.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 3ab7d58c2963
children 3468ea8645ca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5217
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 \section{Standard Module \sectcode{mailcap}}
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 \stmodindex{mailcap}
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 \renewcommand{\indexsubitem}{(in module mailcap)}
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
4
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 Mailcap files are used to configure how MIME-aware applications such
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 as mail readers and Web browsers react to files with different MIME
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 types. (The name ``mailcap'' is derived from the phrase ``mail
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 capability''.) For example, a mailcap file might contain a line like
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 \verb\video/mpeg; xmpeg %s\. Then, if the user encounters an email
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 message or Web document with the MIME type video/mpeg, \verb\%s\ will be
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 replaced by a filename (usually one belonging to a temporary file) and
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 the xmpeg program can be automatically started to view the file.
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
13
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 The mailcap format is documented in RFC 1524, ``A User Agent
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 Configuration Mechanism For Multimedia Mail Format Information'', but
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 is not an Internet standard. However, mailcap files are supported on
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 most Unix systems.
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
18
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 \begin{funcdesc}{findmatch}{caps\, MIMEtype\, key\, filename\, plist}
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 Return a 2-tuple; the first element is a string containing the command
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 line to be executed
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 (which can be passed to \code{os.system()}), and the second element is
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 the mailcap entry for a given MIME type. If no matching MIME
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 type can be found, \code{(None, None)} is returned.
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
25
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 \var{key} is the name of the field desired, which represents the type of
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 activity to be performed; the default value is 'view', since in the
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 most common case you simply want to view the body of the MIME-typed
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 data. Other possible values might be 'compose' and 'edit', if you
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 wanted to create a new body of the given MIME type or alter the
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
31 existing body data. See RFC1524 for a complete list of these fields.
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
32
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 \var{filename} is the filename to be substituted for \%s in the
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 command line; the default value is
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
35 \file{/dev/null} which is almost certainly not what you want, so
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 usually you'll override it by specifying a filename.
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
37
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 \var{plist} can be a list containing named parameters; the default
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 value is simply an empty list. Each entry in the list must be a
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
40 string containing the parameter name, an equals sign (=), and the
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
41 parameter's value. Mailcap entries can contain
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 named parameters like \verb\%{foo}\, which will be replaced by the
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
43 value of the parameter named 'foo'. For example, if the command line
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 \verb\showpartial %{id} %{number} %{total}\
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
45 was in a mailcap file, and \var{plist} was set to \code{['id=1',
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
46 'number=2', 'total=3']}, the resulting command line would be
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 \code{"showpartial 1 2 3"}.
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
48
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
49 In a mailcap file, the "test" field can optionally be specified to
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 test some external condition (e.g., the machine architecture, or the
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 window system in use) to determine whether or not the mailcap line
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
52 applies. \code{findmatch()} will automatically check such conditions
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
53 and skip the entry if the check fails.
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
54 \end{funcdesc}
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
55
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
56 \begin{funcdesc}{getcaps}{}
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 Returns a dictionary mapping MIME types to a list of mailcap file
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
58 entries. This dictionary must be passed to the \code{findmatch}
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
59 function. An entry is stored as a list of dictionaries, but it
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
60 shouldn't be necessary to know the details of this representation.
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
61
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
62 The information is derived from all of the mailcap files found on the
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
63 system. Settings in the user's mailcap file \file{\$HOME/.mailcap}
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
64 will override settings in the system mailcap files
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
65 \file{/etc/mailcap}, \file{/usr/etc/mailcap}, and
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
66 \file{/usr/local/etc/mailcap}.
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
67 \end{funcdesc}
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
68
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
69 An example usage:
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
70 \begin{verbatim}
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 >>> import mailcap
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
72 >>> d=mailcap.getcaps()
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
73 >>> mailcap.findmatch(d, 'video/mpeg', filename='/tmp/tmp1223')
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
74 ('xmpeg /tmp/tmp1223', {'view': 'xmpeg %s'})
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
75 \end{verbatim}