mò &U²Ic@sƒdZdkZdkZdkZdkZdkZdkZdkZdkl Z ei ei dZ dZ dfd„ƒYZdS(s?Extension to execute code outside the Python shell window. This adds the following commands: - Check module does a full syntax check of the current module. It also runs the tabnanny to catch any inconsistent tabs. - Run module executes the module's code in the __main__ namespace. The window must have been saved previously. The module is added to sys.modules, and is also added to the __main__ namespace. XXX GvR Redesign this interface (yet again) as follows: - Present a dialog box for ``Run Module'' - Allow specify command line arguments in the dialog box N(sidleConft_sVError: Inconsistent indentation detected! This means that either: 1) your indentation is outright incorrect (easy to fix), or 2) your indentation mixes tabs and spaces in a way that depends on how many spaces a tab is worth. To fix case 2, change all tabs to spaces by using Select All followed by Untabify Region (both in the Edit menu).t ScriptBindingcBsqtZddddgfgZd„Zd„Zd„Zd „Zd „Zd „Z d „Z d „Z d„Z RS(Ntruns Check Modules<>s Run Modules<>cCs+||_|ii|_|ii|_dS(N(teditwintselftflisttroot(RR((t2/data/zmath/lib/python2.4/idlelib/ScriptBinding.pyt__init__4s cCsD|iƒ}|pdSn|i|ƒpdSn|i|ƒdS(N(Rt getfilenametfilenamettabnannyt checksyntax(RteventR ((Rtcheck_module_event;s  cCsÆt|dƒ}ytiti|iƒƒWn“tij oC}|\}\}}|ii|ƒ|idd|ƒtSnCtij o3}|ii|iƒƒ|idtƒtSnXtS(NtrsTabnanny Tokenizing ErrorsToken Error: %ssTab/space error(topenR tfR tprocess_tokensttokenizetgenerate_tokenstreadlinet TokenErrortmsgtmsgtxttlinenotstartRRtgotolineterrorboxtFalsetNannyNagtnagt get_linenotindent_messagetTrue(RR RRRRRR((RR Cs   c Cs²|iiƒ|_}|iƒ}|i|iƒt|dƒ}|i ƒ}|i ƒd|jo.tidd|ƒ}tidd|ƒ}n|o|ddjo|d}n|ii}|iddd ƒzÆyt||d ƒSWn«ttfj o™}y^|\} \}} } } |p(| || | | ff|_||_ n|i| | | ƒWnd t|ƒ} nX|id d | ƒt SnXWd|i|ƒXdS(NRs s\r\ns s\riÿÿÿÿtERRORs1.0tendtexecs*** s Syntax errors"There's an error in your program: (!RRt open_shelltshelltget_warning_streamt saved_streamtset_warning_streamtstderrRR RtreadtsourcetclosetretsubRttextt tag_removetcompilet SyntaxErrort OverflowErrorterrRt errorfilenameRtoffsettlinetargstcolorize_syntax_errortstrRR( RR R)R'R7R6RR1R-RR8RR9((RR Ts<         cCsÁ|ii}d|d|df}|id|ƒ|i|ƒ}|o(|t jo|id|d|ƒnd|i|ƒjo|i d|ƒn|i d|dƒ|i |ƒdS(Ns0.0 + %d lines + %d charsiR#s wordstarts tinserts+1c( RRR1RR8tposttag_addtgettchart IDENTCHARStmark_settsee(RRRR8R1R>RA((RR;us cCsª|iƒ}|pdSn|i|ƒ}|pdSn|i}|i}tio|i ƒnt i i |ƒ}|i d||fƒ|i|ƒ|i|ƒdS(sYRun the module after setting up the environment. First check the syntax. If OK, make sure the shell is active and then transfer the arguments, set the run environment's working directory to the directory of the module being executed and also add that directory to its sys.path if not already included. Nsuif 1: _filename = %r import sys as _sys from os.path import basename as _basename if (not _sys.argv or _basename(_sys.argv[0]) != _basename(_filename)): _sys.argv = [_filename] import os as _os _os.chdir(%r) del _filename, _sys, _basename, _os (RR R R tcodeR'tinterptPyShelltuse_subprocesst restart_shelltostpathtdirnamet runcommandtprepend_syspathtruncode(RR R'RFR RERL((Rtrun_module_event‚s     cCs¼|iii}|iiƒp™tidddddƒ}|o|o|iiidƒq¸|i ƒ}|ii i ƒ|djo&|iiidƒ|iii}q¸d}n|S(s±Get source filename. If not saved, offer to save (or create) file The debugger requires a source file. Make sure there is one, and that the current version of the source buffer has been saved. If the user declines to save or cancels the Save As dialog, return None. If the user has configured IDLE for Autosave, the file will be silently saved if it already exists and is dirty. tmaintGeneraltautosavettypetbooltokN(RRtioR t get_savedtidleConft GetOptionRStsavetNonetask_save_dialogtreplyR1t focus_set(RRSR R^((RR ¨s     c Cs[dddd}tiddd|dtid tid tid |iiƒ}|i ƒS( NsSource Must Be Saved it s OK to Save?ttitlesSave Before Run or ChecktmessageticonRTtdefaulttmaster( Rt tkMessageBoxtMessagetQUESTIONtOKCANCELtOKRRR1tmbtshow(RRRk((RR]Ãs    cCs0ti||d|iiƒ|iiiƒdS(NRe(Rft showerrorRaRbRRR1R_(RRaRb((RRÍs(s Check Modules<>(s Run Modules<>( t__name__t __module__R\tmenudefsRRR R R;RPR R]R(((RR-s    ! &  (t__doc__RJR/tstringR RRfRGt configHandlerRYt ascii_letterstdigitsRBR!R( R RrRYR/RGRfRR!RRJRB((Rt?s