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