2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
:mod:`aetools` --- OSA client support
|
|
|
|
=====================================
|
|
|
|
|
|
|
|
.. module:: aetools
|
|
|
|
:platform: Mac
|
|
|
|
:synopsis: Basic support for sending Apple Events
|
|
|
|
.. sectionauthor:: Jack Jansen <Jack.Jansen@cwi.nl>
|
Merged revisions 59605-59624 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59606 | georg.brandl | 2007-12-29 11:57:00 +0100 (Sat, 29 Dec 2007) | 2 lines
Some cleanup in the docs.
........
r59611 | martin.v.loewis | 2007-12-29 19:49:21 +0100 (Sat, 29 Dec 2007) | 2 lines
Bug #1699: Define _BSD_SOURCE only on OpenBSD.
........
r59612 | raymond.hettinger | 2007-12-29 23:09:34 +0100 (Sat, 29 Dec 2007) | 1 line
Simpler documentation for itertools.tee(). Should be backported.
........
r59613 | raymond.hettinger | 2007-12-29 23:16:24 +0100 (Sat, 29 Dec 2007) | 1 line
Improve docs for itertools.groupby(). The use of xrange(0) to create a unique object is less obvious than object().
........
r59620 | christian.heimes | 2007-12-31 15:47:07 +0100 (Mon, 31 Dec 2007) | 3 lines
Added wininst-9.0.exe executable for VS 2008
Integrated bdist_wininst into PCBuild9 directory
........
r59621 | christian.heimes | 2007-12-31 15:51:18 +0100 (Mon, 31 Dec 2007) | 1 line
Moved PCbuild directory to PC/VS7.1
........
r59622 | christian.heimes | 2007-12-31 15:59:26 +0100 (Mon, 31 Dec 2007) | 1 line
Fix paths for build bot
........
r59623 | christian.heimes | 2007-12-31 16:02:41 +0100 (Mon, 31 Dec 2007) | 1 line
Fix paths for build bot, part 2
........
r59624 | christian.heimes | 2007-12-31 16:18:55 +0100 (Mon, 31 Dec 2007) | 1 line
Renamed PCBuild9 directory to PCBuild
........
2007-12-31 12:14:33 -04:00
|
|
|
.. moduleauthor:: Jack Jansen
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
The :mod:`aetools` module contains the basic functionality on which Python
|
|
|
|
AppleScript client support is built. It also imports and re-exports the core
|
|
|
|
functionality of the :mod:`aetypes` and :mod:`aepack` modules. The stub packages
|
|
|
|
generated by :mod:`gensuitemodule` import the relevant portions of
|
|
|
|
:mod:`aetools`, so usually you do not need to import it yourself. The exception
|
|
|
|
to this is when you cannot use a generated suite package and need lower-level
|
|
|
|
access to scripting.
|
|
|
|
|
|
|
|
The :mod:`aetools` module itself uses the AppleEvent support provided by the
|
|
|
|
:mod:`Carbon.AE` module. This has one drawback: you need access to the window
|
|
|
|
manager, see section :ref:`osx-gui-scripts` for details. This restriction may be
|
|
|
|
lifted in future releases.
|
|
|
|
|
|
|
|
The :mod:`aetools` module defines the following functions:
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: packevent(ae, parameters, attributes)
|
|
|
|
|
|
|
|
Stores parameters and attributes in a pre-created ``Carbon.AE.AEDesc`` object.
|
|
|
|
``parameters`` and ``attributes`` are dictionaries mapping 4-character OSA
|
|
|
|
parameter keys to Python objects. The objects are packed using
|
|
|
|
``aepack.pack()``.
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: unpackevent(ae[, formodulename])
|
|
|
|
|
|
|
|
Recursively unpacks a ``Carbon.AE.AEDesc`` event to Python objects. The function
|
|
|
|
returns the parameter dictionary and the attribute dictionary. The
|
|
|
|
``formodulename`` argument is used by generated stub packages to control where
|
|
|
|
AppleScript classes are looked up.
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: keysubst(arguments, keydict)
|
|
|
|
|
|
|
|
Converts a Python keyword argument dictionary ``arguments`` to the format
|
|
|
|
required by ``packevent`` by replacing the keys, which are Python identifiers,
|
|
|
|
by the four-character OSA keys according to the mapping specified in
|
|
|
|
``keydict``. Used by the generated suite packages.
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: enumsubst(arguments, key, edict)
|
|
|
|
|
|
|
|
If the ``arguments`` dictionary contains an entry for ``key`` convert the value
|
|
|
|
for that entry according to dictionary ``edict``. This converts human-readable
|
|
|
|
Python enumeration names to the OSA 4-character codes. Used by the generated
|
|
|
|
suite packages.
|
|
|
|
|
|
|
|
The :mod:`aetools` module defines the following class:
|
|
|
|
|
|
|
|
|
|
|
|
.. class:: TalkTo([signature=None, start=0, timeout=0])
|
|
|
|
|
|
|
|
Base class for the proxy used to talk to an application. ``signature`` overrides
|
|
|
|
the class attribute ``_signature`` (which is usually set by subclasses) and is
|
|
|
|
the 4-char creator code defining the application to talk to. ``start`` can be
|
|
|
|
set to true to enable running the application on class instantiation.
|
|
|
|
``timeout`` can be specified to change the default timeout used while waiting
|
|
|
|
for an AppleEvent reply.
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: TalkTo._start()
|
|
|
|
|
|
|
|
Test whether the application is running, and attempt to start it if not.
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: TalkTo.send(code, subcode[, parameters, attributes])
|
|
|
|
|
|
|
|
Create the AppleEvent ``Carbon.AE.AEDesc`` for the verb with the OSA designation
|
|
|
|
``code, subcode`` (which are the usual 4-character strings), pack the
|
|
|
|
``parameters`` and ``attributes`` into it, send it to the target application,
|
|
|
|
wait for the reply, unpack the reply with ``unpackevent`` and return the reply
|
|
|
|
appleevent, the unpacked return values as a dictionary and the return
|
|
|
|
attributes.
|
|
|
|
|