a „oeO%ã@s”dZddlZddlZddlZddlZddlZddlZddlZddl m Z dZ dd„Z dd„Z dd „ZGd d „d ƒZGd d „d ejjjƒZdd„ZdS)z�Exception and error handling. This contains the core exceptions that the implementations should raise as well as the IActiveScriptError interface code. éN)ÚaxscriptcCs tt|ƒƒS)z'Format a string suitable for an AX Host)Ú ExpandTabsÚAddCR©Útext©rúBC:\Program Files\Certbot\pkgs\win32comext\axscript\client\error.pyÚ FormatForAXsr cCst dd|¡S)Nú z ©ÚreÚsubrrrrrsrcCst dd|¡S)NÚ z r rrrrrsrc@sHeZdZdZejgZgd¢Zdd„Zdd„Z dd„Z d d „Z d d „Z d S)ÚIActiveScriptErrorzàAn implementation of IActiveScriptError The ActiveX Scripting host calls this client whenever we report an exception to it. This interface provides the exception details for the host to report to the user. )ÚGetSourceLineTextÚGetSourcePositionÚGetExceptionInfocCstd|ƒdS)Nz#IActiveScriptError QI - unknown IIDr)Úprint)ÚselfZiidrrrÚ_query_interface_.s z$IActiveScriptError._query_interface_cCs ||_dS©N©Ú exception)rÚexcrrrÚ_SetExceptionInfo2sz$IActiveScriptError._SetExceptionInfocCs|jjSr)rÚlinetext©rrrrr5sz$IActiveScriptError.GetSourceLineTextcCs&|jj}||jj|jjd|jjfS)Né)rÚ sourceContextÚlinenoÚ startLineNoÚcolno)rÚctxrrrr8s ýz$IActiveScriptError.GetSourcePositioncCs|jSrrrrrrrAsz#IActiveScriptError.GetExceptionInfoN) Ú__name__Ú __module__Ú __qualname__Ú__doc__rÚIID_IActiveScriptErrorZ_com_interfaces_Z_public_methods_rrrrrrrrrr#s rc@s@eZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dS)ÚAXScriptExceptionzÅA class used as a COM exception. Note this has attributes which conform to the standard attributes for COM exceptions, plus a few others specific to our IActiveScriptError object. cCsZtjjjj|dtjdd�|dur0d|_d|_n|j |_|j |_d|_ |  ||||¡dS)NzUnknown ExceptionzPython ActiveX Scripting Engine)Ú descriptionÚscodeÚsourcerÚ) Úwin32comÚserverrÚ COMExceptionÚ__init__ÚwinerrorÚDISP_E_EXCEPTIONrr ZsourceContextCookieZstartLineNumberrÚ&_AXScriptException__BuildFromException)rÚsiteÚ codeBlockÚexc_typeÚ exc_valueÚ exc_tracebackrrrr0Ms üzAXScriptException.__init__cCs^trddl}| ¡z.t|tƒr0| |||¡n| ||||¡Wnt ¡‚Yn0dS©Nr) Ú debuggingÚ linecacheÚ clearcacheÚ issubclassÚ SyntaxErrorÚ_BuildFromSyntaxErrorÚ_BuildFromOtherÚ tracebackÚ print_exc)rr4ÚtypeÚvalueÚtbr;rrrZ__BuildFromExceptionas z&AXScriptException.__BuildFromExceptionc Cs |j}z |d}Wnd|f}Yn0z,|d\}}}} |durHd}| durTd} Wnd}d}d}d} Yn0t|ƒ|_||_|d|_t|  ¡ƒ|_dS)NrzUnknown Error (%s)rr,ZUnknown)Úargsr r)rr!rÚrstripr) rr4rrErDÚmsgÚfilenamerÚoffsetÚlinerrrr?ps(    z'AXScriptException._BuildFromSyntaxErrorcCsÌd|_d|_tr2t |||¡}td |¡ƒ|_dSgd¢}d}|}|rt| ||¡\} } } } | dd…dkrlqt|j }qBg} |ràd}|}|rè| ||¡\} } } } | |vr¦qè|   d¡r¼| |_| |_ |   | | | | f¡|d}|j }q„nd}|}dg}|  t | ¡¡|tjk�rVd |j|jf}|jtjk�rF|j�rF|jd �rF|jd }|  d |¡n|  t ||¡¡tjd k�r¬tt|ƒƒD]*}t||ƒtu�r€|| d ¡||<�q€td |¡ƒ|_d}}}dS)Néÿÿÿÿrr,)Zr_importZr_reloadZr_openézs  ",