py-aem manual | 3. Packing and unpacking data

#

## 3. Packing and unpacking data

### Codecs

The `aem.Codecs` class provides methods for converting Python data to `aem.ae.AEDesc` objects, and vice-versa.

    Codecs

        Constructor:
            __init__(self)

        Methods:
            pack(self, data) -- convert Python data to an AEDesc; will
                    raise a TypeError if data's type/class is unsupported
                data : anything
                Result : AEDesc

            unpack(self, desc) -- convert an AEDesc to Python data;
                    will return AEDesc if it's an unsupported type
                desc : AEDesc
                Result : anything

### AE types

The Apple Event Manager defines several types for representing type/class names, enumerator names, etc. that have no direct equivalent in Python. Accordingly, AEM defines several classes to represent these types on the Python side. All share a common abstract base class, `AETypeBase`:

    AETypeBase -- Abstract base class

        Constructor:
            __init__(self, code)
                code : bytes -- a four-character Apple event code

        Properties:
            code : bytes (read-only) -- Apple event code

The four concrete classes are:

    AEType(AETypeBase) -- represents an AE object of typeType

    AEEnum(AETypeBase) -- represents an AE object of typeEnumeration

    AEProp(AETypeBase) -- represents an AE object of typeProperty

    AEKey(AETypeBase) -- represents an AE object of typeKeyword