2007-08-15 11:28:01 -03:00
|
|
|
|
|
|
|
:mod:`aepack` --- Conversion between Python variables and AppleEvent data containers
|
|
|
|
====================================================================================
|
|
|
|
|
|
|
|
.. module:: aepack
|
|
|
|
:platform: Mac
|
|
|
|
:synopsis: Conversion between Python variables and AppleEvent data containers.
|
2008-05-12 18:42:13 -03:00
|
|
|
:deprecated:
|
2007-08-15 11:28:01 -03:00
|
|
|
.. sectionauthor:: Vincent Marchetti <vincem@en.com>
|
2007-12-29 06:57:00 -04:00
|
|
|
.. moduleauthor:: Jack Jansen
|
2007-08-15 11:28:01 -03:00
|
|
|
|
|
|
|
The :mod:`aepack` module defines functions for converting (packing) Python
|
|
|
|
variables to AppleEvent descriptors and back (unpacking). Within Python the
|
|
|
|
AppleEvent descriptor is handled by Python objects of built-in type
|
|
|
|
:class:`AEDesc`, defined in module :mod:`Carbon.AE`.
|
|
|
|
|
Merged revisions 72007-72010,72036-72037 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r72007 | georg.brandl | 2009-04-27 17:09:25 +0200 (Mo, 27 Apr 2009) | 1 line
#5856: fix typo s in traceback example.
........
r72008 | georg.brandl | 2009-04-27 17:10:44 +0200 (Mo, 27 Apr 2009) | 1 line
Remove ".. warning::" markup that doesnt contain warnings for users, rather todo items.
........
r72009 | georg.brandl | 2009-04-27 17:29:09 +0200 (Mo, 27 Apr 2009) | 3 lines
Demote warnings to notices where appropriate, following the goal that as few "red box" warnings
should clutter the docs as possible. Part 1: stuff that gets merged to Py3k.
........
r72010 | georg.brandl | 2009-04-27 17:29:26 +0200 (Mo, 27 Apr 2009) | 2 lines
Demote warnings to notices, part 2: stuff that is 2.x-only.
........
r72036 | georg.brandl | 2009-04-27 19:04:23 +0200 (Mo, 27 Apr 2009) | 1 line
#5848: small unittest doc patch.
........
r72037 | georg.brandl | 2009-04-27 19:09:53 +0200 (Mo, 27 Apr 2009) | 1 line
#5840: dont claim we dont support TLS.
........
2009-04-28 15:23:28 -03:00
|
|
|
.. note::
|
2008-05-12 18:42:13 -03:00
|
|
|
|
Merged revisions 72007-72010,72036-72037 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r72007 | georg.brandl | 2009-04-27 17:09:25 +0200 (Mo, 27 Apr 2009) | 1 line
#5856: fix typo s in traceback example.
........
r72008 | georg.brandl | 2009-04-27 17:10:44 +0200 (Mo, 27 Apr 2009) | 1 line
Remove ".. warning::" markup that doesnt contain warnings for users, rather todo items.
........
r72009 | georg.brandl | 2009-04-27 17:29:09 +0200 (Mo, 27 Apr 2009) | 3 lines
Demote warnings to notices where appropriate, following the goal that as few "red box" warnings
should clutter the docs as possible. Part 1: stuff that gets merged to Py3k.
........
r72010 | georg.brandl | 2009-04-27 17:29:26 +0200 (Mo, 27 Apr 2009) | 2 lines
Demote warnings to notices, part 2: stuff that is 2.x-only.
........
r72036 | georg.brandl | 2009-04-27 19:04:23 +0200 (Mo, 27 Apr 2009) | 1 line
#5848: small unittest doc patch.
........
r72037 | georg.brandl | 2009-04-27 19:09:53 +0200 (Mo, 27 Apr 2009) | 1 line
#5840: dont claim we dont support TLS.
........
2009-04-28 15:23:28 -03:00
|
|
|
This module has been removed in Python 3.x.
|
2008-05-12 18:42:13 -03:00
|
|
|
|
|
|
|
|
2007-08-15 11:28:01 -03:00
|
|
|
The :mod:`aepack` module defines the following functions:
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: pack(x[, forcetype])
|
|
|
|
|
|
|
|
Returns an :class:`AEDesc` object containing a conversion of Python value x. If
|
|
|
|
*forcetype* is provided it specifies the descriptor type of the result.
|
|
|
|
Otherwise, a default mapping of Python types to Apple Event descriptor types is
|
|
|
|
used, as follows:
|
|
|
|
|
|
|
|
+-----------------+-----------------------------------+
|
|
|
|
| Python type | descriptor type |
|
|
|
|
+=================+===================================+
|
|
|
|
| :class:`FSSpec` | typeFSS |
|
|
|
|
+-----------------+-----------------------------------+
|
|
|
|
| :class:`FSRef` | typeFSRef |
|
|
|
|
+-----------------+-----------------------------------+
|
|
|
|
| :class:`Alias` | typeAlias |
|
|
|
|
+-----------------+-----------------------------------+
|
|
|
|
| integer | typeLong (32 bit integer) |
|
|
|
|
+-----------------+-----------------------------------+
|
|
|
|
| float | typeFloat (64 bit floating point) |
|
|
|
|
+-----------------+-----------------------------------+
|
|
|
|
| string | typeText |
|
|
|
|
+-----------------+-----------------------------------+
|
|
|
|
| unicode | typeUnicodeText |
|
|
|
|
+-----------------+-----------------------------------+
|
|
|
|
| list | typeAEList |
|
|
|
|
+-----------------+-----------------------------------+
|
|
|
|
| dictionary | typeAERecord |
|
|
|
|
+-----------------+-----------------------------------+
|
|
|
|
| instance | *see below* |
|
|
|
|
+-----------------+-----------------------------------+
|
|
|
|
|
|
|
|
If *x* is a Python instance then this function attempts to call an
|
|
|
|
:meth:`__aepack__` method. This method should return an :class:`AEDesc` object.
|
|
|
|
|
|
|
|
If the conversion *x* is not defined above, this function returns the Python
|
|
|
|
string representation of a value (the repr() function) encoded as a text
|
|
|
|
descriptor.
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: unpack(x[, formodulename])
|
|
|
|
|
|
|
|
*x* must be an object of type :class:`AEDesc`. This function returns a Python
|
|
|
|
object representation of the data in the Apple Event descriptor *x*. Simple
|
|
|
|
AppleEvent data types (integer, text, float) are returned as their obvious
|
|
|
|
Python counterparts. Apple Event lists are returned as Python lists, and the
|
|
|
|
list elements are recursively unpacked. Object references (ex. ``line 3 of
|
|
|
|
document 1``) are returned as instances of :class:`aetypes.ObjectSpecifier`,
|
|
|
|
unless ``formodulename`` is specified. AppleEvent descriptors with descriptor
|
|
|
|
type typeFSS are returned as :class:`FSSpec` objects. AppleEvent record
|
|
|
|
descriptors are returned as Python dictionaries, with 4-character string keys
|
|
|
|
and elements recursively unpacked.
|
|
|
|
|
|
|
|
The optional ``formodulename`` argument is used by the stub packages generated
|
|
|
|
by :mod:`gensuitemodule`, and ensures that the OSA classes for object specifiers
|
|
|
|
are looked up in the correct module. This ensures that if, say, the Finder
|
|
|
|
returns an object specifier for a window you get an instance of
|
|
|
|
``Finder.Window`` and not a generic ``aetypes.Window``. The former knows about
|
|
|
|
all the properties and elements a window has in the Finder, while the latter
|
|
|
|
knows no such things.
|
|
|
|
|
|
|
|
|
|
|
|
.. seealso::
|
|
|
|
|
|
|
|
Module :mod:`Carbon.AE`
|
|
|
|
Built-in access to Apple Event Manager routines.
|
|
|
|
|
|
|
|
Module :mod:`aetypes`
|
|
|
|
Python definitions of codes for Apple Event descriptor types.
|