Hacked By AnonymousFox
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<<run-module-event-2>>)�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 � z<no detail available>r! �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<<run-module-event-2>>)r r
Zevent_generater
)r r
r �<lambda>o s z0ScriptBinding.run_module_event.<locals>.<lambda>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>