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