ž ©’f…c@s“dZddlZddlZddlZddlZddlZddljZddl m Z ddl m Z m Z ddlmZddl mZdZGdd „d ƒZdS( u?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 iN(u EditorWindow(uPyShellu IOBinding(uidleConf(u macosxSupportu/Error: Inconsistent indentation detected! 1) Your indentation is outright incorrect (easy to fix), OR 2) Your indentation mixes tabs and spaces. To fix case 2, change all tabs to spaces by using Edit->Select All followed by Format->Untabify Region and specify the number of columns used by each tab. cBs˜|EeZdZddddgfgZdd„Zdd „Zd d „Zd d „Zdd„Z dd„Z dd„Z dd„Z dd„Z dS(u ScriptBindingurunu Check Moduleu<>u Run Moduleu<>cCsS||_|jj|_|jj|_tjƒrO|jjjd|jƒndS(Nu<>(ueditwinuflisturootu macosxSupporturunningAsOSXAppu text_frameubindu_run_module_event(uselfueditwin((u:/opt/alt/python33/lib64/python3.3/idlelib/ScriptBinding.pyu__init__1s   uScriptBinding.__init__cCs@|jƒ}|sdS|j|ƒs)dS|j|ƒs<dSdS(Nubreak(u getfilenameu checksyntaxutabnanny(uselfueventufilename((u:/opt/alt/python33/lib64/python3.3/idlelib/ScriptBinding.pyucheck_module_event;s u ScriptBinding.check_module_eventcCsļtj|ƒŚ}ytjtj|jƒƒWn³tjk r“}z?|\}\}}|jj|ƒ|j dd|ƒdSWYdd}~XnRtj k rä}z/|jj|j ƒƒ|j dt ƒdSWYdd}~XnXWdQXdS(NuTabnanny Tokenizing ErroruToken Error: %suTab/space errorFT(utokenizeuopenutabnannyuprocess_tokensugenerate_tokensureadlineu TokenErrorueditwinugotolineuerrorboxuFalseuNannyNagu get_linenouindent_messageuTrue(uselfufilenameufumsgumsgtxtulinenoustartunag((u:/opt/alt/python33/lib64/python3.3/idlelib/ScriptBinding.pyutabnannyDs  uScriptBinding.tabnannyc !CsÜ|jjƒ|_}|jƒ}|j|jƒt|dƒ}|jƒ}WdQXd|kr‰|jddƒ}|jddƒ}n|r²|dt dƒkr²|d}n|j }|j }|j dddƒzšyt ||d ƒSWnÕtttfk rÅ}z¬t|d d ƒp'|p'd } t|d d ƒp?d} t|dd ƒpWd} | dkrs| d7} nd| d| df} |j|| ƒ|jdd| ƒdSWYdd}~XnXWd|j|ƒXdS(Nurbs s s iuERRORu1.0uenduexecumsguuulinenouoffsetiu0.0 + %d lines + %d charsu SyntaxErroru%-20si’’’’F(uflistu open_shellushelluget_warning_streamuset_warning_streamustderruopenureadureplaceuordueditwinutextu tag_removeucompileu SyntaxErroru OverflowErroru ValueErrorugetattrucolorize_syntax_erroruerrorboxuFalse( uselfufilenameushellu saved_streamufusourceueditwinutextuvalueumsgulinenouoffsetupos((u:/opt/alt/python33/lib64/python3.3/idlelib/ScriptBinding.pyu checksyntaxVs4       uScriptBinding.checksyntaxcsCtjƒr2ˆjjjd‡fdd†ƒdSˆj|ƒSdS(NiČcsˆjjjdƒS(Nu<>(ueditwinu text_frameuevent_generate((uself(u:/opt/alt/python33/lib64/python3.3/idlelib/ScriptBinding.pyu|su0ScriptBinding.run_module_event..ubreak(u macosxSupporturunningAsOSXAppueditwinu text_frameuafteru_run_module_event(uselfuevent((uselfu:/opt/alt/python33/lib64/python3.3/idlelib/ScriptBinding.pyurun_module_eventts  uScriptBinding.run_module_eventcCs¹|jƒ}|sdS|j|ƒ}|s/dS|j|ƒsBdS|jj}tjrj|jddƒnt j j |ƒ}|j dj d|d|ƒƒ|j|ƒ|j|ƒdS(uXRun 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. ubreakuwith_cwduzif 1: __file__ = {filename!r} import sys as _sys from os.path import basename as _basename if (not _sys.argv or _basename(_sys.argv[0]) != _basename(__file__)): _sys.argv = [__file__] import os as _os _os.chdir({dirname!r}) del _sys, _basename, _os ufilenameudirnameF(u getfilenameu checksyntaxutabnannyushelluinterpuPyShelluuse_subprocessurestart_subprocessuFalseuosupathudirnameu runcommanduformatuprepend_syspathuruncode(uselfueventufilenameucodeuinterpudirname((u:/opt/alt/python33/lib64/python3.3/idlelib/ScriptBinding.pyu_run_module_events"      uScriptBinding._run_module_eventcCsÆ|jjj}|jjƒs«tjdddddƒ}|r[|r[|jjjdƒq«|jƒ}|jj j ƒ|r¢|jjjdƒ|jjj}q«d}n|S(u±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. umainuGeneraluautosaveutypeuboolN( ueditwinuioufilenameu get_saveduidleConfu GetOptionusaveuNoneuask_save_dialogutextu focus_set(uselfufilenameuautosaveuconfirm((u:/opt/alt/python33/lib64/python3.3/idlelib/ScriptBinding.pyu getfilename©s     uScriptBinding.getfilenamec Cs?dd d}tjddd|dtjd |jjƒ}|S( NuSource Must Be Saved iu u OK to Save?utitleuSave Before Run or Checkumessageudefaultumasteru (u tkMessageBoxu askokcanceluOKueditwinutext(uselfumsguconfirm((u:/opt/alt/python33/lib64/python3.3/idlelib/ScriptBinding.pyuask_save_dialogÄs  uScriptBinding.ask_save_dialogcCs0tj||d|jjƒ|jjjƒdS(Numaster(u tkMessageBoxu showerrorueditwinutextu focus_set(uselfutitleumessage((u:/opt/alt/python33/lib64/python3.3/idlelib/ScriptBinding.pyuerrorboxĢsuScriptBinding.errorboxN(u Check Moduleu<>(u Run Moduleu<>(u__name__u __module__u __qualname__uNoneumenudefsu__init__ucheck_module_eventutabnannyu checksyntaxurun_module_eventu_run_module_eventu getfilenameuask_save_dialoguerrorbox(u __locals__((u:/opt/alt/python33/lib64/python3.3/idlelib/ScriptBinding.pyu ScriptBinding*s   (  u ScriptBinding(u__doc__uosureustringutabnannyutokenizeutkinter.messageboxu messageboxu tkMessageBoxuidlelib.EditorWindowu EditorWindowuidlelibuPyShellu IOBindinguidlelib.configHandleruidleConfu macosxSupportuindent_messageu ScriptBinding(((u:/opt/alt/python33/lib64/python3.3/idlelib/ScriptBinding.pyus