AlkantarClanX12

Your IP : 3.21.46.68


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



��Yf���@s_ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZmZyddlTWn2ek
r�eddej�ejd�YnXddljZddlmZmZdd	lmZdd
lmZddl m!Z!ddl"m#Z#dd
l$m%Z%ddl&m'Z'ddl&m(Z(ddl&m)Z)ddl&m*Z*dZ+dZ,eja-ddl.Z.ddd�Z/dddd�Z0da1dd�Z2e2d�dej3dd�Z4e4e_3Gdd�de�Z5Gdd�de�Z6Gd d!�d!e�Z7Gd"d#�d#e!�Z8Gd$d%�d%e'j9�Z:Gd&d'�d'e
�Z;Gd(d)�d)e#�Z<Gd*d+�d+e
j=�Z>Gd,d-�d-e>�Z?Gd.d/�d/e>�Z@d0d1�ZAd2ZBd3d4�ZCeDd5krQejEd5ejEd)<eC�e2d6�dS)7�N)�InteractiveInterpreter)�python_version�system)�*zJ** IDLE can't import Tkinter.
Your Python may not be configured for Tk. **�file�)�EditorWindow�
fixwordbreaks)�FileList)�ColorDelegator)�
UndoDelegator)�OutputWindow)�idleConf)�rpc)�Debugger)�RemoteDebugger)�
macosxSupportz	127.0.0.1cCssd}|d||f7}|dkr8tj||�}|j�}|rX|d|7}|d|j|f7}|S)zFormat warnings the IDLE way.z!
Warning (from warnings module):
z  File "%s", line %s
Nz    %s
z%s: %s
)�	linecache�getline�strip�__name__)�message�category�filename�lineno�line�s�r�4/opt/alt/python35/lib64/python3.5/idlelib/PyShell.py�idle_formatwarning0srcCsd|dkrt}y3|jt||||d|��|jd�Wnttfk
r_YnXdS)aShow Idle-format warning (after replacing warnings.showwarning).

    The differences are the formatter called, the file=None replacement,
    which can be None, the capture of the consequence AttributeError,
    and the output of a hard-coded prompt.
    Nrz>>> )�warning_stream�writer�AttributeError�OSError)rrrrrrrrr�idle_showwarning=s	r$cCsF|r'tdkrBtjatt_ntdk	rBtt_dadS)z>Replace warning.showwarning with idle_showwarning, or reverse.N)�_warnings_showwarning�warnings�showwarningr$)Zcapturerrr�capture_warningsPs		r(TcCsxtj}i}xKt|�D]=}|dd�|dd�dkr|j|�||<qW||�|j|�dS)aoExtend linecache.checkcache to preserve the <pyshell#...> entries

    Rather than repeating the linecache code, patch it to save the
    <pyshell#...> entries, call the original linecache.checkcache()
    (skipping them), and then restore the saved entries.

    orig_checkcache is bound at definition time to the original
    method, allowing it to be patched.
    Nrz<>���)r�cache�list�pop�update)rZorig_checkcacher*�save�keyrrr�extended_linecache_checkcache_s	$
r0c@s�eZdZdZdd�Zd'd(d)d*d+d,gZddd�Zdd�Zd
dd�Zd
dd�Z	dd�Z
dd�Zdd �Zd!d"�Z
d#d$�Zd%d&�Zd
S)-�PyShellEditorWindowz6Regular text edit window in IDLE, supports breakpointscGs�g|_tj||�|jjd|j�|jjd|j�|jjd|jj�t	j
jtj
�d�|_|jj|dd�}|jj|�|jjr�|j�|j�dS)Nz<<set-breakpoint-here>>z<<clear-breakpoint-here>>z<<open-python-shell>>zbreakpoints.lstcSs|j�|�dS)N)�restore_file_breaks)Zold_hook�selfrrr�filename_changed_hook�s
z;PyShellEditorWindow.__init__.<locals>.filename_changed_hook)�breakpointsr�__init__�text�bind�set_breakpoint_here�clear_breakpoint_here�flist�
open_shell�os�path�joinrZ
GetUserCfgDir�breakpointPath�ioZfilename_change_hookZset_filename_change_hookrr2�color_breakpoint_text)r3�argsr4rrrr6ys		
zPyShellEditorWindow.__init__�Cut�<<cut>>�rmenu_check_cut�Copy�<<copy>>�rmenu_check_copy�Paste�	<<paste>>�rmenu_check_pasteN�Set Breakpoint�<<set-breakpoint-here>>�Clear Breakpoint�<<clear-breakpoint-here>>TcCsc|jdkrdS|r:tj�}tj|d�}nddddi}|jjd|�dS)z,Turn colorizing of breakpoint text on or offN�break�
foreground��
background�BREAK)rAr�CurrentTheme�GetHighlightr7Z
tag_config)r3Zcolor�themeZcfgrrrrB�sz)PyShellEditorWindow.color_breakpoint_textcCs�|j}|jj}|jdd|d|d�y|jj|�Wn"tk
rl|jj|�YnXy&|jj	j
j}|j||�WnYnXdS)NrUz%d.0r)
r7rAr�tag_addr5�index�
ValueError�appendr;�pyshell�interp�debuggerr9)r3rr7r�debugrrr�set_breakpoint�s	
z"PyShellEditorWindow.set_breakpointcCsU|j}|jj}|s)|j�dStt|jd���}|j|�dS)N�insert)r7rAr�bell�int�floatrZra)r3�eventr7rrrrrr9�s	
z'PyShellEditorWindow.set_breakpoint_herecCs�|j}|jj}|s)|j�dStt|jd���}y|jj|�WnYnX|j	ddd�y&|j
jjj
}|j||�WnYnXdS)NrbrUzinsert linestartzinsert lineend +1char)r7rArrcrdrerZr5�remove�
tag_remover;r]r^r_r:)r3rfr7rrr`rrrr:�s"	
z)PyShellEditorWindow.clear_breakpoint_herec	Cs�|jr||j}|jj}|s2|j�dSg|_|jddt�y#|jjj	j
}|j|�WnYnXdS)NrUz1.0)r5r7rArrcrhZENDr;r]r^r_�clear_file_breaks)r3r7rr`rrrri�s		
	z%PyShellEditorWindow.clear_file_breaksc Cs[|j}|jj}y,t|jd��}|j�}WdQRXWntk
r[g}YnXy�t|jd��p}x.|D]&}|j|d�s{|j|�q{W|j	�|j}|r�|j|dt
|�d�WdQRXWnotk
rV}zOt|jdd�sDd|j_
tjd	d
ddt
|�d
|j�WYdd}~XnXdS)z#Save breakpoints when file is saved�rN�w�=�
�breakpoint_error_displayedFT�titlez
IDLE Errorrz$Unable to update breakpoint list:
%s�parent)r5rAr�openr@�	readlinesr#�
startswithr!�update_breakpoints�str�getattr�rootrn�tkMessageBox�	showerrorr7)r3Zbreaksr�fp�linesZnew_filer�errrrr�store_file_breaks�s.	


	*
z%PyShellEditorWindow.store_file_breakscCs�|jj�|jdkr dS|jj}|dkr<dStjj|j�r�t|jd��}|j	�}WdQRXx_|D]W}|j
|d�r�t|t|�dd��}x|D]}|j
|�q�Wq�WdS)Nrjrlr)r7r-rArr=r>�isfiler@rqrrrs�eval�lenra)r3rrzr{rZbreakpoint_linenumbersZbreakpoint_linenumberrrrr2s

 
z'PyShellEditorWindow.restore_file_breakscCs4|j}|jd�}|j|�}||_dS)z3Retrieves all the breakpoints in the current windowrUN)r7Z
tag_ranges�ranges_to_linenumbersr5)r3r7�rangesZlinenumber_listrrrrts	z&PyShellEditorWindow.update_breakpointscCs�g}x�tdt|�d�D]f}tt||j��}tt||dj��}x'||kr�|j|�|d7}q^WqW|S)Nr�r)�ranger�rdre�stringr\)r3r�r{rZr�endrrrr�s
z)PyShellEditorWindow.ranges_to_linenumberscCs|j�tj|�dS)z7Extend base method - clear breaks when module is closedN)rir�_close)r3rrrr�-s
zPyShellEditorWindow._close)rDrErF)rGrHrI)rJrKrL)NNN)rMrNN)rOrPN)r�
__module__�__qualname__�__doc__r6Zrmenu_specsrBrar9r:rir}r2rtr�r�rrrrr1vs$		*r1c@s1eZdZdZeZdZddd�ZdS)�PyShellFileListz8Extend base class: IDLE supports a shell and breakpointsNcCsN|jr|jjj�n+t|�|_|jrG|jj�sGdS|jS)N)r]�top�wakeup�PyShell�begin)r3rfrrrr<<s		zPyShellFileList.open_shell)rr�r�r�r1rr]r<rrrrr�3sr�c@sFeZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�ModifiedColorDelegatorz8Extend base class: colorizer for the shell window itselfcCstj|�|j�dS)N)rr6�LoadTagDefs)r3rrrr6Js
zModifiedColorDelegator.__init__cCs7|jddd�|jddd�tj|�dS)NZTODOz1.0�iomarkZSYNC)rhrYr�recolorize_main)r3rrrr�Nsz&ModifiedColorDelegator.recolorize_maincCsutj|�tj�}|jjdddddidtj|d�dtj|d�dtj|d�i�dS)N�stdinrTrR�stdout�stderr�console)rr�rrV�tagdefsr-rW)r3rXrrrr�Ss
	z"ModifiedColorDelegator.LoadTagDefscCs+x$|jD]}|j|dd�q
WdS)Nr�r�)r�rh)r3�tagrrr�removecolors]sz#ModifiedColorDelegator.removecolorsN)rr�r�r�r6r�r�r�rrrrr�Gs

r�c@s4eZdZdZddd�Zddd�ZdS)�ModifiedUndoDelegatorz;Extend base class: forbid insert/delete before the I/O markNc
Cs\y-|jj|dd�r,|jj�dSWntk
rAYnXtj||||�dS)N�<r�)�delegate�comparerc�TclErrorrrb)r3rZ�chars�tagsrrrrbes

zModifiedUndoDelegator.insertcCsYy-|jj|dd�r,|jj�dSWntk
rAYnXtj|||�dS)Nr�r�)r�r�rcr�r�delete)r3Zindex1Zindex2rrrr�ns

zModifiedUndoDelegator.delete)rr�r�r�rbr�rrrrr�bs	r�c@seZdZdd�ZdS)�MyRPCClientcCs
t�dS)z0Override the base class - just re-raise EOFErrorN)�EOFError)r3rrr�
handle_EOFzszMyRPCClient.handle_EOFN)rr�r�r�rrrrr�xsr�c@s�eZdZdd�ZdZdZdZdd�Zdd�Zdd	�Z	d
ddd
�Z
dd�Zdd�Zdd�Z
dd�Zd
dd�ZdZdd�ZdZdd�Zdd�Zdd�Zd d!�Zd"Zd#d$�Zdd%d&�Zd'd(�Zd)d*�Zd+d,�Zdd-d.�Zd/d0�Zd1d2�Zd3d4�Z d5d6�Z!d7d8�Z"d9d:�Z#d;d<�Z$d=d>�Z%dS)?�ModifiedInterpretercCsf||_tjdj}tj|d|�d|_d|_d|_t	|_
|jjj
|_dS)N�__main__�localsF)�	tkconsole�sys�modules�__dict__rr6�save_warnings_filters�
restarting�subprocess_arglist�PORT�port�compile�compiler�flags�original_compiler_flags)r3r�r�rrrr6�s					zModifiedInterpreter.__init__NcCs7|jdkr|j�|_tj|j�|_dS)N)r��build_subprocess_arglist�
subprocess�Popen�
rpcsubproc)r3rrr�spawn_subprocess�sz$ModifiedInterpreter.spawn_subprocesscCs�dd�tjD�}tjddddddd	�}td
krSd|f}n
d|f}tjg|d
|t|j�gS)NcSsg|]}d|�qS)z-Wr)�.0rrrr�
<listcomp>�s	z@ModifiedInterpreter.build_subprocess_arglist.<locals>.<listcomp>�main�Generalzdelete-exitfunc�defaultF�type�boolzidlelib.PyShellz&__import__('idlelib.run').run.main(%r)z__import__('run').main(%r)z-c)r��warnoptionsr�	GetOptionr�
executablerur�)r3rkZ	del_exitfZcommandrrrr��s
z,ModifiedInterpreter.build_subprocess_arglistcCs�t|jf}xXtd�D]<}tj|�yt|�|_PWqtk
rWYqXqW|j�dS|jj	j
�d|_tdkr�|jj	jt
jt
jd�|j�|jj	jd�y|jj�Wn#t
jk
r|j�dSYnX|jjd|j�|jjd|jj�|jjd|jj�|jjd|jj�|jjd	|jj�|jjd
t�|jjd|�|jdd
�|j�|jS)N�rr�
r�r�r�r�r;rr^�with_cwdT)�HOSTr�r��timeZsleepr��rpccltr#�display_port_binding_error�listening_sockZgetsocknamer�Z
setsockopt�socketZ
SOL_SOCKETZSO_REUSEADDRr�Z
settimeout�accept�timeout�display_no_subprocess_error�registerr�r�r�r�r;r�
transfer_path�poll_subprocess)r3Zaddr�irrr�start_subprocess�s>

	



	
z$ModifiedInterpreter.start_subprocessFrScCs�|jr|jSd|_|j�}|rJytj|j�WnYnX|jj�|j�|j}|j}d|_|j	�y|jj
�Wn#tjk
r�|j
�dSYnX|jd|�|j�|jjdd�d|r�|nd}t|j�t|�dd	d
}|jdj||��|jjdd�|jjdd
�|st|j�|r�tj|j�|j�|j|jj_d|_|jS)NTFr�r�zend-1cz	RESTART: ZShell�r�rlz
{0} {1} {0}�restart�left) r�r��getdebuggerrZclose_subprocess_debugger�close�terminate_subprocessr��	executingr�r�r�r�r�r��
stop_readliner7r�rd�widthr�r!�format�mark_set�mark_gravity�
showpromptZrestart_subprocess_debugger�load_breakpointsr�r�r�r�)r3r�rr`r�Z
was_executingr�Zhalfbarrrr�restart_subprocess�sH		

			

	
%

	z&ModifiedInterpreter.restart_subprocesscCs|jjddfi�dS)N�execZinterrupt_the_server)r�Z
remotecall)r3rrrZ__request_interrupt�sz'ModifiedInterpreter.__request_interruptcCstjd|j�j�dS)N�target)�	threadingZThread�'_ModifiedInterpreter__request_interrupt�start)r3rrr�interrupt_subprocess�sz(ModifiedInterpreter.interrupt_subprocesscCs�|jdk	r%|jjj|j�y|jjj�Wntk
rMYnXy|jj�Wntk
rsYnX|j�d|j_	d|_dS)NF)
�_afteridr�r7Zafter_cancelr�r�r�r"r�r�)r3rrr�kill_subprocesss


z#ModifiedInterpreter.kill_subprocesscCsXy|jj�Wntk
r)dSYn+Xy|jj�Wntk
rSdSYnXdS)z"Make sure subprocess is terminatedN)r��killr#�wait)r3rrrr�s
	
z(ModifiedInterpreter.terminate_subprocesscCsC|r"dg}|jtj�n	tj}|jd|f�dS)NrSzRif 1:
        import sys as _sys
        _sys.path = %r
        del _sys
        
)�extendr�r>�
runcommand)r3r�r>rrrr�s		z!ModifiedInterpreter.transfer_pathcCs�|j}|dkrdSy|j|jdd�}Wn;tttfk
rr|jjr^dSd}|j�YnX|rd|jj	�d|_|\}}|jj
}|dkr�|dk	r>tt|�d|�nf|dkr|jj
d�r>|j�n;|dkr>d}t||dtj�t||d|�y|jj�Wntk
rcYnX|jjs�|jjj|jj|j�|_dS)	Nr�g�������?ZOKrZ	EXCEPTIONz<<toggle-jit-stack-viewer>>�ERRORz/PyShell.ModifiedInterpreter: Subprocess ERROR:
)r�Zpollresponse�
active_seqr�r#�KeyboardInterruptr��closingr��resetoutputr��print�repr�getvar�remote_stack_viewerr��
__stderr__�endexecutingr"r7�after�pollintervalr�r�)r3Zclt�responseZhowZwhatr��errmsgrrrr�,s@	
	

z#ModifiedInterpreter.poll_subprocesscCs
||_dS)N)r_)r3r_rrr�setdebuggerTszModifiedInterpreter.setdebuggercCs|jS)N)r_)r3rrrr�WszModifiedInterpreter.getdebuggercCs|jjjd|j�dS)a�Initiate the remote stack viewer from a separate thread.

        This method is called from the subprocess, and by returning from this
        method we allow the subprocess to unblock.  After a bit the shell
        requests the subprocess to open the remote stack viewer which returns a
        static object looking at the last exception.  It is queried through
        the RPC mechanism.

        i,N)r�r7r�r�)r3rrr�open_remote_stack_viewerZs
z,ModifiedInterpreter.open_remote_stack_viewercCs�ddlm}|jjdddi�}|dkrK|jjj�dS|j|j|�}ddlm	}m
}t|jj�}tj
�}tj|d�d}||d	|d
d�}	|	jjddd
d�||	jd|�}
|
j�dS)Nr)�RemoteObjectBrowserr�Zstackviewerr;)�ScrolledCanvas�TreeNodeZnormalrTZbgZhighlightthickness�expandrZfillZboth)r;)�idlelibrr��remotequeuer�rwrcZStubObjectTreeItemZidlelib.TreeWidgetrrZToplevelrrVrW�frameZpackZcanvasr)r3rZoid�itemrrr�rXrTZscZnoderrrr�gsz'ModifiedInterpreter.remote_stack_viewerrcCs#|j|�}|j||�dS)z1Like runsource() but assumes complete exec sourceN)�stuffsource�execfile)r3�sourcerrrr�
execsourcezszModifiedInterpreter.execsourcecCs�|dkr1tj|��}|j�}WdQRXyt||d�}WnXttfk
r�|jj�tdd|jj	�t
j||�|jj�YnX|j
|�dS)zExecute an existing fileNr�zB*** Error in script or command!
Traceback (most recent call last):r)�tokenizerq�readr��
OverflowError�SyntaxErrorr�r�r�r�r�showsyntaxerrorr��runcode)r3rrrz�coderrrrs
	
zModifiedInterpreter.execfilec
Cs�|j|�}d|_tjdd�|_tjdddt�ztj|||�SWd|jdk	r�|jtjdd�<d|_XdS)zBExtend base class method: Stuff the source in the line cache firstrN�action�errorr)	r
Zmorer&�filtersr��filterwarnings�
SyntaxWarningr�	runsource)r3rrrrrr�s	zModifiedInterpreter.runsourcecCsSd|j}|jd|_|jd�}t|�dd||ftj|<|S)z"Stuff source in the filename cachez<pyshell#%d>rrmr)�gid�splitr�rr*)r3rrr{rrrr
�s

#zModifiedInterpreter.stuffsourcecCs|jd|f�dS)z>Prepend sys.path with file's directory if not already includeda(if 1:
            _filename = %r
            import sys as _sys
            from os.path import dirname as _dirname
            _dir = _dirname(_filename)
            if not _dir in _sys.path:
                _sys.path.insert(0, _dir)
            del _filename, _sys, _dirname, _dir
            
N)r�)r3rrrr�prepend_syspath�sz#ModifiedInterpreter.prepend_syspathcCs|j}|j}|jddd�tj�\}}}t|dd�pU|pUd}t|dd�pmd}t|d	d�p�d
}	|	d
kr�|d7}|dkr�d|	d}
nd|d|	df}
|j||
�|j�|jd
|�|j	�dS)z�Override Interactive Interpreter method: Use Colorizing

        Color the offending position instead of printing it and pointing at it
        with a caret.

        r�z1.0r��msgrSz<no detail available>rr�offsetrziomark + %d charsz&iomark linestart + %d lines + %d charszSyntaxError: %s
N)
r�r7rhr��exc_inforvZcolorize_syntax_errorr�r!r�)r3rr�r7r��value�tbrrr�posrrrr�s"		

z#ModifiedInterpreter.showsyntaxerrorcCsG|jj�|j�tj|�|jjd�rC|jj�dS)z1Extend base class method to reset output properlyz<<toggle-jit-stack-viewer>>N)r�r��checklinecacher�
showtracebackr��open_stack_viewer)r3rrrr%�s



z!ModifiedInterpreter.showtracebackcCsUtj}xEt|j��D]1}|dd�|dd�dkr||=qWdS)Nrz<>r))rr*r+�keys)r3�cr/rrrr$�s	$z"ModifiedInterpreter.checklinecachecCsV|jjr|j�dS|jrB|jjdd|fi�nt||j�dS)z*Run the code without invoking the debuggerrr�rr)r�r��display_executing_dialogr�rr�r�)r3rrrrr��s
	zModifiedInterpreter.runcommandcCs�|jjr|jj�|j�|jdk	rQ|jtjdd�<d|_|j}zNyw|jj	�|r�|j
dk	r�|j
jdd|fi�|_n,|r�|j
||j�nt||j�Wn�tk
r.|jjs'tjddddd|jj�r�q*|j�n�Ynytrgtd	d
|jj�|j�|jj�n;|jjr�d|j_tdd
|jj�n
|j�YnXWdts�y|jj�Wntk
r�YnXXdS)
zOverride base class methodNr�rzExit?zDo you want to exit altogether?r��yesrpz IDLE internal error in runcode()rFr�)r�r�r^r�r$r�r&rr_�beginexecutingr�Z
asyncqueuer�Zrunr�r��
SystemExitr�rxZaskyesnor7r%�use_subprocessr�r�r��canceledr")r3rr_rrrr�sP

		


	


zModifiedInterpreter.runcodecCs|jjj|�S)zOverride base class method)r�r�r!)r3rrrrr!"szModifiedInterpreter.writecCs tjddd|jj�dS)NzPort Binding ErroraAIDLE can't bind to a TCP/IP port, which is necessary to communicate with its Python execution server.  This might be because no networking is installed on this computer.  Run IDLE with the -n command line switch to start without a subprocess and refer to Help/IDLE Help 'Running without a subprocess' for further details.rp)rxryr�r7)r3rrrr�&sz.ModifiedInterpreter.display_port_binding_errorcCs tjddd|jj�dS)NzSubprocess Startup Errorz�IDLE's subprocess didn't make connection.  Either IDLE can't start a subprocess or personal firewall software is blocking the connection.rp)rxryr�r7)r3rrrr�1sz/ModifiedInterpreter.display_no_subprocess_errorcCs tjddd|jj�dS)NzAlready executingzYThe Python Shell window is already executing a command; please wait until it is finished.rp)rxryr�r7)r3rrrr)9sz,ModifiedInterpreter.display_executing_dialog)&rr�r�r6r�r�r�r�r�r�r�r�r�r�r�r�r�r�r_rr�rr�rr
rrr
rrr%r$r�rr!r�r�r)rrrrr�sF
+-

&
1r�cs/eZdZde�dZeZeZdVdWdXdYdZd[gZ	ddl
mZddd�Zdd�Z
dZdZdZdZdZdZdd�Zdd�Zddd�Zdd�Zddd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Z d1Z!d2d3�Z"d4d5�Z#d6d7�Z$d8d9�Z%dd:d;�Z&d<d=�Z'd>d?�Z(d@dA�Z)dBdC�Z*dDdE�Z+ddFdG�Z,ddHdI�Z-ddJdK�Z.dLdM�Z/dNdO�Z0fdPdQ�Z1�fdRdS�Z2�fdTdU�Z3�S)\r�zPython z Shellr�_File�edit�_Editr`�_Debug�options�_Options�windows�_Window�help�_Helpr)�HistoryNc	Cs�tr3|j}|dddkr3|jdd�t|�|_|dkrwt�}t|�|j�t|�}t	j
||dd�d|_d|_d|_
|j}|jdd�|jd	|j�|jd
|j�|jd|j�|jd|j�|jd
|j�|jd|j�|jd|j�trr|jd|j�|jd|j�tj|_tj|_tj|_ ddl!m"}t#|d|j$�|_t%|d|j$�|_t%|d|j$�|_t%|d|j$�|_&ts0|jt_|jt_|jt_yddl'}|j(|_)Wntj*t_�YnX|j+|j�|_,d|_-dS)Nr�r�shell�She_llT�Zwrap�charz<<newline-and-indent>>z<<plain-newline-and-indent>>z<<interrupt-execution>>z<<end-of-file>>z<<open-stack-viewer>>z<<toggle-debugger>>z<<toggle-jit-stack-viewer>>z<<view-restart>>z<<restart-shell>>)�	IOBindingr�r�r�r��2)r:r;).r-�
menu_specsrbr�r^�Tkr	�withdrawr�r
r6ZusetabsZindentwidthZcontext_use_ps1r7Z	configurer8�enter_callback�linefeed_callback�cancel_callback�eof_callbackr&�toggle_debugger�toggle_jit_stack_viewer�view_restart_mark�
restart_shellr�r��save_stdoutr��save_stderrr��
save_stdinrr>�PseudoInputFile�encoding�PseudoOutputFiler��pydocZ
plainpagerZpagerr�r9�historyr�)r3r;Zmsrwr7r>rQrrrr6Ws\		

				zPyShell.__init__cCstjdd�S)NZ
shell_onlyT)rZ
GetExtensions)r3rrr�get_standard_extension_names�sz$PyShell.get_standard_extension_namesFcCs
|adS)N)r )r3�streamrrr�set_warning_stream�szPyShell.set_warning_streamcCstS)N)r )r3rrr�get_warning_stream�szPyShell.get_warning_streamcCs`|jr0tjddd|j�|j�dS|jj�}|rR|j�n
|j�dS)NzDon't debug nowz*You can only toggle the debugger when idlerprQ)	r�rxryr7�set_debugger_indicatorr^r��close_debugger�
open_debugger)r3rf�dbrrrrG�s		


zPyShell.toggle_debuggercCs%|jj�}|jd|�dS)Nz<<toggle-debugger>>)r^r�Zsetvar)r3rZrrrrW�szPyShell.set_debugger_indicatorcCsdS)Nr)r3rfrrrrH�szPyShell.toggle_jit_stack_viewercCs�|jj�}|r{|jjd�|j�|jjrNtj|jj�|j�|jj	d�dt
_|j�|j
�dS)Nz[DEBUG OFF]
z>>> )r^r�rr�r�rZclose_remote_debuggerr�r�r!r��ps1r�rW)r3rZrrrrX�s

	
zPyShell.close_debuggercCsq|jjr'tj|jj|�}ntj|�}|jj|�|j�dt_|j	�|j
�dS)Nz[DEBUG ON]
>>> )r^r�rZstart_remote_debuggerrrr�r�r[r�rW)r3Zdbg_guirrrrY�s
	
zPyShell.open_debuggercCs|j�d|_dS)zHelper for ModifiedInterpreterrN)r�r�)r3rrrr+�s
zPyShell.beginexecutingcCs d|_d|_|j�dS)zHelper for ModifiedInterpreterrN)r�r.r�)r3rrrr��s		zPyShell.endexecutingcCsc|jr:tjddddd|j�}|dkr:dS|j�d|_d|_tj|�S)	zExtend EditorWindow.close()zKill?z7Your program is still running!
 Do you want to kill it?r��okrpFZcancelT)	r�rxZaskokcancelr7r�r.r�rr�)r3r�rrrr��s	
		z
PyShell.closecCsy|j�tr|jj�|jt_|jt_|j	t_
d|_d|_d|j_
d|_tj|�dS)zEExtend EditorWindow._close(), shut down debugger and execution serverN)rXr-r^r�rKr�r�rLr�rMr�r�r;r]rRrr�)r3rrrr��s

			zPyShell._closecCsdS)z8Override EditorWindow method: never remove the colorizerTr)r3rrrr�ispythonsource�szPyShell.ispythonsourcecCs|jS)N)�shell_title)r3rrr�short_title�szPyShell.short_titlez@Type "copyright", "credits" or "license()" for more information.cCs�|jjdd�|j�trOd}|jj�}|sm|j�dSndddd}tjt	_|j
d	t	jt	j|j
|f�|jj�|j�d
dl}d|_dS)Nr�rbrSFz==== No Subprocess ====

z9WARNING: Running IDLE without a Subprocess is deprecated
z;and will be removed in a later version. See Help/IDLE Help
zfor details.

zPython %s on %s
%s
%srT)r7r�r�r-r^r�r�r�displayhookr�r!�version�platform�	COPYRIGHTZfocus_forcer��tkinterZ
_default_root)r3ZnosubZclientrdrrrr�s$

	

	z
PyShell.begincCs'|js
dSd|_|jj�dS)NT)�reading�_stop_readline_flagr��quit)r3rrrr�s		zPyShell.stop_readlinecCs�|j}zd|_|jj�Wd||_X|jrFd|_dS|jjdd�}t|�dkrsd}|j�|jr�d|_t	s�t
�|jr�d|_d}|S)NrFrSr�zend-1crrm)rer��mainlooprfr7�getr�r�r.r-r��	endoffile)r3r.rrrr�readline"s(		
		
				zPyShell.readlinecCsdS)NTr)r3rrr�isatty9szPyShell.isattyc
Cs�y |jjddd�rdSWnYnX|jp:|jse|j�|jjd�|j�dSd|_d|_	|jr�|jj
r�|jj�r�|jj�n
|jj
�|jr�|jj�dS)Nz	sel.firstz!=zsel.lastzKeyboardInterrupt
rQrr)r7r�r�rer�r^r!r�rjr.r�r�r�r�r�rg)r3rfrrrrE<s&

		
	
zPyShell.cancel_callbackcCs�|jr|jrdS|jjddd�oD|jjddd�sKdS|jsk|j�|j�nd|_d|_|jj	�dS)Nr�z==rbzend-1crrrQ)
r�rer7r�r�r�r.rjr�rg)r3rfrrrrFRs	

		
zPyShell.eof_callbackcCs@|jr/|jjdd�|jjd�n
|j|�dS)NrbrmrQ)rer7rb�see�newline_and_indent_event)r3rfrrrrDas
	
zPyShell.linefeed_callbackcCs�|jr|jrdSyK|jjdd�}|ra|jjddd�ra|j||�dSWnYnX|jjddd�r�|jjd	d�}|r�|jjdd|d
�r�|j|jj|d|d
�|�dS|jjd	d�}|rI|jjdd
|d�rI|j|jj|d|d
�|�dS|jjdd�}|r�|jj|ddd�r�|j|jj|d
d�|�n|j|jjdd�|�dS|jjddd�r�|jjdd�|jjdd�}|r/|j	�r/|jj
dd�|jjddd�rX|j|�dS|jjdd�|jr�|jjdd�|jj
d�n
|j|�|jjd	dd�|jj�|jr�|jj�n
|j�dS)Nz	sel.firstzsel.lastz<=r�rQrbr�ziomark linestartr�rrzinsert lineendz>=r�zinsert linestartzend-1czend-1c linestartrm)r�rer7rir��recallZ
tag_prevrangeZ
tag_nextranger�rr�rnrbrmrYZupdate_idletasksr�rg�runit)r3rf�sel�prev�next�indicesrrrrrCjsX"'"'&
	

	
zPyShell.enter_callbackcCs�tjdd|�}tjdd|�}|jd�}|jj�zC|jjddd�|jjdd	�|jjd
d�}|j�j	d�r�|j
|�|jjd
d�}|jjd|dj��t
|�d
kr�tjd|d�jd�}tjd|�jd�}x^|d
d�D]L}|j|�rg||t
|�d�}|jjdd|j��q8WWd|jjd�|jj�XdS)Nz^\s*\nrSz\n\s*$rmrqz1.0r�rbzend-1czinsert linestart�:rrz	^([ \t]*))�re�subrr7Zundo_block_startrhr�ri�rstrip�endswithrnrbrr��search�grouprsrmZundo_block_stop)r3rrfr{�prefixZorig_base_indentZnew_base_indentrrrrro�s*

%zPyShell.recallcCs�|jjdd�}t|�}x.|dkrQ||ddkrQ|d}q$W|dkr|||ddkr||d}x.|dkr�||ddkr�|d}qW|d|�}|jj|�dS)Nr�zend-1crrz 	rm)r7rir�r^r)r3rr�rrrrp�s# 
#z
PyShell.runitcCss|jjr|jj�SytjWn%tjddd|j�dSYnXddlm	}||j
|j�dS)NzNo stack tracez@There is no stack trace yet.
(sys.last_traceback is not defined)rpr)�StackBrowser)r^r�r�r��last_tracebackrxryr7Zidlelib.StackViewerr}rwr;)r3rfr}rrrr&�s
	
	zPyShell.open_stack_viewercCs$|jjd�|jjd�dS)Nr�r�)r7rm)r3rfrrrrI�szPyShell.view_restart_markcCs|jjdd�dS)z&Callback for Run/Restart Shell Cntl-F6r�TN)r^r�)r3rfrrrrJ�szPyShell.restart_shellc	Csl|j�yttj�}Wnd}YnX|jj|�|jjdd�|j�|j	j
�dS)NrSrbzend-1c)r�rur�r[r�r!r7r��set_line_and_columnrAZ
reset_undo)r3rrrrr��s

zPyShell.showpromptcCsz|jjdd�}|jr.|jj|�|jjd�dkrY|jjdd�|jjdd�|j�dS)Nr�zend-1czend-2crm)r7rirRZstorerbr�r)r3rrrrr��s	zPyShell.resetoutputcCs�t|t�rst|�rst|�dkrsx't|�D]\}}|dkr:Pq:Wtd|||dd��yB|jjdd�tj	|||d�}|jjdd�Wn�YnX|j
r�d|_
ts�t�|S)	Nu￿zUCS-2rz%Non-BMP character not supported in Tkr��rightr�r)
�
isinstancerur��max�	enumerate�UnicodeEncodeErrorr7r�r
r!r.r-r�)r3rr�r�r=�countrrrr!�s"-			z
PyShell.writecsFy |jjddd�rdSWntk
r8dSYnXt�j�S)Nz	sel.firstr�r��disabled)r7r�r��superrF)r3)�	__class__rrrFs
	zPyShell.rmenu_check_cutcs)|jjddd�rdSt�j�S)Nrbr�r�r�)r7r�r�rL)r3)r�rrrLszPyShell.rmenu_check_paste)rr/)r0r1)r`r2)r3r4)r5r6)r7r8)4rr�r�rr^r�rr�rr@Zidlelib.IdleHistoryr9r6rSrer�r.rjr�rfrUrVrGrWrHrXrYr+r�r�r�r]r_rcr�r�rkrlrErFrDrCrorpr&rIrJr�r�r!rFrLrr)r�rr�Asd	:
	?	r�c@sOeZdZddd�Zedd��Zedd��Zdd	�ZdS)
�
PseudoFileNcCs||_||_||_dS)N)r:r��	_encoding)r3r:r�rOrrrr6"s		zPseudoFile.__init__cCs|jS)N)r�)r3rrrrO'szPseudoFile.encodingcCsd|jS)Nz<%s>)r�)r3rrr�name+szPseudoFile.namecCsdS)NTr)r3rrrrl/szPseudoFile.isatty)rr�r�r6�propertyrOr�rlrrrrr� sr�c@s(eZdZdd�Zdd�ZdS)rPcCsdS)NTr)r3rrr�writable5szPseudoOutputFile.writablecCst|jrtd��t|�tk	r^t|t�sOtdt|�j��tj|�}|jj	||j
�S)Nzwrite to closed filezmust be str, not )�closedr[r�rur��	TypeErrorr�__str__r:r!r�)r3rrrrr!8s	zPseudoOutputFile.writeN)rr�r�r�r!rrrrrP3srPc@sUeZdZddd�Zdd�Zd
dd�Zdd	d
�Zdd�ZdS)rNNcCs#tj||||�d|_dS)NrS)r�r6�_line_buffer)r3r:r�rOrrrr6EszPseudoInputFile.__init__cCsdS)NTr)r3rrr�readableIszPseudoInputFile.readablercCs�|jrtd��|dkr*d}n(t|t�sRtdt|�j��|j}d|_|dkr�x�|jj	�}|s�P||7}qsWn\x6t
|�|kr�|jj	�}|s�P||7}q�W||d�|_|d|�}|S)Nzread from closed filerzmust be int, not rSrr))r�r[r�rdr�r�rr�r:rkr�)r3�size�resultrrrrrLs,				zPseudoInputFile.readcCs�|jrtd��|dkr*d}n(t|t�sRtdt|�j��|jpg|jj	�}|dkr�t
|�}|jdd|�}|dkr�|d}||d�|_|d|�S)Nzread from closed filerzmust be int, not rrmr))r�r[r�rdr�r�rr�r:rkr��find)r3r�rZeolrrrrkcs		
zPseudoInputFile.readlinecCs|jj�dS)N)r:r�)r3rrrr�sszPseudoInputFile.closer)r))rr�r�r6r�rrkr�rrrrrNCs
rNcCsG|jdkrCx1dD])}|j|dd|j|d��qWdS)	z6Make paste replace selection on x11.  See issue #5124.Zx11�Text�Entry�Spinboxz	<<Paste>>z%catch {%W delete sel.first sel.last}
N)r�r�r�)Z_windowingsystemZ
bind_class)rw�clsrrr�
fix_x11_pastews
r�a�
USAGE: idle  [-deins] [-t title] [file]*
       idle  [-dns] [-t title] (-c cmd | -r file) [arg]*
       idle  [-dns] [-t title] - [arg]*

  -h         print this help message and exit
  -n         run IDLE without a subprocess (DEPRECATED,
             see Help/IDLE Help for details)

The following options will override the IDLE 'settings' configuration:

  -e         open an edit window
  -i         open a shell window

The following options imply -i and will open a shell:

  -c cmd     run the command in a shell, or
  -r file    run script from file

  -d         enable the debugger
  -s         run $IDLESTARTUP or $PYTHONSTARTUP before anything else
  -t title   set title of shell window

A default edit window will be bypassed when -c, -r, or - are used.

[arg]* are passed to the command (-c) or script (-r) in sys.argv[1:].

Examples:

idle
        Open an edit window or shell depending on IDLE's configuration.

idle foo.py foobar.py
        Edit the files, also open a shell if configured to start with shell.

idle -est "Baz" foo.py
        Run $IDLESTARTUP or $PYTHONSTARTUP, edit foo.py, and open a shell
        window with the title "Baz".

idle -c "import sys; print(sys.argv)" "foo"
        Open a shell window and run the command, passing "-c" in sys.argv[0]
        and "foo" in sys.argv[1].

idle -d -s -r foo.py "Hello World"
        Open a shell window, run a startup script, enable the debugger, and
        run foo.py, passing "foo.py" in sys.argv[0] and "Hello World" in
        sys.argv[1].

echo "import sys; print(sys.argv)" | idle - "foobar"
        Open a shell window, run the script piped in, passing '' in sys.argv[0]
        and "foobar" in sys.argv[1].
cs�td�dad}d}d}d}d}d}y)tjtjdd�d�\}}WnRtjk
r�}z/td|tfdtj�tj	d�WYdd}~XnXx*|D]"\}	}
|	dkr�|
}d}|	d	kr�d}d}|	d
krd}|	dkr-tj
jt�tj	�|	dkr?d}|	d
krdtddtj�da|	dkr�|
}tj
j|�r�ntd|�tj	�d}|	dkr�d}d}|	dkr�|
t_d}q�W|r
|ddkr
tjj�}d}x=tttj
��D]&}tj
jtj
|�tj
|<q W|r}|ddkr}dg|dd�t_n�|r�dg|t_n�|r�|g|t_n�|r3d}g}x'|D]}
|jtj
j|
��q�Wxs|D]:}tj
j|�}|tj
kr�tj
jd|�q�Wn.tj�}|tj
kratj
jd|�tjddddd�}|p�|}|p�|}tdd�atj�tj
jtj
jt �d��t!�dkrtj
j�d�}tj"d |�nct#d!krit#d"kr$d#nd$���fd%d&�d3D�}d*d&�|D�}tj$d|�t%t�t&t�t't�a(t)j*tt(�t)j+�r�tj,d+d,�tj,d+d-�tj,d+d.�|r4|p�|s4x:|dd�D](}
t(j-|
�dkr�|j.|
�q�W|s4t(j/�|rut(j0�}|sPdSt)j+�r~t(j1r~|j2j3�n	t(j4}|r�|j5�|r�tj6j7d/�p�tj6j7d0�}
|
r�tj
j|
�r�|j8j9|
�|s�|rH|j8j:d1tjf�|r|j8j;|�qw|rw|j8j<|�|j8j9|�n/|rwt)j=t�}|rw|j8j:d2|�xt(j>r�tj?�qzWtj@�td�dS)4NTFrzc:deihnr:st:zError: %s
%srr�z-cz-dz-ez-hz-iz-nz: Warning: running IDLE without a subprocess is deprecated.z-rzNo script file: z-sz-tr�-rSr�r�zeditor-on-startupr�r�Z	classNameZIdleZIconsZWindowszidle.icor�g!@g333333!@z.pngz.gifcs/g|]%}tjj�d|�f��qS)z	idle_%d%s)r=r>r?)r�r�)�ext�icondirrrr�s	zmain.<locals>.<listcomp>�� �0cSsg|]}td|��qS)r)Z
PhotoImage)r��iconfilerrrr�s	r�z<B2>z<B2-Motion>z<<PasteSelection>>ZIDLESTARTUPZ
PYTHONSTARTUPzbif 1:
            import sys as _sys
            _sys.argv = %r
            del _sys
            
zprint('%s'))r�r�r�)Ar(r-�getoptr��argvrr��	usage_msgr��exitr�r!r=r>r~r�r^r�rr�r��abspathr\�dirnamerb�getcwdrr�rArwrBr?�__file__rZ
wm_iconbitmapZ	TkVersionZwm_iconphotor	r�r�r;rZsetupAppZisAquaTkZunbind_classrqrg�newr<�dictr��lowerr]rY�environrir^rr�r
rZtkVersionWarningZinversedictrhZdestroy)Zenable_shellZenable_editr`�cmdZscriptZstartupZoptsrCr�o�ar�Zpathxr�dirZ
edit_startr�Z	iconfilesZiconsr:Ztkversionwarningr)r�r�rr��s
) 
	


	
$



!



	
	
r�r�F)Fr�r=Zos.pathrvr�r�r�r�r�rrArrrrbrrrd�ImportErrorr�r�r�Ztkinter.messageboxZ
messageboxrxZidlelib.EditorWindowrr	Zidlelib.FileListr
Zidlelib.ColorDelegatorrZidlelib.UndoDelegatorrZidlelib.OutputWindowr
Zidlelib.configHandlerrrrrrrr�r�r r&rr$r%r(�
checkcacher0r1r�r�r�Z	RPCClientr�r�r��
TextIOBaser�rPrNr�r�r�rr�rrrr�<module>sz
	
	
	�����4?�