tzh
2024-08-22 c7d0944258c7d0943aa7b2211498fd612971ce27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
]\¬Qc @s¾dZddlmZedddƒddlTddlmZddlmZdd    lmZdd
lZdd
l    Z    dd
l
Z
ddl Tdd l m Z mZmZmZmZd Zd Zdddddddddddg Zd„Zdd„Ziid„Zd„Zd„Zd„Zd d+d!„ƒYZd"efd#„ƒYZed$ƒZd%„Zd&efd'„ƒYZ ie _!ie _"d(„Z#e$d)krºe#ƒe    j%d*ƒnd
S(,sçTools for use in AppleEvent clients and servers.
 
pack(x) converts a Python object to an AEDesc object
unpack(desc) does the reverse
 
packevent(event, parameters, attributes) sets params and attrs in an AEAppleEvent record
unpackevent(event) returns the parameters and attributes from an AEAppleEvent record
 
Plus...  Lots of classes and routines that help representing AE objects,
ranges, conditionals, logicals, etc., so you can write, e.g.:
 
    x = Character(1, Document("foobar"))
 
and pack(x) will create an AE object reference equivalent to AppleScript's
 
    character 1 of document "foobar"
 
Some of the stuff that appears to be exported from this module comes from other
files: the pack stuff from aepack, the objects from aetypes.
 
iÿÿÿÿ(twarnpy3ks&In 3.x, the aetools module is removed.t
stackleveli(t*(tAE(tEvt(t AppleEventsN(tpackkeytpacktunpacktcoercet
AEDescTypes aetools.Errori
ttrantrtidtevcltevidtaddrtoptkttimotintetesrctmisstfromcCs7y|jddƒ}Wntjk
r/}dSX|jS(NRtkeyw(tAEGetAttributeDescRtErrortNonetdata(taetdesctmsg((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pytmissed<s
tcCs\i}y|jddƒ}Wntjk
r2nXt||ƒ|d<~y|jddƒ}Wntjk
runXt||ƒ|d<~x8t|ƒ}|s¥Pnt|j|dƒ|ƒ||<qi}x‚tD]z}y|j|dƒ}WnHtjtjfk
r:}|ddkrÔ|ddkrԂqÔqÔnXt||ƒ||<qÔW||fS(Ns----s****terrnii[ùÿÿiXùÿÿ(tAEGetParamDescRRRRt
aekeywordsRtMacOS(Rt formodulenamet
parameterstdirobjtkeyt
attributesRR((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pyt unpackeventCs8 "  cCsdx*|jƒD]\}}t|||ƒq Wx0|jƒD]"\}}|j|t|ƒƒq:WdS(N(titemsRtAEPutAttributeDescR(RR%R(R'tvalue((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pyt    packeventcscCs}|jƒ}xj|jƒD]\}||krM||}||=||||<q|dkr||krtd|‚qqWdS(s>Replace long name keys by their 4-char counterparts, and checks----sUnknown keyword argument: %sN(tvaluestkeyst    TypeError(t    argumentstkeydicttoktktv((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pytkeysubstms  
cCsu||ks|dkrdS||}|jƒ}||krUt||ƒ||<n||krqtd|‚ndS(s7Substitute a single enum keyword argument, if it occursNsUnknown enumerator: %s(RR.tEnumR0(R1R'tedictR5R3((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pyt    enumsubstxs
   cCsd|d}|}d|kr)|d}ntj|ƒ}d|krQ|d}nd}|||fS(s2Create the 'best' argument for a raise MacOS.ErrorR terrsterobN(R#tGetErrorStringR(R1R terr_a1terr_a2terr_a3((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pyt decodeerrorƒs
    tTalkTocBsÒeZdZdZdZiZiZdZd„Z    e
e    ƒZ    dddd„Z d„Z d„Z iid„Zd„Ziid„Zd    „Zdid
„ZeZid d 6Zid „ZeZd„ZRS(s"An AE connection to an applicationicCs1|jr dStjƒsdStjddƒdS(Nii(t_TalkTo__eventloop_initializedR#t WMAvailableRt WaitNextEvent(tklass((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pyt__ensure_WMAvailablešs      cCsd|_|dkr!|j}nt|ƒtkr?||_n„t|ƒtkrrt|dƒrr|jƒ|_nQt|ƒt    krºt
|ƒdkrºt j t j|ƒ|_||_n    td‚t j|_t j|_|rí||_n t j|_|r |jƒndS(såCreate a communication channel with a particular application.
 
        Addressing the application is done by specifying either a
        4-byte signature, an AEDesc or an object that will __aepack__
        to an AEDesc.
        t
__aepack__is+signature should be 4-char string or AEDescN(Rttarget_signaturet
_signaturettypeR
ttargett InstanceTypethasattrRGt
StringTypetlenRt AECreateDescRttypeApplSignatureR0t kAEWaitReplyt
send_flagstkAENormalPriorityt send_priorityt send_timeouttkAEDefaultTimeoutt_start(tselft    signaturetstartttimeout((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pyt__init__£s$       !$         cCsŒy|jddƒWnqtjk
r‡t|jƒxQttƒD]?}y|jddƒWntjk
rqnXPtjdƒqAWnXdS(s/Start the application, if it is not running yettascrtnoopiN(    tsendRRt_launchRHtrangetLAUNCH_MAX_WAIT_TIMEttimetsleep(RYti((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pyRX¿s cCs|jƒdS(sDeprecated, used _start()N(RX(RY((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pyR[ÎscCs8tj|||jtjtjƒ}t|||ƒ|S(s.Create a complete structure for an apple event(RtAECreateAppleEventRKRtkAutoGenerateReturnIDtkAnyTransactionIDR-(RYtcodetsubcodeR%R(tevent((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pytneweventÒscCs[|jƒstd‚n|j|j|j|jƒ}t||jƒ\}}|||fS(s<Send a pre-created appleevent, await the reply and unpack its0No window manager access, cannot send AppleEvent(t_TalkTo__ensure_WMAvailablet RuntimeErrortAESendRSRURVR)t _moduleName(RYRltreplyR%R(((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pyt    sendeventÚs    cCs|j|j||||ƒƒS(sESend an appleevent given code/subcode/pars/attrs and unpack the reply(RsRm(RYRjRkR%R(((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pyR`ãscCs|jddƒdS(sSend 'activate' commandtmisctactvN(R`(RY((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pytactivateëscCsŸd}d}i|d6}|r2t|ƒ|d<n|j||||ƒ\}}}d|krqtt|ƒ‚nd|kr›|dS|r—|t_ntSdS(s¬_get: get data from an object
        Required argument: the object
        Keyword argument _attributes: AppleEvent attribute dictionary
        Returns: the data
        tcoretgetds----trtypR N(tmktypeR`RR@titemt    __class__(RYt_objecttasfilet _attributest_codet_subcodet
_argumentst_reply((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pyt_getïs     RttocKsƒd}d}t||jƒ||d<|j||||ƒ\}}}|jddƒrktt|ƒ‚nd|kr|dSdS(sËset: Set an object's data.
        Required argument: the object for the command
        Keyword argument to: The new value.
        Keyword argument _attributes: AppleEvent attribute dictionary
        Rwtsetds----R iN(R6t _argmap_setR`tgetRR@(RYR}RR‚R€RRƒ((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pyt_set s
  cCsY||jkr)|j|}t|dƒS||jkrL|j|}|ƒSt|‚dS(N(t    _elemdicttDelayedComponentItemRt    _propdicttAttributeError(RYtnametcls((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pyt __getattr__'s   N(t__name__t
__module__t__doc__RRIRqRŠRŒRBRnt classmethodR]RXR[RmRsR`RvR„RˆR‡R‰tsetR(((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pyRA’s,                         
 t _miniFindercBseZid„ZRS(cKsd}d}|rtd‚n||d<|j||||ƒ\}}}d|krgtt|ƒ‚nd|kr{|dSdS(s¤open: Open the specified object(s)
        Required argument: list of objects to open
        Keyword argument _attributes: AppleEvent attribute dictionary
        taevttodocsNo optional args expecteds----R N(R0R`RR@(RYR}RR‚R€RRƒ((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pytopen3s 
   (R‘R’R™(((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pyR–2stMACScCstjtd|fƒƒdS(s;Open a file thru the finder. Specify file by name or fsspecsID  N(t_finderR™t_application_file(tappfile((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pyRaJsRœcBseZdZdZRS(s0application file - An application's file on disktappf(R‘R’R“twant(((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pyRœOscCsÈtjddƒ}tjdd|ddƒ}t|ƒGHtdƒtjdd    |ddƒ}td
td td ƒƒƒ}|GHt|ƒGHt    |i|d 6ƒt|ƒ\}}|d GHtdƒdS( NtsigntquilR—toappiÿÿÿÿit:RwRxiis----(
RRPRgR)t    raw_inputt    CharactertWordtDocumenttreprR-(RKRtobjtparamstattrs((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pyttest[s 
     t__main__i((&R“twarningsRttypestCarbonRRRR#tsysRdtaetypestaepackRRRR    R
RRcR"RR)R-R6R9R@RAR–R›Rat ComponentItemRœRŒRŠR¬R‘texit(((sX/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/aetools.pyt<module>sR
 
(