Exemplo n.º 1
0
    def __init__(self):
        # Clients may add/remove/replace encoder and decoder items:
        self.encoders = {
            NSAppleEventDescriptor.class__(): self.packdesc,
            type(None): self.packnone,
            bool: self.packbool,
            int: self.packint,
            float: self.packfloat,
            bytes: self.packbytes,
            str: self.packstr,
            list: self.packlist,
            tuple: self.packlist,
            dict: self.packdict,
            datetime.datetime: self.packdatetime,
            AEType: self.packtype,
            AEEnum: self.packenum,
        }
        if sys.version_info.major < 3:  # 2.7 compatibility
            self.encoders[unicode] = self.packstr

        self.decoders = {
            fourcharcode(k): v
            for k, v in {
                kae.typeNull: self.unpacknull,
                kae.typeBoolean: self.unpackboolean,
                kae.typeFalse: self.unpackboolean,
                kae.typeTrue: self.unpackboolean,
                kae.typeSInt32: self.unpacksint32,
                kae.typeIEEE64BitFloatingPoint: self.unpackfloat64,
                kae.typeUTF8Text: self.unpackunicodetext,
                kae.typeUTF16ExternalRepresentation: self.unpackunicodetext,
                kae.typeUnicodeText: self.unpackunicodetext,
                kae.typeLongDateTime: self.unpacklongdatetime,
                kae.typeAEList: self.unpackaelist,
                kae.typeAERecord: self.unpackaerecord,
                kae.typeAlias: self.unpackfile,
                kae.typeFSS: self.unpackfile,
                kae.typeFSRef: self.unpackfile,
                kae.typeFileURL: self.unpackfile,
                kae.typeType: self.unpacktype,
                kae.typeEnumeration: self.unpackenumeration,
            }.items()
        }
Exemplo n.º 2
0
    def __init__(self):
        # Clients may add/remove/replace encoder and decoder items:
        self.encoders = {
            NSAppleEventDescriptor.class__(): self.pack_description,
            type(None): self.pack_none,
            bool: self.pack_bool,
            int: self.pack_int,
            float: self.pack_float,
            bytes: self.pack_bytes,
            str: self.pack_str,
            list: self.pack_list,
            tuple: self.pack_list,
            dict: self.pack_dict,
            datetime.datetime: self.pack_datetime,
            AEType: self.pack_type,
            AEEnum: self.pack_enum,
        }

        self.decoders = {
            four_characters_code(k): v
            for k, v in {
                aeobjects.typeNull: self.unpack_null,
                aeobjects.typeBoolean: self.unpack_boolean,
                aeobjects.typeFalse: self.unpack_boolean,
                aeobjects.typeTrue: self.unpack_boolean,
                aeobjects.typeSInt32: self.unpack_s_int32,
                aeobjects.typeIEEE64BitFloatingPoint: self.unpack_float64,
                aeobjects.typeUTF8Text: self.unpack_unicode_text,
                aeobjects.typeUTF16ExternalRepresentation: self.unpack_unicode_text,
                aeobjects.typeUnicodeText: self.unpack_unicode_text,
                aeobjects.typeLongDateTime: self.unpack_long_datetime,
                aeobjects.typeAEList: self.unpack_ae_list,
                aeobjects.typeAERecord: self.unpack_ae_record,
                aeobjects.typeAlias: self.unpack_file,
                aeobjects.typeFSS: self.unpack_file,
                aeobjects.typeFSRef: self.unpack_file,
                aeobjects.typeFileURL: self.unpack_file,
                aeobjects.typeType: self.unpack_type,
                aeobjects.typeEnumeration: self.unpack_enumeration,
            }.items()
        }
Exemplo n.º 3
0
	def __init__(self):
		# Clients may add/remove/replace encoder and decoder items:
		self.encoders = {
				NSAppleEventDescriptor.class__(): self.packdesc,
				type(None): self.packnone,
				bool: self.packbool,
				int: self.packint,
				float: self.packfloat,
				bytes: self.packbytes,
				str: self.packstr,
				list: self.packlist,
				tuple: self.packlist,
				dict: self.packdict,
				datetime.datetime: self.packdatetime,
				AEType: self.packtype,
				AEEnum: self.packenum,
		}
		if sys.version_info.major < 3: # 2.7 compatibility
			self.encoders[unicode] = self.packstr
		
		self.decoders = {fourcharcode(k): v for k, v in {
				kae.typeNull: self.unpacknull,
				kae.typeBoolean: self.unpackboolean,
				kae.typeFalse: self.unpackboolean,
				kae.typeTrue: self.unpackboolean,
				kae.typeSInt32: self.unpacksint32,
				kae.typeIEEE64BitFloatingPoint: self.unpackfloat64,
				kae.typeUTF8Text: self.unpackunicodetext,
				kae.typeUTF16ExternalRepresentation: self.unpackunicodetext,
				kae.typeUnicodeText: self.unpackunicodetext,
				kae.typeLongDateTime: self.unpacklongdatetime,
				kae.typeAEList: self.unpackaelist,
				kae.typeAERecord: self.unpackaerecord,
				kae.typeAlias: self.unpackfile,
				kae.typeFSS: self.unpackfile,
				kae.typeFSRef: self.unpackfile,
				kae.typeFileURL: self.unpackfile,
				kae.typeType: self.unpacktype,
				kae.typeEnumeration: self.unpackenumeration,
		}.items()}