<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--Converted with LaTeX2HTML 98.2 beta6 (August 14th, 1998)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>8.1 IC Objects</TITLE>
<META NAME="description" CONTENT="8.1 IC Objects">
<META NAME="keywords" CONTENT="mac">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="STYLESHEET" HREF="mac.css">
<LINK REL="previous" HREF="module-ic.html">
<LINK REL="up" HREF="module-ic.html">
<LINK REL="next" HREF="module-MacOS.html">
</HEAD>
<BODY bgcolor="#ffffff">
<div class=navigation>
<table align=center width="100%" cellpadding=0 cellspacing=2>
<tr>
<td><A HREF="module-MacOS.html"><img width=32 height=32 align=bottom border=0 alt="next"
 src="../icons/next.gif"></A></td>
<td><A HREF="module-ic.html"><img width=32 height=32 align=bottom border=0 alt="up"
 src="../icons/up.gif"></A></td>
<td><A HREF="module-ic.html"><img width=32 height=32 align=bottom border=0 alt="previous"
 src="../icons/previous.gif"></A></td>
<td align=center bgcolor="#99CCFF" width="100%">
 <b class=title>Macintosh Library Modules</b></td>
<td><A HREF="contents.html"><img width=32 height=32 align=bottom border=0 alt="contents"
 src="../icons/contents.gif"></A></td>
<td><a
 href="modindex.html"><img width=32 height=32 align=bottom border=0 alt="modules"
 src="../icons/modules.gif"></a></td>
<td><A HREF="genindex.html"><img width=32 height=32 align=bottom border=0 alt="index"
 src="../icons/index.gif"></A></td>
</tr></table><b class=navlabel>Next:</b> <span class=sectref><A HREF="module-MacOS.html">9. MacOS  </A></span>
<b class=navlabel>Up:</b> <span class=sectref><A HREF="module-ic.html">8. ic  </A></span>
<b class=navlabel>Previous:</b> <span class=sectref><A HREF="module-ic.html">8. ic  </A></span>
<br><hr></div>
<!--End of Navigation Panel-->

<H2><A NAME="SECTION002810000000000000000">
8.1 IC Objects</A>
</H2>

<P>
<tt class=class>IC</tt> objects have a mapping interface, hence to obtain the mail
address you simply get <tt><var>ic</var>['MailAddress']</tt>. Assignment also
works, and changes the option in the configuration file.

<P>
The module knows about various datatypes, and converts the internal IC
representation to a ``logical'' Python data structure. Running the
<tt class=module>ic</tt> module standalone will run a test program that lists all
keys and values in your IC database, this will have to server as
documentation.

<P>
If the module does not know how to represent the data it returns an
instance of the <tt>ICOpaqueData</tt> type, with the raw data in its
<tt class=member>data</tt> attribute. Objects of this type are also acceptable values
for assignment.

<P>
Besides the dictionary interface, <tt class=class>IC</tt> objects have the
following methods:

<P>
<dl><dt><b><a name="l2h-131"><tt class=method>launchurl</tt></a></b> (<var>url</var><big>[</big><var>, hint</var><big>]</big>)
<dd>
Parse the given URL, lauch the correct application and pass it the
URL. The optional <var>hint</var> can be a scheme name such as
<tt>'mailto:'</tt>, in which case incomplete URLs are completed with this
scheme.  If <var>hint</var> is not provided, incomplete URLs are invalid.
</dl>

<P>
<dl><dt><b><a name="l2h-132"><tt class=method>parseurl</tt></a></b> (<var>data</var><big>[</big><var>, start</var><big>[</big><var>, end</var><big>[</big><var>, hint</var><big>]</big><big>]</big><big>]</big>)
<dd>
Find an URL somewhere in <var>data</var> and return start position, end
position and the URL. The optional <var>start</var> and <var>end</var> can be
used to limit the search, so for instance if a user clicks in a long
textfield you can pass the whole textfield and the click-position in
<var>start</var> and this routine will return the whole URL in which the
user clicked.  As above, <var>hint</var> is an optional scheme used to
complete incomplete URLs.
</dl>

<P>
<dl><dt><b><a name="l2h-133"><tt class=method>mapfile</tt></a></b> (<var>file</var>)
<dd>
Return the mapping entry for the given <var>file</var>, which can be passed
as either a filename or an <tt class=function>macfs.FSSpec()</tt> result, and which
need not exist.

<P>
The mapping entry is returned as a tuple <tt>(<var>version</var>,
<var>type</var>, <var>creator</var>, <var>postcreator</var>, <var>flags</var>,
<var>extension</var>, <var>appname</var>, <var>postappname</var>, <var>mimetype</var>,
<var>entryname</var>)</tt>, where <var>version</var> is the entry version
number, <var>type</var> is the 4-character filetype, <var>creator</var> is the
4-character creator type, <var>postcreator</var> is the 4-character creator
code of an
optional application to post-process the file after downloading,
<var>flags</var> are various bits specifying whether to transfer in binary
or ascii and such, <var>extension</var> is the filename extension for this
file type, <var>appname</var> is the printable name of the application to
which this file belongs, <var>postappname</var> is the name of the
postprocessing application, <var>mimetype</var> is the MIME type of this
file and <var>entryname</var> is the name of this entry.
</dl>

<P>
<dl><dt><b><a name="l2h-134"><tt class=method>maptypecreator</tt></a></b> (<var>type, creator</var><big>[</big><var>, filename</var><big>]</big>)
<dd>
Return the mapping entry for files with given 4-character <var>type</var> and
<var>creator</var> codes. The optional <var>filename</var> may be specified to
further help finding the correct entry (if the creator code is
<tt>'????'</tt>, for instance).

<P>
The mapping entry is returned in the same format as for <var>mapfile</var>.
</dl>

<P>
<dl><dt><b><a name="l2h-135"><tt class=method>settypecreator</tt></a></b> (<var>file</var>)
<dd>
Given an existing <var>file</var>, specified either as a filename or as an
<tt class=function>macfs.FSSpec()</tt> result, set its creator and type correctly based
on its extension.  The finder is told about the change, so the finder
icon will be updated quickly.
</dl><p>
<div class=navigation><hr><table align=center width="100%" cellpadding=0 cellspacing=2>
<tr>
<td><A HREF="module-MacOS.html"><img width=32 height=32 align=bottom border=0 alt="next"
 src="../icons/next.gif"></A></td>
<td><A HREF="module-ic.html"><img width=32 height=32 align=bottom border=0 alt="up"
 src="../icons/up.gif"></A></td>
<td><A HREF="module-ic.html"><img width=32 height=32 align=bottom border=0 alt="previous"
 src="../icons/previous.gif"></A></td>
<td align=center bgcolor="#99CCFF" width="100%">
 <b class=title>Macintosh Library Modules</b></td>
<td><A HREF="contents.html"><img width=32 height=32 align=bottom border=0 alt="contents"
 src="../icons/contents.gif"></A></td>
<td><a
 href="modindex.html"><img width=32 height=32 align=bottom border=0 alt="modules"
 src="../icons/modules.gif"></a></td>
<td><A HREF="genindex.html"><img width=32 height=32 align=bottom border=0 alt="index"
 src="../icons/index.gif"></A></td>
</tr></table><b class=navlabel>Next:</b> <span class=sectref><A HREF="module-MacOS.html">9. MacOS  </A></span>
<b class=navlabel>Up:</b> <span class=sectref><A HREF="module-ic.html">8. ic  </A></span>
<b class=navlabel>Previous:</b> <span class=sectref><A HREF="module-ic.html">8. ic  </A></span>
</div>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>Send comments on this document to <a href="mailto:python-docs@python.org">python-docs@python.org</a>.
</ADDRESS>
</BODY>
</HTML>
