blob: d797cfa0a3c0326e9e6bf8fee8fda2abac9d3a4c [file] [log] [blame]
Guido van Rossume229d861997-08-18 15:14:26 +00001\section{Standard Module \sectcode{ic}}
2\bimodindex{ic}
3
4\renewcommand{\indexsubitem}{(in module ic)}
5
6This module provides access to macintosh Internet Config package,
7which stores preferences for Internet programs such as mail address,
8default homepage, etc. Also, Internet Config contains an elaborate set
9of mappings from Macintosh creator/type codes to foreign filename
10extensions plus information on how to transfer files (binary, ascii,
11etc).
12
13There is a low-level companion module \code{icglue} which provides the
14basic ic access functionality. This low-level module is not
15documented, but the docstrings of the routines document the parameters
16and the routine names are the same as for the Pascal or C API to
17Internet Config, so the standard IC programmers documentation can be
18used if this module is needed.
19
20The \code{ic} module defines the \code{error} exception and symbolic
21names for all error codes IC can produce, see the source for details.
22
23The \code{ic} module defines the following functions:
24
Fred Drake671fe9d1997-12-29 18:53:31 +000025\begin{funcdesc}{IC}{\optional{signature, ic}}
Guido van Rossume229d861997-08-18 15:14:26 +000026Create an internet config object. The signature is a 4-char creator
27code of the current application (default \code{'Pyth'}) which may
28influence some of ICs settings. The optional \var{ic} argument is a
29low-level \code{icinstance} created beforehand, this may be useful if
30you want to get preferences from a different config file, etc.
31\end{funcdesc}
32
Fred Drake671fe9d1997-12-29 18:53:31 +000033\begin{funcdesc}{launchurl}{url \optional{, hint}}
Guido van Rossume229d861997-08-18 15:14:26 +000034\end{funcdesc}
Fred Drake671fe9d1997-12-29 18:53:31 +000035\begin{funcdesc}{parseurl}{data \optional{, start, end, hint}}
Guido van Rossume229d861997-08-18 15:14:26 +000036\end{funcdesc}
37\begin{funcdesc}{mapfile}{file}
38\end{funcdesc}
Fred Drake671fe9d1997-12-29 18:53:31 +000039\begin{funcdesc}{maptypecreator}{type, creator \optional{, filename}}
Guido van Rossume229d861997-08-18 15:14:26 +000040\end{funcdesc}
41\begin{funcdesc}{settypecreator}{file}
42These functions are ``shortcuts'' to the methods of the same name,
43described below.
44\end{funcdesc}
45
46
47\subsection{IC objects}
48
49IC objects have a mapping interface, hence to obtain the mail address
50you simply get \code{ic['MailAddress']}. Assignment also works, and
51changes the option in the configuration file.
52
53The module knows about various datatypes, and converts the internal IC
54representation to a ``logical'' python datastructure. Running the
55\code{ic} module standalone will run a test program that lists all
56keys and values in your IC database, this will have to server as
57documentation.
58
59If the module does not know how to represent the data it returns an
60instance of the \var{ICOpaqueData} type, with the raw data in its
61\var{data} attribute. Objects of this type are also acceptable values
62for assignment.
63
64Besides the dictionary interface IC objects have the following methods:
65
66\renewcommand{\indexsubitem}{(IC object attribute)}
67
Fred Drake671fe9d1997-12-29 18:53:31 +000068\begin{funcdesc}{launchurl}{url \optional{, hint}}
Guido van Rossume229d861997-08-18 15:14:26 +000069Parse the given URL, lauch the correct application and pass it the
70URL. The optional \var{hint} can be a scheme name such as
71\code{mailto:}, in which case incomplete URLs are completed with this
72scheme (otherwise incomplete URLs are invalid).
73\end{funcdesc}
74
Fred Drake671fe9d1997-12-29 18:53:31 +000075\begin{funcdesc}{parseurl}{data \optional{, start, end, hint}}
Guido van Rossume229d861997-08-18 15:14:26 +000076Find an URL somewhere in \var{data} and return start position, end
77position and the URL. The optional \var{start} and \var{end} can be
78used to limit the search, so for instance if a user clicks in a long
79textfield you can pass the whole textfield and the click-position in
80\var{start} and this routine will return the whole URL in which the
81user clicked. \var{Hint} is again an optional scheme used to complete
82incomplete URLs.
83\end{funcdesc}
84
85\begin{funcdesc}{mapfile}{file}
86Return the mapping entry for the given \var{file}, which can be passed
87as either a filename or an \var{FSSpec} object, and which need not
88exist.
89
Fred Drake671fe9d1997-12-29 18:53:31 +000090The mapping entry is returned as a tuple \code{(}\var{version},
91\var{type}, \var{creator}, \var{postcreator}, \var{flags},
92\var{extension}, \var{appname}, \var{postappname}, \var{mimetype},
93\var{entryname}\code{)}, where \var{version} is the entry version
Guido van Rossume229d861997-08-18 15:14:26 +000094number, \var{type} is the 4-char filetype, \var{creator} is the 4-char
95creator type, \var{postcreator} is the 4-char creator code of an
96optional application to post-process the file after downloading,
97\var{flags} are various bits specifying whether to transfer in binary
98or ascii and such, \var{extension} is the filename extension for this
99file type, \var{appname} is the printable name of the application to
100which this file belongs, \var{postappname} is the name of the
101postprocessing application, \var{mimetype} is the MIME type of this
102file and \var{entryname} is the name of this entry.
103\end{funcdesc}
104
Fred Drake671fe9d1997-12-29 18:53:31 +0000105\begin{funcdesc}{maptypecreator}{type, creator \optional{, filename}}
Guido van Rossume229d861997-08-18 15:14:26 +0000106Return the mapping entry for files with given 4-char \var{type} and
107\var{creator} codes. The optional \var{filename} may be specified to
108further help finding the correct entry (if the creator code is
109\code{'????'}, for instance).
110
111The mapping entry is returned in the same format as for \var{mapfile}.
112\end{funcdesc}
113
114\begin{funcdesc}{settypecreator}{file}
115Given an existing \var{file}, specified either as a filename or as an
116\var{FSSpec} record, set its creator and type correctly based on its
117extension. The finder is told about the change, so the finder icon
118will be updated quickly.
119\end{funcdesc}