a oeN@sddlZddlZddlZddlZddlZddlZddlZddlZddlm Z m Z ddl m Z m Z daddZddlmZeej_Gd d d e jZGd d d e jZeZdS) N)afxresdialog)app dbgcommands.pycCs8|}ddlm}||ddlm}||dS)Nrtoolmenuhelp)Z GetSharedMenupywin.frameworkr SetToolsMenur SetHelpMenuOtherHelp)selfZ sharedMenur r rCC:\Program Files\Certbot\pkgs\pythonwin\pywin\framework\intpyapp.py_SetupSharedMenu_s    r)docviewc@s,eZdZddZddZddZddZd S) MainFramecCsd|_tj||dkrdStjtjBtjBtj Btj B}| tj t ||tjB}|dtj|t j| tj |d||ddlm}|||}ddlm}||dddlm}||dS) NrZStandard)PrepareControlBarsrrr ) closingrrOnCreatewin32conZWS_CHILDrZCBRS_SIZE_DYNAMICZCBRS_TOPZ CBRS_TOOLTIPSZ CBRS_FLYBYZ EnableDockingZCBRS_ALIGN_ANYwin32uiZ CreateToolBarZ WS_VISIBLEZ ModifyStylecommctrlZ TBSTYLE_FLATZ LoadToolBarZ IDR_MAINFRAMEZ SetWindowTextZDockControlBarZpywin.debugger.debuggerrZGetMenur r r r r)rZ createStructZstyletbrZmenur r rrrr$s6         zMainFrame.OnCreatecCszPddl}|jjdurN|jjjrNz|jjdWntYn0WdSWntjydYn0d|_ | d| dddl m }||tj|tj|jS)NrrToolbarDefaultr )pywin.debuggerZdebuggerZcurrentDebuggerZpumpingclose traceback print_excrerrorrZ SaveBarStateZ SetActiveViewr r Z FinalizeHelpDestroyControlBarrZAFX_IDW_TOOLBARID_VIEW_TOOLBAR_DBG_obj_OnClose)rZpywinr rrrr(Hs*       zMainFrame.OnClosecCs2z||}Wntjy$YdS0|dSN)Z GetControlBarrr$Z DestroyWindow)ridZbarrrrr%ds zMainFrame.DestroyControlBarc CsFz|}|||rWdSWntjtfy6Yn0|j||SNr)Z GetActiveView OnCommandrr$AttributeErrorr')rZwparamZlparamvrrrr,ks  zMainFrame.OnCommandN)__name__ __module__ __qualname__rr(r%r,rrrrr#s$rc@seZdZddZddZddZddZd d Zd d Zd dZ d4ddZ ddZ d5ddZ ddZ ddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3ZdS)6InteractivePythonAppcCstj|t||jtj||j tj ||j tj | |jtj ||jtj||jtj||jtj| |jtj||jtj||jtj||jtj||jtj| |jtjdSr)) rCApp HookCommandsrZDebuggerCommandHandlerZ HookCommand OnViewBrowserZID_VIEW_BROWSE OnFileImportZID_FILE_IMPORT OnFileCheckZ ID_FILE_CHECKZHookCommandUpdateOnUpdateFileCheck OnFileRunZ ID_FILE_RUN OnFileLocateZID_FILE_LOCATEOnInteractiveWindowZID_VIEW_INTERACTIVEOnUpdateInteractiveWindow OnViewOptionsZID_VIEW_OPTIONS OnHelpIndexrZ ID_HELP_INDEX OnFileSaveAllZID_FILE_SAVE_ALLOnViewToolbarDbgr&OnUpdateViewToolbarDbgrrrrr4s"  z!InteractivePythonApp.HookCommandscCstSr))rrBrrrCreateMainFramesz$InteractivePythonApp.CreateMainFramecCs`zddlm}Wnty$YdS0||j}z|dd|WS|jyZYdS0dS)Nrintpydde PythonwinZSystem)rrE ImportErrorZCreateConversation ddeServerZ ConnectTor$)rrEconvrrrMakeExistingDDEConnections   z.InteractivePythonApp.MakeExistingDDEConnectioncCszddlm}Wnty,d|_d}Yn0|dur|||_|jd|jz6|}|dur|d| t j |durWdSWnt t dYdS0dS)NrrDrFzself.Activate()z+ - error in DDE conversation with Pythonwin)rrErGrHZ DDEServerZCreateZCBF_FAIL_SELFCONNECTIONSrJExec ProcessArgssysargvrDisplayTracebackexc_info)rrEZ connectionrrrInitDDEs&     zInteractivePythonApp.InitDDEcCsdtjvr6dtjvr6dtjvr6dtjvr6|r   z!InteractivePythonApp.InitInstancecCsTtzddlm}|Wn Yn0|jdurH|jd|_tj |SNrrV) rZDestroyDebuggerThreadrrWZDestroyInteractiveWindowrHZShutdownrr3 ExitInstancer]rrrr_s    z!InteractivePythonApp.ExitInstancecCs2t}||dtjkr.|tjdSr+)r GetMainFrameZSetForegroundWindowZGetWindowPlacementrZSW_SHOWMINIMIZEDZ ShowWindowZ SW_RESTORE)rr\rrrActivateszInteractivePythonApp.ActivateNc Cst|dks|dsdSd}|t|kr||}|d7}|drTd|dd}|dsxtddd}|d8}|t|kr||pd}|d vrq|d rt|td d}|r|d |n,dd lm}| }|r| | |dq|dkrl|d7}t |} tj| sBtd | t fdtjq|r\|dt| nt|q|dkr|r|d|d||ddfn*dd lm}||d||dddS|dkr6|r|d|d||ddfn,dd lm}||d||ddddS|dkrJtdq|dkr~|durj||n td|d7}qtd|qdS)Nrr-/PythonzDefault Arg Typez/editMISSING)rRrSrTrUz/goto:zvfrom pywin.framework import scriptutils ed = scriptutils.GetActiveEditControl() if ed: ed.SetSel(ed.LineIndex(%s - 1)) scriptutilsz"No such file: %s Command Line: %szOpen file for editz%win32ui.GetApp().OpenDocumentFile(%s)z/rundlgzHfrom pywin.framework import scriptutils;scriptutils.RunScript(%r, %r, 1) z/runzHfrom pywin.framework import scriptutils;scriptutils.RunScript(%r, %r, 0)z/appz6/app only supported for new instances of Pythonwin.exez/ddezDThe /dde command can only be used when Pythonwin is already runningz(Command line argument not recognised: %s)len startswithr GetProfileVallowerintrKrrgZGetActiveEditControlZSetSelZ LineIndexwin32apiZGetFullPathNameospathisfile MessageBoxZGetCommandLinerZ MB_ICONERRORreprGetAppOpenDocumentFilejoin RunScript RuntimeError ValueError) rargsZddeiZargTypeZparZgotolinergZedfnamerrrrLs                  z InteractivePythonApp.ProcessArgscCs|ddS)Nz,pywin.framework.editor,pywin.framework.stdin) DoLoadModulesrBrrrrZosz&InteractivePythonApp.LoadSystemModulescCs(|durd}tdd|}||dS)Nz6pywin.framework.sgrepmdi,pywin.framework.mdi_pycheckerrdzStartup Modules)rrkr})r moduleNamesdefaultrrrr[rsz$InteractivePythonApp.LoadUserModulescCs\|sdS|d}|D]@}z t|Wqtd|}t|t|Yq0qdS)N,z)Startup import of user module "%s" failed)split __import__r"r#printrrr)rr~modulesmodulemsgrrrr}ys  z"InteractivePythonApp.DoLoadModulescCs6zt|dWn td|tYn0dS)N zERROR executing DDE command: )execrr"r#)rZcommandrrr OnDDECommands  z!InteractivePythonApp.OnDDECommandcCsddlm}tddd}|dur&dSz|t|tjtjWnRty\t dYn8t yvt dYnt t d Yn0dS) z*Called when ViewBrowse message is receivedr)browserZObject __builtins__zBrowse Python ObjectNz This is no object with this namez(The object has no attribute of that namezThis object can not be browsed)Z pywin.toolsrrGetSimpleInputZBrowseeval__main____dict__ NameErrorrrrr-r"r#)rr*coderZobNamerrrr5s   z!InteractivePythonApp.OnViewBrowsecCsddlm}|dS)zRCalled when a FileImport message is received. Import the current or specified filerrfN)rrgZ ImportFilerr*rrgrrrr6s z!InteractivePythonApp.OnFileImportcCsddlm}|dS)zDCalled when a FileCheck message is received. Check the current file.rrfN)rrgZ CheckFilerrrrr7s z InteractivePythonApp.OnFileCheckcCs$ddlm}||ddudS)Nrrfr)rrgEnableZGetActiveFileName)rcmduirgrrrr8s z&InteractivePythonApp.OnUpdateFileCheckcCs.ddlm}ttjdk}|dd|dS)z*Called when a FileRun message is received.rrfrN)rrgrnZ GetKeyStaterZVK_SHIFTrw)rr*rrgZshowDlgrrrr9s zInteractivePythonApp.OnFileRuncCsddlm}tdtd}|dur&dS|atdddkrJtddatdda|t}|durxt d tnt |dS) Nrrfz File namezLocate Python Filer.\z The file '%s' can not be located) rrgrrlastLocateFileNamerlreplaceZLocatePythonFilerrrrtru)rr*rrgnameZnewNamerrrr:s    z!InteractivePythonApp.OnFileLocatec Csttd}ddlm}||ddlm }|| g}| D]0}z |j }Wnt yvYqRYn0||}qRzddlm} Wntyd} Yn0| dur|| |D]} || q|tjkrtddtdttjddtddS)NzPythonwin Optionsr) ideoptionsrr)configuiz!Applying configuration changes...)rZ InitRichEditrZ PropertySheetZ pywin.dialogsrZAddPageZOptionsPropPagerr ZToolMenuPropPageZGetDocTemplateListZGetPythonPropertyPagesr-r rrGappendZDebuggerOptionsPropPageZDoModalrZIDOK SetStatusTextZ DoWaitCursorr`ZSendMessageToDescendantsZWM_WININICHANGE) rr*rZsheetrr ZpagestemplategetterrZpagerrrr=s8             z"InteractivePythonApp.OnViewOptionscCsddlm}|dSr^)rrWZToggleInteractiveWindow)rr*rrWrrrr;s z(InteractivePythonApp.OnInteractiveWindowcCsDztjd}|}Wnty,d}Yn0|||dS)Nzpywin.framework.interactr)rMrZIsInteractiveWindowVisibleKeyErrorrZSetCheck)rrrWstaterrrr<s    z.InteractivePythonApp.OnUpdateInteractiveWindowcCsXddlm}d}|D]*}|r|rd}}||qtd|ddS)Nr)editorTemplaterz%d documents saved)Zpywin.framework.editorrZGetDocumentListZ IsModifiedZ GetPathNameZOnSaveDocumentrr)rr*rrZnumdocrrrr?s  z"InteractivePythonApp.OnFileSaveAllcCs|dkrt| SdS)Nr)rr`Z OnBarCheck)rr*rrrrr@sz%InteractivePythonApp.OnViewToolbarDbgcCst||ddSr+)rr`ZOnUpdateControlBarMenur)rrrrrrAsz+InteractivePythonApp.OnUpdateViewToolbarDbgcCsddlm}|dS)Nrr )rr ZSelectAndRunHelpFile)rr*rr rrrr>!s z InteractivePythonApp.OnHelpIndex)N)N)r/r0r1r4rCrJrQrYr_rarLrZr[r}rr5r6r7r8r9r:r=r;r<r?r@rAr>rrrrr2}s28  `  +  r2)rorMr"rrrnrrZ pywin.mfcrrrrrrrrZ DocTemplaterr3r2ZthisApprrrrs& Z1