B ÓlñªŽ£ëã@sšdZddlZddlZddlZddlmZddlmZddl m Z ddl m Z ddl m Z ddl mZdZGd d „d ƒZed kr–dd lmZed dddS)a‹Execute code from an editor. Check module: do a full syntax check of the current module. Also run the tabnanny to catch any inconsistent tabs. Run module: also execute 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. TODO: Specify command line arguments in a dialog box. éN)ÚidleConf)Úmacosx)Úpyshell)Ú CustomRun)Úoutwina/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. c@sbeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd dœdd„Z dd„Z dd„Z dd„Z dS)Ú ScriptBindingcCs>||_|jj|_|jj|_g|_t ¡r:|jj d|j¡dS)Nz<>) ÚeditwinÚflistÚrootÚcli_argsrÚ isCocoaTkÚ text_frameZbindÚ_run_module_event)Úselfr©rú6/opt/alt/python37/lib64/python3.7/idlelib/runscript.pyÚ__init__%s   zScriptBinding.__init__cCsNt|jtjƒr|jj ¡dS| ¡}|s.dS| |¡ss    zScriptBinding.tabnannyc Cs\|j ¡|_}| ¡}| |j¡t|dƒ}| ¡}WdQRXd|krb| dd¡}| dd¡}|r~|dt dƒkr~|d}|j }|j }|  ddd¡z²y t ||d ƒStttfk rF}zzt|d d ƒpÒ|pÒd } t|d d ƒpâd} t|dd ƒpòd} | dkr| d7} d| d| df} | || ¡| dd| ¡dSd}~XYnXWd| |¡XdS)NÚrbó s ó éÿÿÿÿZERRORz1.0ÚendÚexecr'Úzr(éÚoffsetrz0.0 + %d lines + %d charsÚ SyntaxErrorz%-20sF)r Z open_shellÚshellZget_warning_streamZset_warning_streamÚstderrrÚreadÚreplaceÚordrrZ tag_removeÚcompiler3Ú OverflowErrorÚ ValueErrorÚgetattrZcolorize_syntax_errorr$) rrr4Z saved_streamr&ÚsourcerrÚvaluer'r(r2ÚposrrrrPs4       zScriptBinding.checksyntaxcs2t ¡r$ˆjj d‡fdd„¡dSˆ |¡SdS)NéÈcsˆjj d¡S)Nz<>)rr Zevent_generater)rrrÚvsz0ScriptBinding.run_module_event..r)rr rr Zafterr)rrr)rrÚrun_module_eventns  zScriptBinding.run_module_eventcCs|j|ddS)NT)Ú customize)r)rrrrrÚrun_custom_event|szScriptBinding.run_custom_eventF)rCc Cst|jtjƒr|jj ¡dS| ¡}|s.dS| |¡}|s@dS| |¡sNdS|r‚d|j  ¡›d}t |j j||j dj }|s‚dS|rŠ|ngdf\|_ }|j j}tjr¸|r¸|jd|dtj |¡} |g} |j rÚ| |j 7} | d|›d | ›d | ›d ¡| |¡| |¡dS) ayRun the module after setting up the environment. First check the syntax. Next get customization. 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. rz Customize z Run)r TF)Zwith_cwdrzif 1: __file__ = zi import sys as _sys from os.path import basename as _basename argv = zØ if (not _sys.argv or _basename(_sys.argv[0]) != _basename(__file__) or len(argv) > 1): _sys.argv = argv import os as _os _os.chdir(z:) del _sys, argv, _basename, _os )rrrrrrrrrZ short_titlerr4r ÚresultÚinterprZuse_subprocessZrestart_subprocessÚosÚpathÚdirnameZ runcommandZprepend_syspathZruncode) rrrCrÚcodeÚtitleZrun_argsZrestartrFrIÚargvrrrrs>             zScriptBinding._run_module_eventcCsx|jjj}|j ¡sttjddddd}|r>|r>|jj d¡n6| ¡}|jj  ¡|rp|jj d¡|jjj}nd}|S)a±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. ÚmainZGeneralÚautosaveÚbool)ÚtypeN) rÚiorZ get_savedrZ GetOptionZsaveÚask_save_dialogrÚ focus_set)rrrNÚconfirmrrrr¶s     zScriptBinding.getfilenamecCs d}tjd|tj|jjd}|S)Nz%Source Must Be Saved OK to Save?zSave Before Run or Check)rKÚmessageÚdefaultÚparent)Ú tkMessageBoxZ askokcancelZOKrr)rr'rTrrrrRÑs  zScriptBinding.ask_save_dialogcCs$tj|||jjd|jj ¡dS)N)rW)rXZ showerrorrrrS)rrKrUrrrr$ÙszScriptBinding.errorboxN) Ú__name__Ú __module__Ú __qualname__rrrrrBrDrrrRr$rrrrr#s  7rÚ__main__)rMz idlelib.idle_test.test_runscripté)Ú verbosity)Ú__doc__rGrrZtkinter.messageboxZ messageboxrXZidlelib.configrZidlelibrrZ idlelib.queryrrr%rrYZunittestrMrrrrÚ s      =