3
§ f¡ ã @ s€ d Z ddlZddlZddlZddljZddlmZ ddl m
Z
ddl mZ dZG dd„ dƒZ
ed kr|dd
lmZ eddd
� dS )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)Úpyshella/ 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 @ sT e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd d
„ Zdd„ Zd
d„ Z dd„ Z
dd„ ZdS )Ú
ScriptBindingc C s8 || _ | j j| _| j j| _tjƒ r4| j jjd| jƒ d S )Nz<>)ÚeditwinÚflistÚrootr Ú isCocoaTkÚ
text_frameZbindÚ_run_module_event)Úselfr © r
ú6/opt/alt/python36/lib64/python3.6/idlelib/runscript.pyÚ__init__# s
zScriptBinding.__init__c C s0 | j ƒ }|sdS | j|ƒsdS | j|ƒs,dS dS )NÚbreak)ÚgetfilenameÚchecksyntaxÚtabnanny)r ÚeventÚfilenamer
r
r Úcheck_module_event- s
z ScriptBinding.check_module_eventc C sº t j|ƒ�¦}ytjt j|jƒƒ W nˆ t jk
rn } z.|j\}\}}| jj |ƒ | j
dd| ƒ dS d }~X n> tjk
rª } z | jj |jƒ ƒ | j
dt
ƒ dS d }~X nX W d Q R X dS )NzTabnanny Tokenizing ErrorzToken Error: %sFzTab/space errorT)ÚtokenizeÚopenr Zprocess_tokensÚgenerate_tokensÚreadlineÚ
TokenErrorÚargsr ZgotolineÚerrorboxZNannyNagZ
get_linenoÚindent_message)r r ÚfÚmsgZmsgtxtÚlinenoÚstartZnagr
r
r r 7 s
zScriptBinding.tabnannyc
C sZ | j jƒ | _}|jƒ }|j|jƒ t|dƒ�}|jƒ }W d Q R X d|krb|jddƒ}|jddƒ}|r~|d t dƒkr~|d }| j
}|j}|jdddƒ z°yt
||d ƒS tttfk
�rD } zzt|d
dƒpÒ|pÒd} t|d
dƒpâd}
t|ddƒpòd}|dk�r|
d7 }
d|
d |d f }|j||ƒ | jdd| ƒ dS d }~X nX W d |j|ƒ X d S )NÚrbó
s
ó
é ZERRORz1.0ÚendÚexecr Ú zr! Úoffsetr z0.0 + %d lines + %d charsÚSyntaxErrorz%-20sFéÿÿÿÿ)r Z
open_shellÚshellZget_warning_streamZset_warning_streamÚstderrr ÚreadÚreplaceÚordr ÚtextZ
tag_removeÚcompiler+ Ú
OverflowErrorÚ
ValueErrorÚgetattrZcolorize_syntax_errorr )
r r r- Zsaved_streamr Úsourcer r2 Úvaluer r! r* Úposr
r
r r I s4
zScriptBinding.checksyntaxc s2 t jƒ r$ˆ jjjd‡ fdd„ƒ dS ˆ j|ƒS d S )NéÈ c s ˆ j jjdƒS )Nz<>)r r
Zevent_generater
)r r
r Úo s z0ScriptBinding.run_module_event..r )r r r r
Úafterr )r r r
)r r Úrun_module_eventg s
zScriptBinding.run_module_eventc C sŒ | j ƒ }|sdS | j|ƒ}|s"dS | j|ƒs0dS | jj}tjrT|jd| jj |ƒd� t
jj|ƒ}|j
dj||d�ƒ |j|ƒ |j|ƒ dS )aX Run 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.
r F)Zwith_cwdr az if 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
)r Údirname)r r r r- Úinterpr Zuse_subprocessZrestart_subprocessr Z_filename_to_unicodeÚosÚpathr> Z
runcommandÚformatZprepend_syspathZruncode)r r r Úcoder? r> r
r
r r t s$
zScriptBinding._run_module_eventc C sx | j jj}| j jƒ sttjddddd�}|r>|r>| j jjdƒ n6| jƒ }| j jj ƒ |rp| j jjdƒ | j jj}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 Úior Z get_savedr Z GetOptionZsaveÚask_save_dialogr2 Ú focus_set)r r rE Úconfirmr
r
r r � s
zScriptBinding.getfilenamec C s d }t jd|t j| jjd�}|S )
NzSource Must Be Saved
é ú zOK to Save?zSave Before Run or Check)ÚtitleÚmessageÚdefaultÚparentz zSource Must Be Saved
z%Source Must Be Saved
OK to Save?)ÚtkMessageBoxZaskokcancelZOKr r2 )r r rK r
r
r rI ¸ s zScriptBinding.ask_save_dialogc C s$ t j||| jjd� | jjjƒ d S )N)rQ )rR Z showerrorr r2 rJ )r rN rO r
r
r r À s zScriptBinding.errorboxN)Ú__name__Ú
__module__Ú__qualname__r r r r r= r r rI r r
r
r
r r ! s
)r Ú__main__)rD z idlelib.idle_test.test_runscripté )Ú verbosity)Ú__doc__r@ r r Ztkinter.messageboxZ
messageboxrR Zidlelib.configr Zidlelibr r r r rS ZunittestrD r
r
r
r Ú s
&