appleevents - respond to Apple Events in Python without using pipe characters around keys in dictionary -


i use appscript , aemreceive in py2app bundled python 2.7 application accept incoming apple events , return app's output apple events external application communicates app.

this works quite well, 1 exception: when return dictionary, keys surrounded pipe characters need keys without these characters.

example: send response external app:

{has description:true, folder:file "travellerhd:users:andre:desktop:mynewfile"} 

instead app sends this:

{|has description|:true, |folder|:file "travellerhd:users:andre:desktop:mynewfile"} 

the event handler has been installed using code:

aemreceive.installeventhandler(get_property, "coregetd",                                ('----', 'request_string',                                 aemreceive.kae.typeaerecord),                               ) 

where "get_property" name of function gets invoked once external app requests location info item. function returns dictionary:

return {'has description': asset.has_description,         'folder': mactypes.file(asset.folder)} 

i have learned surrounding keys pipes necessary if want use apple events reserved words "folder" app's keys or if key uses spaces or non-ascii characters. when remove space "has description" or rename "folder" key "myfolder", app returns dictionary without surrounding keys pipes.

yet, external app communicates app requires app use keys empty spaces "folder" key.

any ideas?

thanks lot in advance.

figured out how works.

in sdef file properties defined:

<property name="has description" code="ashd" type="boolean" description="whether library has xml description."> </property> <property name="folder" code="asfd" type="file" description="directory in library files exist."> </property> 

instead of returning keys strings this:

return {'has description': asset.has_description,         'folder': mactypes.file(asset.folder)} 

i return 4 character codes , let aem heavy lifting:

return {aem.aetype('ashd'): asset.has_description,         aem.aetype('asfd'): mactypes.file(asset.folder)} 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -