Your IP : 216.73.217.32


Current Path : /opt/alt/python38/lib64/python3.8/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/idlelib/__pycache__/pyshell.cpython-38.opt-2.pyc

U

i�fe��
@s�ddlZedkr ejdejd<zddlTWn*ek
rVedejd�ed��YnXejdkr�z ddl	Z	dZ
e	�d	��e
�Wnee
efk
r�YnXdd
lmZedkr�e�at��ddlmZet�ejd
detd�ed��ddlmZddlZddlZddlZddlmZddlZddlZddlZddl m!Z!ddl"Z"ddl#Z#ddl$Z$ddl%Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+ddl*m,Z,ddl-m.Z.m/Z/ddl0m1Z1ddl2m3Z3ddl*m4Z4ddlm5Z5m6Z6m7Z7ddl8m9Z9dZ:dZ;eja<d;dd�Z=da>d d!�Z?e?d"�dej@fd#d$�ZAeAe_@Gd%d&�d&e.�ZBGd'd(�d(e1�ZCGd)d*�d*e'�ZDGd+d,�d,e9�ZEGd-d.�d.e4jF�ZGd/d0�ZHGd1d2�d2e�ZIGd3d4�d4e3�ZJd5d6�ZKd7ZLd8d9�ZMedk�r�eM�e?d:�dS)<�N�__main__zidlelib.pyshell)�*zJ** IDLE can't import Tkinter.
Your Python may not be configured for Tk. **��file�Zwin32Zshcore)�
messageboxg!@��fix_scalingzIdle Cannot Startz"Idle requires tcl/tk 8.5+, not %s.��parent)�InteractiveInterpreter)�python_version)�TextWrapper)�ColorDelegator)�idleConf��debugger)�
debugger_r)�EditorWindow�
fixwordbreaks)�FileList)�OutputWindow)�rpc)�idle_formatwarning�StdInputFile�
StdOutputFile)�
UndoDelegatorz	127.0.0.1c	CsP|dkrt}z&|�t|||||d��|�d�Wnttfk
rJYnXdS)N)�line�>>> )�warning_stream�writer�AttributeError�OSError)�message�category�filename�linenorr�r'�4/opt/alt/python38/lib64/python3.8/idlelib/pyshell.py�idle_showwarningEs�r)cCs0|rtdkr,tjatt_ntdk	r,tt_dadS�N)�_warnings_showwarning�warnings�showwarningr))Zcapturer'r'r(�capture_warningsXsr.TcCsXtj}i}t|�D].}|dd�|dd�dkr|�|�||<q||�|�|�dS�Nr���z<>)�	linecache�cache�list�pop�update)r%Zorig_checkcacher2�save�keyr'r'r(�extended_linecache_checkcachegsr8c@szeZdZdd�ZddddddgZdd
d�Zdd
�Zd dd�Zd!dd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)"�PyShellEditorWindowcGs�g|_tj|f|��|j�d|j�|j�d|j�|j�d|jj�t	j
�tj
d�|_|jj|fdd�}|j�|�|jjr�|��|��dS)N�<<set-breakpoint-here>>�<<clear-breakpoint-here>>z<<open-python-shell>>zbreakpoints.lstcSs|��|�dSr*)�restore_file_breaks)Zold_hook�selfr'r'r(�filename_changed_hook�sz;PyShellEditorWindow.__init__.<locals>.filename_changed_hook)�breakpointsr�__init__�text�bind�set_breakpoint_here�clear_breakpoint_here�flist�
open_shell�os�path�joinrZuserdir�breakpointPath�ioZfilename_change_hookZset_filename_change_hookr%r<�color_breakpoint_text)r=�argsr>r'r'r(r@�s ��
zPyShellEditorWindow.__init__)ZCutz<<cut>>�rmenu_check_cut)ZCopyz<<copy>>Zrmenu_check_copy)ZPastez	<<paste>>�rmenu_check_paste)NNN)zSet Breakpointr:N)zClear Breakpointr;NTcCsD|jdkrdS|r(t��}t�|d�}n
ddd�}|j�d|�dS)N�break�)�
foreground�
background�BREAK)rKr�CurrentTheme�GetHighlightrAZ
tag_config)r=Zcolor�themeZcfgr'r'r(rL�s

z)PyShellEditorWindow.color_breakpoint_textcCs�|j}|jj}|�dd|d|d�z|j�|�Wn tk
rX|j�|�YnXz|jj	j
j}|�||�WnYnXdS)NrTz%d.0r)
rArKr%�tag_addr?�index�
ValueError�appendrE�pyshell�interprrC)r=r&rAr%�debugr'r'r(�set_breakpoint�sz"PyShellEditorWindow.set_breakpointNcCs>|j}|jj}|s|��dStt|�d���}|�|�dS)N�insert)rArKr%�bell�int�floatrYr_)r=�eventrAr%r&r'r'r(rC�sz'PyShellEditorWindow.set_breakpoint_herecCs�|j}|jj}|s|��dStt|�d���}z|j�|�WnYnX|�	ddd�z|j
jjj
}|�||�WnYnXdS)Nr`rT�insert linestartzinsert lineend +1char)rArKr%rarbrcrYr?�remove�
tag_removerEr\r]rrD)r=rdrAr%r&r^r'r'r(rD�s$�z)PyShellEditorWindow.clear_breakpoint_herecCsd|jr`|j}|jj}|s$|��dSg|_|�ddt�z|jjj	j
}|�|�WnYnXdS)NrT�1.0)r?rArKr%rargZENDrEr\r]r�clear_file_breaks)r=rAr%r^r'r'r(ri�sz%PyShellEditorWindow.clear_file_breaksc
Cs|j}|jj}z$t|jd��}|��}W5QRXWntk
rJg}YnXzjt|jd��T}|D]}|�|d�s`|�|�q`|�	�|j}|r�|�|dt
|�d�W5QRXWnTtk
�r
}z4t|jdd�s�d|j_
tjdd	t
|�|jd
�W5d}~XYnXdS)N�r�w�=�
�breakpoint_error_displayedFTz
IDLE Errorz$Unable to update breakpoint list:
%s)�titler#r)r?rKr%�openrJ�	readlinesr"�
startswithr �update_breakpoints�str�getattr�rootrnr�	showerrorrA)r=Zbreaksr%�fp�linesZnew_filer�errr'r'r(�store_file_breaks�s2
(��z%PyShellEditorWindow.store_file_breaksc	Cs�|j��|jdkrdS|jj}|dkr,dStj�|j�r�t|jd��}|�	�}W5QRX|D]>}|�
|d�r^t|t|�dd��}|D]}|�
|�q�q^dS)Nrjrlr)rAr5rKr%rGrH�isfilerJrprqrr�eval�lenr_)r=r%rxryrZbreakpoint_linenumbersZbreakpoint_linenumberr'r'r(r<
s

z'PyShellEditorWindow.restore_file_breakscCs$|j}|�d�}|�|�}||_dS)NrT)rAZ
tag_ranges�ranges_to_linenumbersr?)r=rA�rangesZlinenumber_listr'r'r(rss

z&PyShellEditorWindow.update_breakpointscCsbg}tdt|�d�D]H}tt||j��}tt||dj��}||kr|�|�|d7}q@q|S)Nr�r)�ranger~rbrc�stringr[)r=r�ryrYr&�endr'r'r(r%s
z)PyShellEditorWindow.ranges_to_linenumberscCs|��t�|�dSr*)rir�_close�r=r'r'r(r�6szPyShellEditorWindow._close)T)N)N)�__name__�
__module__�__qualname__r@�rmenu_specsrLr_rCrDrir{r<rsrr�r'r'r'r(r9~s$�	

	
*r9c@seZdZeZdZddd�ZdS)�PyShellFileListNcCs8|jr|jj��nt|�|_|jr2|j��s2dS|jSr*)r\�top�wakeup�PyShell�begin�r=rdr'r'r(rFEs

zPyShellFileList.open_shell)N)r�r�r�r9rr\rFr'r'r'r(r�<sr�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ModifiedColorDelegatorcCst�|�|��dSr*)rr@�LoadTagDefsr�r'r'r(r@Ss
zModifiedColorDelegator.__init__cCs*|�ddd�|�ddd�t�|�dS)NZTODOrh�iomarkZSYNC)rgrXr�recolorize_mainr�r'r'r(r�Wsz&ModifiedColorDelegator.recolorize_mainc	CsJt�|�t��}|j�ddd�t�|d�t�|d�t�|d�d��dS)N)rSrR�stdout�stderr�console)�stdinr�r�r�)rr�rrU�tagdefsr5rV)r=rWr'r'r(r�\s



�z"ModifiedColorDelegator.LoadTagDefscCs|jD]}|�|dd�qdS)Nr�r�)r�rg)r=�tagr'r'r(�removecolorsfs
z#ModifiedColorDelegator.removecolorsN)r�r�r�r@r�r�r�r'r'r'r(r�Ps
r�c@s eZdZddd�Zddd�ZdS)�ModifiedUndoDelegatorNcCsNz$|j�|dd�r"|j��WdSWntk
r8YnXt�||||�dS�N�<r�)�delegate�comparera�TclErrorrr`)r=rY�chars�tagsr'r'r(r`ns

zModifiedUndoDelegator.insertcCsLz$|j�|dd�r"|j��WdSWntk
r8YnXt�|||�dSr�)r�r�rar�r�delete)r=Zindex1Zindex2r'r'r(r�ws

zModifiedUndoDelegator.delete)N)N)r�r�r�r`r�r'r'r'r(r�ks
	r�c@seZdZdd�ZdS)�MyRPCClientcCst�dSr*)�EOFErrorr�r'r'r(�
handle_EOF�szMyRPCClient.handle_EOFN)r�r�r�r�r'r'r'r(r��sr�cCs^d|pd�d�}|t|�krNt|t|�d�\}}||d�|�|d��S|dd�SdS)Nz= RESTART: ZShellz =r�rl���)r~�divmod)�widthr%r�Zdiv�modr'r'r(�restart_line�s
r�c@seZdZdd�ZdZdZdZdd�Zdd�Zdd	�Z	d?dd
�Z
dd�Zdd�Zdd�Z
dd�Zd@dd�ZdZdd�ZdZdd�Zdd�Zdd�Zd d!�Zd"Zd#d$�ZdAd%d&�Zd'd(�Zd)d*�Zd+d,�ZdBd-d.�Zd/d0�Zd1d2�Zd3d4�Z d5d6�Z!d7d8�Z"d9d:�Z#d;d<�Z$d=d>�Z%dS)C�ModifiedInterpretercCsB||_tjdj}tj||d�d|_d|_t|_	|j
jj|_
dS)Nr)�localsF)�	tkconsole�sys�modules�__dict__rr@�
restarting�subprocess_arglist�PORT�port�compile�compiler�flags�original_compiler_flags)r=r�r�r'r'r(r@�szModifiedInterpreter.__init__NcCs&|jdkr|��|_t�|j�|_dSr*)r��build_subprocess_arglist�
subprocess�Popen�
rpcsubprocr�r'r'r(�spawn_subprocess�s

z$ModifiedInterpreter.spawn_subprocesscCsJdd�tjD�}tjdddddd�}d	|f}tjg|d
|t|j�gS)NcSsg|]}d|�qS)z-Wr')�.0�sr'r'r(�
<listcomp>�sz@ModifiedInterpreter.build_subprocess_arglist.<locals>.<listcomp>�main�Generalzdelete-exitfuncF�bool)�default�typez&__import__('idlelib.run').run.main(%r)�-c)r��warnoptionsr�	GetOption�
executablertr�)r=rkZ	del_exitfZcommandr'r'r(r��s
�
z,ModifiedInterpreter.build_subprocess_arglistc	Cs\t|jf}td�D]8}t�|�zt|�|_WqXWqtk
rHYqXq|��dS|jj	�
�d|_tdkr�|jj	�t
jt
jd�|��|jj	�d�z|j��Wn t
jk
r�|��YdSX|j�d|j�|j�d|jj�|j�d|jj�|j�d|jj�|j�d	|jj�|j�d
t�|j�d|�|jdd
�|��|jS)N�rr�
r�r�r�r�rEr1r]T��with_cwd)�HOSTr�r��time�sleepr��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�rEr1�
transfer_path�poll_subprocess)r=Zaddr�ir'r'r(�start_subprocess�sB



�z$ModifiedInterpreter.start_subprocessFrQcCs2|jr|jSd|_|��}|r<zt�|j�WnYnX|j��|��|j}|j}d|_|�	�z|j�
�Wn tjk
r�|�
�YdSX|j|d�|��|j�dd�|�d�|�t|j|��|j�dd�|j�dd�|�s|��|�rt�|j�|��|j|jj_d|_|jS)	NTFr�r��end-1crm�restart�left)r�r��getdebuggerrZclose_subprocess_debugger�close�terminate_subprocessr��	executingr�r�r�r�r�r��
stop_readlinerAr�r r�r��mark_set�mark_gravity�
showpromptZrestart_subprocess_debugger�load_breakpointsr�r�r�r�)r=r�r%r^r�Z
was_executingr'r'r(�restart_subprocess�sF

z&ModifiedInterpreter.restart_subprocesscCs|j�dddi�dS)N�execZinterrupt_the_serverr')r�Z
remotecallr�r'r'r(Z__request_interruptsz'ModifiedInterpreter.__request_interruptcCstj|jd���dS)N)�target)�	threadingZThread�'_ModifiedInterpreter__request_interrupt�startr�r'r'r(�interrupt_subprocesssz(ModifiedInterpreter.interrupt_subprocesscCs~|jdk	r|jj�|j�z|jj��Wntk
r>YnXz|j��Wntk
rbYnX|��d|j_	d|_dS�NF)
�_afteridr�rAZafter_cancelr�r�r�r!r�r�r�r'r'r(�kill_subprocesss
z#ModifiedInterpreter.kill_subprocesscCsPz|j��Wntk
r$YdSXz|j��Wntk
rJYdSXdSr*)r��killr"�waitr�r'r'r(r�!sz(ModifiedInterpreter.terminate_subprocesscCs2|rdg}|�tj�ntj}|�d|f�dS)NrQzRif 1:
        import sys as _sys
        _sys.path = %r
        del _sys
        
)�extendr�rH�
runcommand)r=r�rHr'r'r(r�.s�z!ModifiedInterpreter.transfer_pathc
Cs8|j}|dkrdSz|j|jdd�}Wn4tttfk
rZ|jjrJYdSd}|��YnX|�r|j�	�d|_|\}}|jj
}|dkr�|dk	r�tt|�|d�nH|dkr�|j�
d�r�|��n*|dkr�d}t||tjd�t|||d�z|j��Wntk
�rYnX|jj�s4|jj�|jj|j�|_dS)	Ng�������?)r�ZOKrZ	EXCEPTION�<<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!rA�after�pollintervalr�r�)r=Zclt�responseZhowZwhatr��errmsgr'r'r(r�=sD


�z#ModifiedInterpreter.poll_subprocesscCs
||_dSr*r)r=rr'r'r(�setdebuggereszModifiedInterpreter.setdebuggercCs|jSr*rr�r'r'r(r�hszModifiedInterpreter.getdebuggercCs|jj�d|j�dS)Ni,)r�rArrr�r'r'r(�open_remote_stack_viewerks
z,ModifiedInterpreter.open_remote_stack_viewercCs�ddlm}|j�dddi�}|dkr6|jj��dS|�|j|�}ddlm	}m
}t|jj�}t�
�}t�|d�d}|||dd	�}	|	jjd
dd�||	jd|�}
|
��dS)
Nr)�
debugobj_rr�Zstackviewer)rE)�ScrolledCanvas�TreeNode�normalrS)ZbgZhighlightthicknessrZboth)�expandZfill)�idlelibrr��remotequeuer�rvraZStubObjectTreeItemZidlelib.treerr
ZToplevelrrUrV�frameZpackZcanvasr)r=rZoid�itemrr
r�rWrSZscZnoder'r'r(rxsz'ModifiedInterpreter.remote_stack_viewerrcCs|�|�}|�||�dSr*)�stuffsource�execfile�r=�sourcer%r'r'r(�
execsource�s
zModifiedInterpreter.execsourcec	Cs�|dkrFt�|��.}|��}tr<dtj�|��d�|d}W5QRXzt||d�}WnHtt	fk
r�|j
��td|j
j
d�t�||�|j
��YnX|�|�dS)Nz__file__ = r'''z'''
z
del __file__r�zB*** Error in script or command!
Traceback (most recent call last):r)�tokenizerp�read�use_subprocessrGrH�abspathr��
OverflowError�SyntaxErrorr�r�r�r�r�showsyntaxerrorr��runcode)r=r%rrx�coder'r'r(r�s&��
�zModifiedInterpreter.execfilecCs|�|�}t�|||�Sr*)rr�	runsourcerr'r'r(r"�s
zModifiedInterpreter.runsourcecCs>d|j}|jd|_|�d�}t|�dd||ftj|<|S)Nz<pyshell#%d>rrmr)�gid�splitr~r1r2)r=rr%ryr'r'r(r�s


zModifiedInterpreter.stuffsourcecCs|�d|f�dS)Na(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
            
)r��r=r%r'r'r(�prepend_syspath�s�z#ModifiedInterpreter.prepend_syspathcCs�|j}|j}|�ddd�t��\}}}t|dd�p:|p:d}t|dd�pJd}t|d	d�pZd
}	|	d
krl|d7}|dkr�d|	d}
nd|d|	df}
|�||
�|��|�d
|�|�	�dS)Nr�rhr��msgrQz<no detail available>r&r�offsetrziomark + %d charsz&iomark linestart + %d lines + %d charszSyntaxError: %s
)
r�rArgr��exc_inforuZcolorize_syntax_errorr�r r�)r=r%r�rAr��value�tbr'r&r(�posr'r'r(r�s$�z#ModifiedInterpreter.showsyntaxerrorcCs6|j��|��t�|�|j�d�r2|j��dS)Nr�)r�r��checklinecacher�
showtracebackr�open_stack_viewerr�r'r'r(r.�s


z!ModifiedInterpreter.showtracebackcCs>tj}t|���D]&}|dd�|dd�dkr||=qdSr/)r1r2r3�keys)r=�cr7r'r'r(r-�sz"ModifiedInterpreter.checklinecachecCs@|jjr|��dS|jr0|j�dd|fi�nt||j�dS)Nrr�r r)r�r��display_executing_dialogr�rr�r�)r=r!r'r'r(r��szModifiedInterpreter.runcommandcCsL|jjr|��|��|j}z�zT|j��|sR|j	dk	rR|j	�
dd|fi�|_n |rf|�||j
�nt||j
�Wn�tk
r�|jjs�tjddd|jjd�r��q�|��n�Yn`tr�td|jjd�|��|j��n,|jj�rd	|j_td
|jjd�n|��YnXW5t�sFz|j��Wntk
�rDYnXXdS)Nr�r zExit?zDo you want to exit altogether?Zyes�r�rz IDLE internal error in runcode()rFr�)r�r�r�r-rrrr!�beginexecutingr�Z
asyncqueuer��runr�r��
SystemExitr�rZaskyesnorAr.r�r��canceled)r=r!rr'r'r(r �sR

��
�
zModifiedInterpreter.runcodecCs|jj�|�Sr*)r�r�r )r=r�r'r'r(r #szModifiedInterpreter.writecCstjdd|jjd�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.r
�rrwr�rAr�r'r'r(r�'s
�z.ModifiedInterpreter.display_port_binding_errorcCstjdd|jjd�dS)NzSubprocess Connection Errorz�IDLE's subprocess didn't make connection.
See the 'Startup failure' section of the IDLE doc, online at
https://docs.python.org/3/library/idle.html#startup-failurer
r8r�r'r'r(r�2s
�z/ModifiedInterpreter.display_no_subprocess_errorcCstjdd|jjd�dS)NzAlready executingzYThe Python Shell window is already executing a command; please wait until it is finished.r
r8r�r'r'r(r2:s
�z,ModifiedInterpreter.display_executing_dialog)FrQ)F)N)N)&r�r�r�r@r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr	r�r
rr#rrr"rr&rr.r-r�r r r�r�r2r'r'r'r(r��sF	+
,

&

	
.r�cs�eZdZde�ZeZeZddddddgZ	e
jdgZd	Zd
dl
mZdUd
d�Zdd�Zd	Zd	Zd	Zd	Zd	Zd	Zdd�Zdd�ZdVdd�Zdd�ZdWdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Z d%d&�Z!d'd(�Z"d)d*�Z#d+d,�Z$d-Z%d.d/�Z&d0d1�Z'd2d3�Z(d4d5�Z)dXd6d7�Z*d8d9�Z+d:d;�Z,d<d=�Z-d>d?�Z.d@dA�Z/dYdBdC�Z0dZdDdE�Z1d[dFdG�Z2dHdI�Z3dJdK�Z4dLdM�Z5d\dOdP�Z6�fdQdR�Z7�fdSdT�Z8�Z9S)]r�zIDLE Shell )rZ_File)ZeditZ_Edit)r^Z_Debug)ZoptionsZ_Options)ZwindowZ_Window)�helpZ_Help)ZSqueeze�<<squeeze-current-text>>Fr)�HistoryNcCs$tr&|j}|dddkr&|�dd�t|�|_|dkrVt�}t|�|��t|�}t	�
||dd�d|_d|_t
td�r�tjnd|_|j�d	�d
|_|j|_|j}|jdd�|�d
|j�|�d|j�|�d|j�|�d|j�|�d|j�|�d|j�|�d|j�t�r8|�d|j�|�d|j�|� |�}|�d|j!�tj"|_#tj$|_%tj&|_'ddl(m)}t*|d|j+|j,�|_&t-|d|j+|j,�|_"t-|d|j+d�|_$t-|d|j+|j,�|_.t�s�|j"t_"|j$t_$|j&t_&zddl/}|j0|_1Wntj2t_$�YnX|�3|j�|_4d|_5dS)Nr�r�shell)r<ZShe_llT��ps1rrmr0�char)�wrapz<<newline-and-indent>>z<<plain-newline-and-indent>>z<<interrupt-execution>>z<<end-of-file>>z<<open-stack-viewer>>�<<toggle-debugger>>r�z<<view-restart>>z<<restart-shell>>r:)�iomenur�r�r��backslashreplacer��2)6r�
menu_specsr`r�r]�Tkr�withdrawr�rr@ZusetabsZindentwidth�hasattrr�r>�sys_ps1r$Zprompt_last_line�promptrAZ	configurerB�enter_callback�linefeed_callback�cancel_callback�eof_callbackr/�toggle_debugger�toggle_jit_stack_viewer�view_restart_mark�
restart_shellZSqueezerZsqueeze_current_text_eventr��save_stdoutr��save_stderrr��
save_stdinrrBr�encoding�errorsrr��pydocZ
plainpagerZpagerrr;�historyr)r=rEZmsrvrAZsqueezerrBrXr'r'r(r@^s�

�����zPyShell.__init__cCstjdd�S)NT)Z
shell_only)rZ
GetExtensionsr�r'r'r(�get_standard_extension_names�sz$PyShell.get_standard_extension_namescCs|adSr*�r)r=�streamr'r'r(�set_warning_stream�szPyShell.set_warning_streamcCstSr*r[r�r'r'r(�get_warning_stream�szPyShell.get_warning_streamcCsH|jr$tjdd|jd�|��dS|j��}|r<|��n|��dS)NzDon't debug nowz*You can only toggle the debugger when idler
rP)	r�rrwrA�set_debugger_indicatorr]r��close_debugger�
open_debugger)r=rd�dbr'r'r(rO�s�

zPyShell.toggle_debuggercCs|j��}|�d|�dS)NrA)r]r�Zsetvar�r=rbr'r'r(r_�s
zPyShell.set_debugger_indicatorcCsdSr*r'r�r'r'r(rP�szPyShell.toggle_jit_stack_viewercCsh|j��}|r\|j�d�|��|jjr8t�|jj�|��|j�	d�|j
|_|��|�
�dS)Nz[DEBUG OFF]
)r]r�r	r�r�rZclose_remote_debuggerr�r�r rIrJr�r_rcr'r'r(r`�s
zPyShell.close_debuggercCsX|jjrt�|jj|�}n
t�|�}|j�|�|��d|j|_	|�
�|��dS)Nz[DEBUG ON]
)r]r�rZstart_remote_debuggerrZDebuggerr	r�rIrJr�r_)r=Zdbg_guir'r'r(ra�s
�
zPyShell.open_debuggercCs |jr
dnd}|�dd|�dS)N�disabledrr^z*tack*iewer)r�Zupdate_menu_state)r=�stater'r'r(�debug_menu_postcommand�szPyShell.debug_menu_postcommandcCs|��d|_dS�NT)r�r�r�r'r'r(r4�szPyShell.beginexecutingcCsd|_d|_|��dSr�)r�r7r�r�r'r'r(r�szPyShell.endexecutingcCsD|jr&tjddd|jd�}|dkr&dS|��d|_d|_t�|�S)NzKill?z7Your program is still running!
 Do you want to kill it?�okr3FZcancelT)	r�rZaskokcancelrAr�r7r�rr�)r=rr'r'r(r��s�z
PyShell.closecCsV|��tr|j��|jt_|jt_|j	t_
d|_d|_d|j_
d|_t�|�dSr*)r`rr]r�rSr�r�rTr�rUr�r�rEr\rYrr�r�r'r'r(r��s
zPyShell._closecCsdSrgr'r%r'r'r(�ispythonsourceszPyShell.ispythonsourcecCs|jSr*)�shell_titler�r'r'r(�short_titleszPyShell.short_titlezHType "help", "copyright", "credits" or "license()" for more information.cCs�|j�dd�|��tr:d}|j��}|sF|��dSnd}tjt	_|�
dt	jt	j|j
|f�|j��|��ddl}d|_d|_dS)	Nr�r`rQFz�==== No Subprocess ====

WARNING: Running IDLE without a Subprocess is deprecated
and will be removed in a later version. See Help/IDLE Help
for details.

zPython %s on %s
%s
%srT)rAr�r�rr]r�r�r�displayhookr�r �version�platform�	COPYRIGHTZfocus_forcer��tkinterZ_support_default_rootZ
_default_root)r=ZnosubZclientrpr'r'r(r�s&
�
z
PyShell.begincCs|js
dSd|_|j��dSrg)�reading�_stop_readline_flagr��quitr�r'r'r(r�2szPyShell.stop_readlinecCs�|j}zd|_|j��W5||_X|jr4d|_dS|j�dd�}t|�dkrRd}|��|jrnd|_t	snt
�|jr~d|_d}|S)NTFrQr�r�rrm)rqr��mainlooprrrA�getr~r�r7rr��	endoffile)r=r6rr'r'r(�readline8s(zPyShell.readlinecCsdSrgr'r�r'r'r(�isattyOszPyShell.isattycCs�z|j�ddd�rWdSWnYnX|jsT|jsT|��|j�d�|��dSd|_d|_	|jr�|jj
r�|j��r�|j��n
|j�
�|jr�|j��dS)N�	sel.firstz!=�sel.lastzKeyboardInterrupt
rPFT)rAr�r�rqr�r]r r�rvr7r�r�r�r�r�rsr�r'r'r(rMRs&



zPyShell.cancel_callbackcCsf|jr|jsdS|j�ddd�r0|j�ddd�s4dS|jsL|��|��nd|_d|_|j�	�dS)Nr�z==r`r�FTrP)
r�rqrAr�r�r�r7rvr�rsr�r'r'r(rNhs�

zPyShell.eof_callbackcCs0|jr"|j�dd�|j�d�n
|�|�dS)Nr`rmrP)rqrAr`�see�newline_and_indent_eventr�r'r'r(rLws

zPyShell.linefeed_callbackcCs:|jr|jsdSz8|j�dd�}|rF|j�ddd�rF|�||�WdSWnYnX|j�ddd��rX|j�d	d�}|r�|j�dd|d
�r�|�|j�|d|d
�|�dS|j�d	d�}|r�|j�dd
|d�r�|�|j�|d|d
�|�dS|j�dd�}|�r>|j�|ddd��r>|�|j�|d
d�|�n|�|j�dd�|�dS|j�ddd��rx|j�dd�|j�dd�}|�r�|�	��s�|j�
dd�|j�ddd��r�|�|�dS|j�dd�|j�r�|j�dd�|j�
d�n
|�|�|j�d	dd�|j��|j�r.|j��n|��dS)Nryrzz<=r�rPr`r��iomark linestartr�rrzinsert lineendz>=r�rer�zend-1c linestartrm)r�rqrArur��recallZ
tag_prevrangeZ
tag_nextranger��stripr�r|r`r{rXZupdate_idletasksr�rs�runit)r=rd�sel�prev�next�indicesr�r'r'r(rK�sZ
�


zPyShell.enter_callbackc	Cs6t�dd|�}t�dd|�}|�d�}|j��z�|j�ddd�|j�dd	�|j�	d
d�}|�
��d�r�|�|�|j�	d
d�}|j�
d|d���t|�d
k�rt�d|d��d�}t�d|��d�}|d
d�D]8}|�|�r�||t|�d�}|j�
dd|�
��q�W5|j�d�|j��XdS)Nz^\s*\nrQz\n\s*$rmr`r�rhr�r�re�:rrz	^([ \t]*))�re�subr$rAZundo_block_startr{Zundo_block_stoprgr�ru�rstrip�endswithr|r`rr~�search�grouprr)r=r�rdry�prefixZorig_base_indentZnew_base_indentrr'r'r(r~�s*



zPyShell.recallcCs�|j�dd�}t|�}|dkr8||ddkr8|d}q|dkrX||ddkrX|d}|dkrz||ddkrz|d}qX|d|�}|j�|�dS)Nr�r�rrz 	rm)rArur~r]r")r=rr�r'r'r(r��s

z
PyShell.runitcCs\|jjr|j��Sz
tjWn tjdd|jd�YdSXddlm	}||j
|j�dS)NzNo stack tracez@There is no stack trace yet.
(sys.last_traceback is not defined)r
r)�StackBrowser)r]r�rr��last_tracebackrrwrAZidlelib.stackviewerr�rvrE)r=rdr�r'r'r(r/�s

�zPyShell.open_stack_viewercCs|j�d�|j�d�dS)Nr�r�)rAr{r�r'r'r(rQ�szPyShell.view_restart_markcCs|jjdd�dS)NTr�)r]r�r�r'r'r(rR�szPyShell.restart_shellcCs:|��|j�|j�|j�dd�|��|j��dS)Nr`r�)	r�r�r rJrAr��set_line_and_columnrKZ
reset_undor�r'r'r(r��s
zPyShell.showpromptcCsP|jjj}t|ddd�}d�|�|��}|�d�s:|d7}|jj�	d|d�dS)Nr=T)r��tabsizeZexpand_tabsrmr}r�)
r]r�r�rrIr@r�ZperZbottomr`)r=r'r��wrapperZwrapped_msgr'r'r(�show_warnings

zPyShell.show_warningcCsb|j�dd�}|jr |j�|�|j�d�dkr>|j�dd�|j�dd�|��|j��dS)Nr�r�zend-2crm)	rArurYZstorer`r�r�ZctipZremove_calltip_window)r=rr'r'r(r�szPyShell.resetoutputr'cCsXz0|j�dd�t�|||d�}|j�dd�Wn�YnX|jrTd|_tsTt�|S)Nr��rightr�F)rAr�rr r7rr�)r=r�r��countr'r'r(r sz
PyShell.writecs<z|j�ddd�rWdSWntk
r0YdSXt���S)Nryr�r�rd)rAr�r��superrNr���	__class__r'r(rN$s
zPyShell.rmenu_check_cutcs|j�ddd�rdSt���S)Nr`r�r�rd)rAr�r�rOr�r�r'r(rO,szPyShell.rmenu_check_paste)N)N)N)N)N)N)N)r'):r�r�r�r
rjr�rr�rrErr�Zallow_line_numbersZidlelib.historyr;r@rZrqr�r7rvr�rrr]r^rOr_rPr`rarfr4rr�r�rirkror�r�rwrxrMrNrLrKr~r�r/rQrRr�r�r�r rNrO�
__classcell__r'r'r�r(r�Bst
�
�
C


�
	?




r�c
Cs2|jdkr.dD]}|�|dd|�|d��qdS)NZx11)ZTextZEntryZSpinboxz	<<Paste>>z%catch {%W delete sel.first sel.last}
)Z_windowingsystemZ
bind_class)rv�clsr'r'r(�
fix_x11_paste2s

��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].
c
sVddl}ddlm}ddlm}ddlm}td�dad}d}d}d}d}d}	z|�tj	dd�d�\}
}WnD|j
k
r�}z$td	|tftj
d
�t�d�W5d}~XYnX|
D]�\}
}|
dkr�|}d}|
d
kr�d}d}|
dkr�d}|
dk�r
tj�t�t��|
dk�rd}|
dk�r4tdtj
d
�da|
dk�rh|}tj�|��rRntd|�t��d}|
dk�rzd}	d}|
dkr�|t_d}q�|�r�|ddk�r�tj��}d}tttj��D]}tj�tj|�tj|<�q�|�r|ddk�rdg|dd�t_	n�|�rdg|t_	n�|�r0|g|t_	n�|�r�d}g}|D]}|�tj�|���qB|D],}tj�|�}|tjk�r`tj�d|��q`n"t��}|tjk�r�tj�d|�tj ddddd�}|�p�|}|�p�|}t�r�|�s�t!�t"dd�a#t#�$�dd l%m&}|t#�tj�'tj�t(�d!��|�d"k�rPtj�'�d#�}t#j)|d$�nV|�*��s�t+d%k�rnd&�d'}nd(�d)}��fd*d+�|D�}d,d+�|D�}t#j,d0|��t-t#�t.t#�t/t#�a0|�1t#t0�|�r|�s|�s|dd�D] }t0�2|�dk�r�|�3|��q�|�st0�4�|�rNt0�5�}|�s0dS|�*��rTt0j6�rT|j7�8�nt0j9}|�rb|�:�|	�r�tj;�<d-��p�tj;�<d.�}|�r�tj�|��r�|j=�>|�|�s�|�r�|j=�?d/tj	f�|�r�|j=�@|�n|�r.|j=�A|�|j=�>|�n8|�r.|�Bt#�}|�r|�C|�|�D�}|�r.|�C|�t0jE�rBt#�F��q.t#�G�td�dS)1Nr)�system)�testing)�macosxTFrzc:deihnr:st:zError: %s
%srr�r�z-dz-ez-hz-iz-nz: Warning: running IDLE without a subprocess is deprecated.z-rzNo script file: z-sz-t�-rQr�r�zeditor-on-startupr�)r�ZIdle)Z	classNamerZIconsZWindowszidle.ico)r�g333333!@z.png)�� �0�z.gif)r�r�r�cs"g|]}tj��d|�f��qS)z	idle_%d%s)rGrHrI)r��size�ZextZicondirr'r(r��s�zmain.<locals>.<listcomp>cSsg|]}tt|d��qS))Zmasterr)Z
PhotoImagerv)r��iconfiler'r'r(r��s�ZIDLESTARTUPZ
PYTHONSTARTUPzbif 1:
            import sys as _sys
            _sys.argv = %r
            del _sys
            
)T)H�getoptrnr�rr�r�r.rr��argv�errorr��	usage_msgr��exitr�r rGrHr|r�rjr�rr�r~rr[�dirnamer`�getcwdrr�Z
NoDefaultRootrFrvrG�idlelib.runr	rI�__file__Z
wm_iconbitmapZisAquaTk�	TkVersionZwm_iconphotorr�r�rEZsetupApprprf�newrF�dictr��lowerr\ra�environrur]rr�rr&ZtkVersionWarningr�ZpreferTabsPreferenceWarningZinversedictrtZdestroy)r�r�r�r�Zenable_shellZenable_editr^�cmdZscriptZstartupZoptsrMr'�o�ar�Zpathxr%�dirZ
edit_startr	r�ZsizesZ	iconfilesZiconsr<ZtkversionwarningZprefer_tabs_preference_warningr'r�r(r�ss&


�



�



��
��


r�F)NN)Nr�r�r�rp�ImportErrorr�rr6rnZctypesZPROCESS_SYSTEM_DPI_AWAREZOleDLLZSetProcessDpiAwarenessr!r"rr�rFrvrGr�r	rwr!rr1rGZos.pathr
r�r�r��textwraprr�r�rr,Zidlelib.colorizerrZidlelib.configrrrrZidlelib.editorrrZidlelib.filelistrZidlelib.outwinrrrrrZidlelib.undorr�r�rr)r+r.�
checkcacher8r9r�r�r�Z	RPCClientr�r�r�r�r�r�r�r'r'r'r(�<module>s��
��

�
?0s66