a oe<@sdZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z m Z ddl mZmZmZmZmZmZdZdZddZd d Zd d ZGd dde jZGdddZGdddZGddde jZGddde jZddZefddZ e!dkre dS)zPython ActiveX Scripting Implementation This module implements the Python ActiveX Scripting client. To register the implementation, simply "run" this Python program - ie either double-click on it, or run "python.exe pyscript.py" from the command line. N)axscript) frameworkscriptdispatch)SCRIPTTEXT_FORCEEXECUTIONSCRIPTTEXT_ISEXPRESSIONSCRIPTTEXT_ISPERSISTENT Exception RaiseAsserttracez&{DF630910-1C1D-11d0-AE36-8C0F5E000000}cGstr t|dSN)debugging_attrr )argsrEC:\Program Files\Certbot\pkgs\win32comext\axscript\client\pyscript.pydebug_attr_print"srcCstdd|S)N z resubtextrrr ExpandTabs'srcCstdd|S)N z rrrrrAddCR+src@seZdZddZdS)AXScriptCodeBlockcCsdtj|S)Nz PyScript - )rrGetDisplayNameselfrrrr0sz AXScriptCodeBlock.GetDisplayNameN)__name__ __module__ __qualname__rrrrrr/src@s8eZdZdZddZddZddZdd Zd d Zd S) AXScriptAttributez$An attribute in a scripts namespace.cCs||jd<dSN_scriptEngine___dict__)renginerrr__init__=szAXScriptAttribute.__init__cCsB|ddkr$|dddkr$t|||}|dur>t||S)N_)AttributeError_FindAttribute_)rattrrcrrr __getattr__@s  zAXScriptAttribute.__getattr__cCsd|jd<dSr"r$rrrr_Close_HszAXScriptAttribute._Close_c Cshz|j|jWSty$Yn0|jD]*}z|||WStyXYq00q0t|dSr )subItemslowerattributeObjectKeyErrorvalues_DoFindAttribute_r+)robjr-itemrrrr6Ks  z#AXScriptAttribute._DoFindAttribute_c CsF|jjD]*}z|||WSty4Yq 0q t|jj|Sr )r#r1r5r6r+getattrglobalNameSpaceModule)rr-r8rrrr,Xs  z!AXScriptAttribute._FindAttribute_N) rrr __doc__r'r/r0r6r,rrrrr!:s  r!c@s8eZdZdZddZddZddZdd Zd d Zd S) NamedScriptAttributez3An explicitely named object in an objects namespacecCs||jd<dSN _scriptItem_r$)rZ scriptItemrrrr'mszNamedScriptAttribute.__init__cCsdt|jdS)Nz)reprr>rrrr__repr__pszNamedScriptAttribute.__repr__cCsNz|jj|jWSty@|jjrr1r2r3r4dispatchContainerr9r+)rr-rrrr/ss  z NamedScriptAttribute.__getattr__cCsB|}|jjr6zt|jj||WSty4Yn0t|dSr )r2r>rBsetattrr+)rr-valuerrr __setattr__}s z NamedScriptAttribute.__setattr__cCsd|jd<dSr=r$rrrrr0szNamedScriptAttribute._Close_N) rrr r;r'rAr/rEr0rrrrr<fs   r<c@s,eZdZddZddZddZddZd S) ScriptItemcCs$tj|||||i|_d|_dSr )rrFr' scriptletsr3)rZ parentItemnamedispatchflagsrrrr'szScriptItem.__init__cCs&tj||jr|jd|_dSr )rrFResetr3r0rrrrrKs  zScriptItem.ResetcCstj|d|_i|_dSr )rrFCloserBrGrrrrrLs zScriptItem.ClosecCstj|t||_|jrzL|}d}}|j}|d}z|j |}Wnt ydYn0Wnt j yd}Yn0|durt jj|j|d}|dur||j |<t jj|j||j|_dSNr)rrFRegisterr<r3rIZ GetEngineZ GetTypeInfoZ GetTypeAttrmapKnownCOMTypesr4 pythoncomZ com_errorwin32comZclientZdynamicZ MakeOleReprZ CDispatchrHrB)rr&ZolereprZclsidZtypeinforrrrNs.         zScriptItem.RegisterN)rrr r'rKrLrNrrrrrFsrFc@seZdZdZdZejejgZdZ e Z dZ ddgZ dZdd Zd d Zd d ZddZddZddZddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(S))PyScriptzPython.AXScript.2PythonzPython ActiveX Scripting Enginez*win32com.axscript.client.pyscript.PyScript).pys)pysFileZbothcCs"tj|d|_g|_d|_dSr )r COMScriptr'r: codeBlocksscriptDispatchrrrrr's zPyScript.__init__cCsRtj|ddl}d|_|d|_t||jjd<g|_ g|_ i|_ d|_ dS)NrZ __ax_main__ax) rrVInitNewimprXZ new_moduler:r!r%rWZpersistedCodeBlocksrOcodeBlockCounter)rr[rrrrZs  zPyScript.InitNewcCs|jD] }d|_qtj|SNr()rW beenExecutedrrVStop)rbrrrr_s z PyScript.StopcCsF|jdd}g|_|D] }|jt@rd|_|j|qtj|SrM)rWrJrr^appendrrVrK)rZ oldCodeBlocksr`rrrrKs zPyScript.ResetcCs|jd|_|jSr])r\rrrr_GetNextCodeBlockNumbers z PyScript._GetNextCodeBlockNumbercCs|j}tj|||s|r0|j|jj|j<| r|j D]}|j|jj|j<qB|j j jD]"\}}|jsft|j ||jj|<qfdSr )Z isRegisteredrrVRegisterNamedItemZ IsVisibler3r:r%rHZIsGlobalr1r5rBZ _olerepr_ZmapFuncsitemsZhiddenr9)rr8ZwasRegZsubitemrHentryrrrrcs zPyScript.RegisterNamedItemcCs>z6|jj}|jD]"}|js||dr|||qWn0dS)Nexec)r:r%rWr^CompileInScriptedSectionExecInScriptedSection)rglobs codeBlockrrrDoExecutePendingScripts s  z PyScript.DoExecutePendingScriptscCsdSr rrrrrDoRunszPyScript.DoRuncCs*|d|_g|_d|_tj|dSr )ResetNamespacer:rWrXrrVrLrrrrrLs zPyScript.ClosecCs |jdurt||j|_|jSr )rXrZMakeScriptDispatchr:)rrHrrrGetScriptDispatchs  zPyScript.GetScriptDispatchcCs4|d|ddd|d|ddS)Nrr(r))upper)r subItemName eventNamerrrMakeEventMethodName&s    zPyScript.MakeEventMethodNamec Cs`||} ||kr| } n| | |dd} |||} td| |||d} || | | j| <dS)NzScript Event %sr)Z GetNamedItemZGetCreateSubItemrrr_AddScriptCodeBlockrG) rZ defaultNamecodeZitemNamerprqZ delimitersourceContextCookiestartLineNumberr8ZsubItemfuncNamerjrrrDoAddScriptlet/s   zPyScript.DoAddScriptletcCs`||j|j}d}}z&|j|}t|t|kr<|}d}WntyPYn0|durd|} t|jdD]} | d| d} qt| d} | |d| sdSi} | ||j j | | |}||j|<|durs2    ,&5b