Oops -- Lib/Test should be Lib/test, of course!
[python/dscho.git] / Doc / libmacic.tex
blob33364cd8aa0356001c4a5bf6f27362684a50bf89
1 \section{Standard Module \module{ic}}
2 \label{module-ic}
3 \bimodindex{ic}
6 This module provides access to Macintosh Internet Config package,
7 which stores preferences for Internet programs such as mail address,
8 default homepage, etc. Also, Internet Config contains an elaborate set
9 of mappings from Macintosh creator/type codes to foreign filename
10 extensions plus information on how to transfer files (binary, ascii,
11 etc).
13 There is a low-level companion module
14 \module{icglue}\refbimodindex{icglue} which provides the basic
15 Internet Config access functionality. This low-level module is not
16 documented, but the docstrings of the routines document the parameters
17 and the routine names are the same as for the Pascal or \C{} API to
18 Internet Config, so the standard IC programmers' documentation can be
19 used if this module is needed.
21 The \module{ic} module defines the \exception{error} exception and
22 symbolic names for all error codes Internet Config can produce; see
23 the source for details.
25 \begin{excdesc}{error}
26 Exception raised on errors in the \module{ic} module.
27 \end{excdesc}
30 The \module{ic} module defines the following class and function:
32 \begin{classdesc}{IC}{\optional{signature\optional{, ic}}}
33 Create an internet config object. The signature is a 4-character creator
34 code of the current application (default \code{'Pyth'}) which may
35 influence some of ICs settings. The optional \var{ic} argument is a
36 low-level \code{icglue.icinstance} created beforehand, this may be
37 useful if you want to get preferences from a different config file,
38 etc.
39 \end{classdesc}
41 \begin{funcdesc}{launchurl}{url\optional{, hint}}
42 \funcline{parseurl}{data\optional{, start\optional{, end\optional{, hint}}}}
43 \funcline{mapfile}{file}
44 \funcline{maptypecreator}{type, creator\optional{, filename}}
45 \funcline{settypecreator}{file}
46 These functions are ``shortcuts'' to the methods of the same name,
47 described below.
48 \end{funcdesc}
51 \subsection{IC Objects}
53 \class{IC} objects have a mapping interface, hence to obtain the mail
54 address you simply get \code{\var{ic}['MailAddress']}. Assignment also
55 works, and changes the option in the configuration file.
57 The module knows about various datatypes, and converts the internal IC
58 representation to a ``logical'' Python data structure. Running the
59 \module{ic} module standalone will run a test program that lists all
60 keys and values in your IC database, this will have to server as
61 documentation.
63 If the module does not know how to represent the data it returns an
64 instance of the \code{ICOpaqueData} type, with the raw data in its
65 \member{data} attribute. Objects of this type are also acceptable values
66 for assignment.
68 Besides the dictionary interface, \class{IC} objects have the
69 following methods:
72 \begin{methoddesc}{launchurl}{url\optional{, hint}}
73 Parse the given URL, lauch the correct application and pass it the
74 URL. The optional \var{hint} can be a scheme name such as
75 \code{'mailto:'}, in which case incomplete URLs are completed with this
76 scheme. If \var{hint} is not provided, incomplete URLs are invalid.
77 \end{methoddesc}
79 \begin{methoddesc}{parseurl}{data\optional{, start\optional{, end\optional{, hint}}}}
80 Find an URL somewhere in \var{data} and return start position, end
81 position and the URL. The optional \var{start} and \var{end} can be
82 used to limit the search, so for instance if a user clicks in a long
83 textfield you can pass the whole textfield and the click-position in
84 \var{start} and this routine will return the whole URL in which the
85 user clicked. As above, \var{hint} is an optional scheme used to
86 complete incomplete URLs.
87 \end{methoddesc}
89 \begin{methoddesc}{mapfile}{file}
90 Return the mapping entry for the given \var{file}, which can be passed
91 as either a filename or an \function{macfs.FSSpec()} result, and which
92 need not exist.
94 The mapping entry is returned as a tuple \code{(}\var{version},
95 \var{type}, \var{creator}, \var{postcreator}, \var{flags},
96 \var{extension}, \var{appname}, \var{postappname}, \var{mimetype},
97 \var{entryname}\code{)}, where \var{version} is the entry version
98 number, \var{type} is the 4-character filetype, \var{creator} is the
99 4-character creator type, \var{postcreator} is the 4-character creator
100 code of an
101 optional application to post-process the file after downloading,
102 \var{flags} are various bits specifying whether to transfer in binary
103 or ascii and such, \var{extension} is the filename extension for this
104 file type, \var{appname} is the printable name of the application to
105 which this file belongs, \var{postappname} is the name of the
106 postprocessing application, \var{mimetype} is the MIME type of this
107 file and \var{entryname} is the name of this entry.
108 \end{methoddesc}
110 \begin{methoddesc}{maptypecreator}{type, creator\optional{, filename}}
111 Return the mapping entry for files with given 4-character \var{type} and
112 \var{creator} codes. The optional \var{filename} may be specified to
113 further help finding the correct entry (if the creator code is
114 \code{'????'}, for instance).
116 The mapping entry is returned in the same format as for \var{mapfile}.
117 \end{methoddesc}
119 \begin{methoddesc}{settypecreator}{file}
120 Given an existing \var{file}, specified either as a filename or as an
121 \function{macfs.FSSpec()} result, set its creator and type correctly based
122 on its extension. The finder is told about the change, so the finder
123 icon will be updated quickly.
124 \end{methoddesc}