|
| 1 | +\section{\module{aepack} --- |
| 2 | + Conversion between Python variables and AppleEvent data containers} |
| 3 | + |
| 4 | +\declaremodule{standard}{aepack} |
| 5 | + \platform{Mac} |
| 6 | +%\moduleauthor{Jack Jansen?}{email} |
| 7 | +\modulesynopsis{Conversion between Python variables and AppleEvent |
| 8 | + data containers.} |
| 9 | +\sectionauthor{Vincent Marchetti}{ [email protected]} |
| 10 | + |
| 11 | + |
| 12 | +The \module{aepack} module defines functions for converting (packing) |
| 13 | +Python variables to AppleEvent descriptors and back (unpacking). |
| 14 | +Within Python the AppleEvent descriptor is handled by Python objects |
| 15 | +of built-in type \pytype{AEDesc}, defined in module \refmodule{AE}. |
| 16 | + |
| 17 | +The \module{aepack} module defines the following functions: |
| 18 | + |
| 19 | + |
| 20 | +\begin{funcdesc}{pack}{x\optional{, forcetype}} |
| 21 | +Returns an \class{AEDesc} object containing a conversion of Python |
| 22 | +value x. If \var{forcetype} is provided it specifies the descriptor |
| 23 | +type of the result. Otherwise, a default mapping of Python types to |
| 24 | +Apple Event descriptor types is used, as follows: |
| 25 | + |
| 26 | +\begin{tableii}{l|l}{textrm}{Python type}{descriptor type} |
| 27 | + \lineii{\class{FSSpec}}{typeFSS} |
| 28 | + \lineii{\class{Alias}}{typeAlias} |
| 29 | + \lineii{integer}{typeLong (32 bit integer)} |
| 30 | + \lineii{float}{typeFloat (64 bit floating point)} |
| 31 | + \lineii{string}{typeText} |
| 32 | + \lineii{list}{typeAEList} |
| 33 | + \lineii{dictionary}{typeAERecord} |
| 34 | + \lineii{instance}{\emph{see below}} |
| 35 | +\end{tableii} |
| 36 | + |
| 37 | +\pytype{FSSpec} and \pytype{Alias} are built-in object types defined |
| 38 | +in the module \refmodule{macfs}. |
| 39 | + |
| 40 | +If \var{x} is a Python instance then this function attempts to call an |
| 41 | +\method{__aepack__()} method. This method should return an |
| 42 | +\pytype{AE.AEDesc} object. |
| 43 | + |
| 44 | +If the conversion \var{x} is not defined above, this function returns |
| 45 | +the Python string representation of a value (the repr() function) |
| 46 | +encoded as a text descriptor. |
| 47 | +\end{funcdesc} |
| 48 | + |
| 49 | +\begin{funcdesc}{unpack}{x} |
| 50 | + \var{x} must be an object of type \class{AEDesc}. This function |
| 51 | + returns a Python object representation of the data in the Apple |
| 52 | + Event descriptor \var{x}. Simple AppleEvent data types (integer, |
| 53 | + text, float) are returned as their obvious Python counterparts. |
| 54 | + Apple Event lists are returned as Python lists, and the list |
| 55 | + elements are recursively unpacked. Object references |
| 56 | + (ex. \code{line 3 of document 1}) are returned as instances of |
| 57 | + \class{aetypes.ObjectSpecifier}. AppleEvent descriptors with |
| 58 | + descriptor type typeFSS are returned as \class{FSSpec} |
| 59 | + objects. AppleEvent record descriptors are returned as Python |
| 60 | + dictionaries, with keys of type \class{?} and elements recursively |
| 61 | + unpacked. |
| 62 | +\end{funcdesc} |
| 63 | + |
| 64 | + |
| 65 | +\begin{seealso} |
| 66 | + \seemodule{AE}{Built-in access to Apple Event Manager routines.} |
| 67 | + \seemodule{aetypes}{Python definitions of codes for Apple Event |
| 68 | + descriptor types.} |
| 69 | + \seetitle[http://developer.apple.com/techpubs/mac/IAC/IAC-2.html]{ |
| 70 | + Inside Macintosh: Interapplication |
| 71 | + Communication}{Information about inter-process |
| 72 | + communications on the Macintosh.} |
| 73 | +\end{seealso} |
0 commit comments