Platforms: Mac
The 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 AEDesc, defined in module Carbon.AE.
The aepack module defines the following functions:
Returns an 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 |
|---|---|
| FSSpec | typeFSS |
| FSRef | typeFSRef |
| 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 __aepack__() method. This method should return an 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.
x must be an object of type 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 aetypes.ObjectSpecifier, unless formodulename is specified. AppleEvent descriptors with descriptor type typeFSS are returned as 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 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.
See also
关于本评注系统
本站使用上下文关联的评注系统来收集反馈信息。不同于一般对整章做评注的做法, 我们允许你对每一个独立的“文本块”做评注。一个“文本块”看起来是这样的:
一个“文本块”是一个段落,一个列表项,一段代码,或者其他一小段内容。 你选中它会高亮度显示:
要对文本块做评注,你只需要点击它旁边的标识块:
我们会仔细阅读每个评论,如果可能的话我们也会把评注考虑到未来的版本中去:
如果你愿意你的评注被采用,请确保留下你的全名 (注意不是昵称或简称)
Many, many thanks to Jack Slocum; the inspiration and much of the code for the comment system comes from Jack's blog, and this site couldn't have been built without his wonderful
YAHOO.extlibrary. Thanks also to Yahoo for YUI itself.