o =?hQ @sdZddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z ddl m Z ddl mZd ZGd d d Zed krQdd lmZeddddSdS)aExecute 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) messagebox)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@sZeZdZddZddZddZddZd d Zd d d dZddZ ddZ ddZ dS) ScriptBindingcCs*||_|jj|_|jj|_g|_d|_dS)Ng)editwinflistrootcli_argsperf)selfr r8/opt/alt/python310/lib64/python3.10/idlelib/runscript.py__init__&s    zScriptBinding.__init__cCsNt|jtjr|jjdS|}|sdS||sdS||s%dSdS)Nbreak) isinstancer r OutputWindowtextbell getfilename checksyntaxtabnanny)reventfilenamerrrcheck_module_event0s   z ScriptBinding.check_module_eventc Cst|k}z tt|jWnVtjy@}z"|j\}\}}|j || dd|WYd}~WddSd}~wtj yg}z|j | | dt WYd}~WddSd}~wwWddS1sswYdS)NzTabnanny Tokenizing ErrorzToken Error: %sFzTab/space errorT)tokenizeopenrZprocess_tokensgenerate_tokensreadline TokenErrorargsr ZgotolineerrorboxZNannyNagZ get_linenoindent_message)rrfmsgZmsgtxtlinenostartZnagrrrr=s0        zScriptBinding.tabnannyc Cs|j|_}|}||jt|d }|}Wdn1s&wYd|vr;|dd}|dd}|rI|dt dkrI|d}|j }|j }| dddzdz t ||d WW||Stttfy}zGt|d d px|pxd } t|d d pd} t|dd pd} | dkr| d7} d| d| df} ||| |dd| WYd}~W||dSd}~ww||w)Nrb s  ZERRORz1.0endexecr&zr'offsetrz0.0 + %d lines + %d chars SyntaxErrorz%-20sF)r Z open_shellshellZget_warning_streamZset_warning_streamstderrrreadreplaceordr rZ tag_removecompiler2 OverflowError ValueErrorgetattrZcolorize_syntax_errorr#) rrr3Z saved_streamr%sourcer rvaluer&r'r1posrrrrOs>         zScriptBinding.checksyntaxcCs|j|ddS)NT customize)run_module_event)rrrrrrun_custom_eventmszScriptBinding.run_custom_eventFr?c Cs.trt|jdkrdSt|jtjr|jj dS| }|s&dS| |}|s/dS| |s6dS|rPd|jd}t|jj ||jdj}|sPdS|rT|ngdf\|_}|jj}tjrk|rk|jd|dtj|} |g} |jr|| |j7} |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. g?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 )rZ isCocoaTktime perf_counterr rr rrrrrrrZ short_titlerr3r resultinterprZuse_subprocessZrestart_subprocessospathdirnameZ runcommandZprepend_syspathZruncode) rrr@rcodetitleZrun_argsZrestartrFrIargvrrrrApsT         zScriptBinding.run_module_eventcCs||jjj}|jss$        0