Your IP : 18.218.63.176


Current Path : /opt/alt/python35/lib64/python3.5/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/idlelib/__pycache__/ScriptBinding.cpython-35.opt-1.pyc



��Yf}�@s�dZddlZddlZddlZddljZddlmZddl	m
Z
ddlmZdZGdd�d�Z
dS)	a?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

�N)�PyShell)�idleConf)�
macosxSupporta/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@s�eZdZddddgfgZdd�Zd	d
�Zdd�Zd
d�Zdd�Zdd�Z	dd�Z
dd�Zdd�ZdS)�
ScriptBindingZrunN�Check Module�<<check-module>>�
Run Module�<<run-module>>cCsP||_|jj|_|jj|_tj�rL|jjjd|j�dS)Nz<<run-module-event-2>>)�editwin�flist�rootr�	isCocoaTk�
text_frameZbind�_run_module_event)�selfr
�r�:/opt/alt/python35/lib64/python3.5/idlelib/ScriptBinding.py�__init__/s
	zScriptBinding.__init__cCs@|j�}|sdS|j|�s)dS|j|�s<dSdS)N�break)�getfilename�checksyntax�tabnanny)r�event�filenamerrr�check_module_event9sz ScriptBinding.check_module_eventcCs�tj|���}ytjtj|j��Wn�tjk
r�}zB|j\}\}}|jj	|�|j
dd|�dSWYdd}~XnRtjk
r�}z/|jj	|j��|j
dt
�dSWYdd}~XnXWdQRXdS)NzTabnanny Tokenizing ErrorzToken Error: %sFzTab/space errorT)�tokenize�openrZprocess_tokens�generate_tokens�readline�
TokenError�argsr
Zgotoline�errorboxZNannyNagZ
get_lineno�indent_message)rr�f�msgZmsgtxt�lineno�startZnagrrrrBs	zScriptBinding.tabnannyc
Cs�|jj�|_}|j�}|j|j�t|d��}|j�}WdQRXd|kr�|jdd�}|jdd�}|r�|dt	d�kr�|d}|j
}|j}|jddd�z�yt
||d	�SWn�tttfk
r�}z�t|d
d�p"|p"d}	t|d
d�p:d}
t|dd�pRd}|dkrk|
d7}
d|
d|df}|j||�|jdd|	�dSWYdd}~XnXWd|j|�XdS)N�rbs
s
s
�ZERRORz1.0�end�execr$�z<no detail available>r%�offsetrz0.0 + %d lines + %d chars�SyntaxErrorz%-20sF���)rZ
open_shell�shellZget_warning_streamZset_warning_stream�stderrr�read�replace�ordr
�textZ
tag_remove�compiler-�
OverflowError�
ValueError�getattrZcolorize_syntax_errorr!)
rrr/Zsaved_streamr#�sourcer
r4�valuer$r%r,�posrrrrTs4
		
zScriptBinding.checksyntaxcsCtj�r2�jjjd�fdd��dS�j|�SdS)N��cs�jjjd�S)Nz<<run-module-event-2>>)r
rZevent_generater)rrr�<lambda>zsz0ScriptBinding.run_module_event.<locals>.<lambda>r)rr
r
r�afterr)rrr)rr�run_module_eventrs
zScriptBinding.run_module_eventcCs�|j�}|sdS|j|�}|s/dS|j|�sBdS|jj}tjry|jddd|jj	|��t
jj|�}|j
djd|d|��|j|�|j|�dS)aXRun 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.
        rZwith_cwdFrazif 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
            
�dirname)rrrr/�interprZuse_subprocessZrestart_subprocessr
Z_filename_to_unicode�os�pathr@Z
runcommand�formatZprepend_syspathZruncode)rrr�coderAr@rrrrs$		


zScriptBinding._run_module_eventcCs�|jjj}|jj�s�tjddddd�}|r[|r[|jjjd�nM|j�}|jjj	�|r�|jjjd�|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�type�boolN)
r
�iorZ	get_savedrZ	GetOptionZsave�ask_save_dialogr4�	focus_set)rrrG�confirmrrrr�szScriptBinding.getfilenamec	Cs?dd
d}tjddd|dtjd	|jj�}|S)NzSource Must Be Saved
�� zOK to Save?�titlezSave Before Run or Check�message�default�parentz     )�tkMessageBoxZaskokcancelZOKr
r4)rr$rMrrrrK�s	zScriptBinding.ask_save_dialogcCs0tj||d|jj�|jjj�dS)NrS)rTZ	showerrorr
r4rL)rrPrQrrrr!�szScriptBinding.errorbox)rr)rr	)
�__name__�
__module__�__qualname__Zmenudefsrrrrr?rrrKr!rrrrr(s
	
)r)�__doc__rBrrZtkinter.messageboxZ
messageboxrTZidlelibrZidlelib.configHandlerrrr"rrrrr�<module>s


?>