Your IP : 216.73.216.52


Current Path : /opt/alt/python39/lib64/python3.9/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/idlelib/__pycache__/pyshell.cpython-39.opt-1.pyc

a

XC?h��
@s�ddlZedkr ejdejd<zddlTWn(eyTedejd�ed��Yn0ejdkr�z ddl	Z	dZ
e	�d	��e
�Wnee
efy�Yn0dd
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;zdZ<e<e=_<e<e>_<Wne?�yYn0eja@d<dd �ZAdaBd!d"�ZCeCd#�dejDfd$d%�ZEeEe_DGd&d'�d'e.�ZFGd(d)�d)e1�ZGGd*d+�d+e'�ZHGd,d-�d-e9�ZIGd.d/�d/e4jJ�ZKd0d1�ZLGd2d3�d3e�ZMGd4d5�d5e3�ZNd6d7�ZOd8ZPd9d:�ZQedk�r�eQ�eCd;�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.1zCtrl-D (end-of-file)c	CsN|durt}z&|�t|||||d��|�d�WnttfyHYn0dS)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.
    N)�line�>>> )�warning_stream�writer�AttributeError�OSError)�message�category�filename�linenorr�r'�4/opt/alt/python39/lib64/python3.9/idlelib/pyshell.py�idle_showwarningLs
�r)cCs0|rtdur,tjatt_ntdur,tt_dadS)z>Replace warning.showwarning with idle_showwarning, or reverse.N)�_warnings_showwarning�warnings�showwarningr))Zcapturer'r'r(�capture_warnings_sr-TcCsXtj}i}t|�D].}|dd�|dd�dkr|�|�||<q||�|�|�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.
    Nr����<>)�	linecache�cache�list�pop�update)r%Zorig_checkcacher1�save�keyr'r'r(�extended_linecache_checkcachensr7c@sveZdZdZdd�Zgd�Zddd�Zdd	�Zddd�Zdd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd
S)�PyShellEditorWindowz6Regular text edit window in IDLE, supports breakpointscGs�g|_tj|g|�R�|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|��|�dS�N)�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 Breakpointr9N)zClear Breakpointr:NTcCsD|jdurdS|r(t��}t�|d�}n
ddd�}|j�d|�dS)z,Turn colorizing of breakpoint text on or offN�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�|�WntyV|j�|�Yn0z|jj	j
j}|�||�WnYn0dS)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Yn0|�	ddd�z|j
jjj
}|�||�WnYn0dS)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Yn0dS)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}z8t|jd��}|��}Wd�n1s:0YWnty\g}Yn0z~t|jd��^}|D]}|�|d�sr|�|�qr|�	�|j}|r�|�|dt
|�d�Wd�n1s�0YWnXt�y4}z>t|jdd��s d|j_
tjd	d
t
|�|jd�WYd}~n
d}~00dS)z#Save breakpoints when file is saved�rN�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_breakscCs�|j��|jdurdS|jj}|dur,dStj�|j�r�t|jd��}|�	�}Wd�n1sd0Y|D]>}|�
|d�rrt|t|�dd��}|D]}|�
|�q�qrdS)Nrjrlr)rAr4rKr%rGrH�isfilerJrprqrr�eval�lenr_)r=r%rxryrZbreakpoint_linenumbersZbreakpoint_linenumberr'r'r(r<s

&z'PyShellEditorWindow.restore_file_breakscCs$|j}|�d�}|�|�}||_dS)z3Retrieves all the breakpoints in the current windowrTN)rAZ
tag_ranges�ranges_to_linenumbersr?)r=rA�rangesZlinenumber_listr'r'r(rs%s

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�|�dS)z7Extend base method - clear breaks when module is closedN)rir�_close�r=r'r'r(r�=szPyShellEditorWindow._close)T)N)N)�__name__�
__module__�__qualname__�__doc__r@�rmenu_specsrLr_rCrDrir{r<rsrr�r'r'r'r(r8�s	

	
*r8c@s"eZdZdZeZdZddd�ZdS)�PyShellFileListz8Extend base class: IDLE supports a shell and breakpointsNcCs8|jr|jj��nt|�|_|jr2|j��s2dS|jSr;)r\�top�wakeup�PyShell�begin�r=rdr'r'r(rFLs

zPyShellFileList.open_shell)N)r�r�r�r�r8rr\rFr'r'r'r(r�Csr�c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�ModifiedColorDelegatorz8Extend base class: colorizer for the shell window itselfcCst�|�|��dSr;)rr@�LoadTagDefsr�r'r'r(r@Zs
zModifiedColorDelegator.__init__cCs*|�ddd�|�ddd�t�|�dS)NZTODOrh�iomarkZSYNC)rgrXr�recolorize_mainr�r'r'r(r�^sz&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�tagdefsr4rV)r=rWr'r'r(r�cs



�z"ModifiedColorDelegator.LoadTagDefscCs|jD]}|�|dd�qdS)Nr�r�)r�rg)r=�tagr'r'r(�removecolorsms
z#ModifiedColorDelegator.removecolorsN)r�r�r�r�r@r�r�r�r'r'r'r(r�Ws

r�c@s$eZdZdZddd�Zddd�ZdS)	�ModifiedUndoDelegatorz;Extend base class: forbid insert/delete before the I/O markNcCsLz$|j�|dd�r"|j��WdSWnty6Yn0t�||||�dS�N�<r�)�delegate�comparera�TclErrorrr`)r=rY�chars�tagsr'r'r(r`us

zModifiedUndoDelegator.insertcCsJz$|j�|dd�r"|j��WdSWnty6Yn0t�|||�dSr�)r�r�rar�r�delete)r=Zindex1Zindex2r'r'r(r�~s

zModifiedUndoDelegator.delete)N)N)r�r�r�r�r`r�r'r'r'r(r�rs
	r�c@seZdZdd�ZdS)�MyRPCClientcCst�dS)z0Override the base class - just re-raise EOFErrorN)�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)z�Return width long restart line formatted with filename.

    Fill line with balanced '='s, with any extras and at least one at
    the beginning.  Do not end with a trailing space.
    z= RESTART: ZShellz =r�rlN���)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&|jdur|��|_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>��z@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	CsXt|jf}td�D]6}t�|�zt|�|_WqVWqtyFYq0q|��dS|jj	�
�d|_tdkr�|jj	�t
jt
jd�|��|jj	�d�z|j��Wnt
jy�|��YdS0|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�rEr0r]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�rEr0�
transfer_path�poll_subprocess)r=Zaddr�ir'r'r(�start_subprocess�s@



�z$ModifiedInterpreter.start_subprocessFrQcCs0|jr|jSd|_|��}|r<zt�|j�WnYn0|j��|��|j}|j}d|_|�	�z|j�
�Wntjy�|�
�YdS0|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_interruptsz'ModifiedInterpreter.__request_interruptcCstj|jd���dS)N)�target)�	threadingZThread�'_ModifiedInterpreter__request_interrupt�startr�r'r'r(�interrupt_subprocesssz(ModifiedInterpreter.interrupt_subprocesscCsz|jdur|jj�|j�z|jj��Wnty<Yn0z|j��Wnty^Yn0|��d|j_	d|_dS)NF)
�_afteridr�rAZafter_cancelr�r�r�r!r�r�r�r'r'r(�kill_subprocesss
z#ModifiedInterpreter.kill_subprocesscCsLz|j��Wnty"YdS0z|j��WntyFYdS0dS)z"Make sure subprocess is terminatedN)r��killr"�waitr�r'r'r(r�(sz(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�5s�z!ModifiedInterpreter.transfer_pathc
Cs4|j}|durdSz|j|jdd�}Wn2tttfyX|jjrHYdSd}|��Yn0|�r|j�	�d|_|\}}|jj
}|dkr�|dur�tt|�|d�nH|dkr�|j�
d�r�|��n*|dkr�d}t||tjd�t|||d�z|j��Wnt�yYn0|jj�s0|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�DsB



�z#ModifiedInterpreter.poll_subprocesscCs
||_dSr;r)r=rr'r'r(�setdebuggerlszModifiedInterpreter.setdebuggercCs|jSr;rr�r'r'r(r�oszModifiedInterpreter.getdebuggercCs|jj�d|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�rArrr�r'r'r(�open_remote_stack_viewerrs
z,ModifiedInterpreter.open_remote_stack_viewercCs�ddlm}|j�dddi�}|dur6|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)�idlelibrr��remotequeuer�rvraZStubObjectTreeItemZidlelib.treer
rZToplevelrrUrV�frameZpackZcanvasr)r=rZoid�itemr
rr�rWrSZscZnoder'r'r(rsz'ModifiedInterpreter.remote_stack_viewerrcCs|�|�}|�||�dS)z1Like runsource() but assumes complete exec sourceN)�stuffsource�execfile�r=�sourcer%r'r'r(�
execsource�s
zModifiedInterpreter.execsourcec	Cs�|durZt�|��8}|��}tr<dtj�|��d�|d}Wd�n1sP0Yzt||d�}WnFtt	fy�|j
��td|j
j
d�t�||�|j
��Yn0|�|�dS)zExecute an existing fileNz__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�rr�r�showsyntaxerrorr��runcode)r=r%rrx�coder'r'r(r�s&��"
�zModifiedInterpreter.execfilecCs|�|�}t�|||�S)zBExtend base class method: Stuff the source in the line cache first)rr�	runsourcerr'r'r(r#�s
zModifiedInterpreter.runsourcecCs>d|j}|jd|_|�d�}t|�dd||ftj|<|S)z"Stuff source in the filename cachez<pyshell#%d>rrmr)�gid�splitr~r0r1)r=rr%ryr'r'r(r�s


zModifiedInterpreter.stuffsourcecCs|�d|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��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)z�Override Interactive Interpreter method: Use Colorizing

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

        r�rhr��msgrQz<no detail available>r&r�offsetrziomark + %d charsz&iomark linestart + %d lines + %d charszSyntaxError: %s
N)
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)z1Extend base class method to reset output properlyr�N)r�r��checklinecacher�
showtracebackr�open_stack_viewerr�r'r'r(r/�s


z!ModifiedInterpreter.showtracebackcCs>tj}t|���D]&}|dd�|dd�dkr||=qdS)Nrr.r/)r0r1r2�keys)r=�cr6r'r'r(r.�sz"ModifiedInterpreter.checklinecachecCs@|jjr|��dS|jr0|j�dd|fi�nt||j�dS)z*Run the code without invoking the debuggerrr�r!r)r�r��display_executing_dialogr�rr�r�)r=r"r'r'r(r��szModifiedInterpreter.runcommandcCst|jjr|��|��|j}�z"zT|j��|sT|jdurT|j�dd|fi�|_n |rh|�	||j
�nt||j
�Wn�ty�|jj
s�tjddd|jjd�r��q�|��n�Yn`tr�td|jjd	�|��|j��n,|jj�rd
|j_td|jjd	�n|��Yn0Wt�spz|j��Wnt�y@Yn0n,t�snz|j��Wnt�ylYn00dS)�Override base class methodNr�r!zExit?zDo you want to exit altogether?Zyes�r�rz IDLE internal error in runcode()rFr�)r�r�r�r.r�beginexecutingr�Z
asyncqueuer��runr�r��
SystemExitr�rZaskyesnorAr/rrr�r�canceledr!)r=r"rr'r'r(r!�sZ

��
�
�zModifiedInterpreter.runcodecCs|jj�|�S)r4)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
r:r�r'r'r(r�9s
�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
r:r�r'r'r(r3As
�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�rrr$rrr#rr'r r/r.r�r!r r�r�r3r'r'r'r(r��sF	+
,

&

	
.r�cs�eZdZde�ZeZeZgd�Z	e
jdgZdZddl
mZdPdd	�Zd
d�ZdZdZdZdZdZdZdd
�Zdd�ZdQdd�Zdd�ZdRdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z d d!�Z!d"d#�Z"d$d%�Z#d&d'�Z$d(Z%d)d*�Z&d+d,�Z'd-d.�Z(d/d0�Z)dSd1d2�Z*d3d4�Z+d5d6�Z,d7d8�Z-d9d:�Z.d;d<�Z/dTd=d>�Z0dUd?d@�Z1dVdAdB�Z2dCdD�Z3dEdF�Z4dGdH�Z5dWdJdK�Z6�fdLdM�Z7�fdNdO�Z8�Z9S)Xr�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|�|_|durVt�}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_$�Yn0|�3|j�|_4d|_5dS)Nr�r�shell)r>ZShe_llT��ps1rrmr.�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_callbackr0�toggle_debugger�toggle_jit_stack_viewer�view_restart_mark�
restart_shellZSqueezerZsqueeze_current_text_eventr��save_stdoutr��save_stderrr��
save_stdinrrDr�encoding�errorsrr��pydocZ
plainpagerZpagerrr=�historyr)r=rEZmsrvrAZsqueezerrDrZr'r'r(r@esx

�����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(rQ�s�

zPyShell.toggle_debuggercCs|j��}|�d|�dS)NrC)r]r�Zsetvar�r=rdr'r'r(ra�s
zPyShell.set_debugger_indicatorcCsdSr;r'r�r'r'r(rR�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 rKrLr�rarer'r'r(rb�s
zPyShell.close_debuggercCsX|jjrt�|jj|�}n
t�|�}|j�|�|��d|j|_	|�
�|��dS)Nz[DEBUG ON]
)r]r�rZstart_remote_debuggerrZDebuggerr
r�rKrLr�ra)r=Zdbg_guir'r'r(rc�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)�Helper for ModifiedInterpreterTN)r�r�r�r'r'r(r6�szPyShell.beginexecutingcCsd|_d|_|��dS)riFN)r�r9r�r�r'r'r(r�szPyShell.endexecutingcCsD|jr&tjddd|jd�}|dur&dS|��d|_d|_t�|�S)zExtend EditorWindow.close()zKill?z7Your program is still running!
 Do you want to kill it?�okr5FZcancelT)	r�rZaskokcancelrAr�r9r�rr�)r=rr'r'r(r��s�z
PyShell.closecCsV|��tr|j��|jt_|jt_|j	t_
d|_d|_d|j_
d|_t�|�dS)zEExtend EditorWindow._close(), shut down debugger and execution serverN)rbrr]r�rUr�r�rVr�rWr�r�rEr\r[rr�r�r'r'r(r�s
zPyShell._closecCsdS)z8Override EditorWindow method: never remove the colorizerTr'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=ZnosubZclientrrr'r'r(r�s&
�
z
PyShell.begincCs|js
dSd|_|j��dS�NT)�reading�_stop_readline_flagr��quitr�r'r'r(r�9szPyShell.stop_readlinecCs�|j}zd|_|j��W||_n||_0|jr:d|_dS|j�dd�}t|�dkrXd}|��|jrtd|_t	stt
�|jr�d|_d}|S)NTFrQr�r�rrm)rtr��mainlooprurA�getr~r�r9rr��	endoffile)r=r5rr'r'r(�readline?s(zPyShell.readlinecCsdSrsr'r�r'r'r(�isattyVszPyShell.isattycCs�z|j�ddd�rWdSWnYn0|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�rtr�r]r r�ryr9r�r�r�r�r�rvr�r'r'r(rOYs&



zPyShell.cancel_callbackcCsf|jr|jsdS|j�ddd�r0|j�ddd�s4dS|jsL|��|��nd|_d|_|j�	�dS)Nr�z==r`r�FTrP)
r�rtrAr�r�r�r9ryr�rvr�r'r'r(rPos�

zPyShell.eof_callbackcCs0|jr"|j�dd�|j�d�n
|�|�dS)Nr`rmrP)rtrAr`�see�newline_and_indent_eventr�r'r'r(rN~s

zPyShell.linefeed_callbackcCs:|jr|jsdSz8|j�dd�}|rF|j�ddd�rF|�||�WdSWnYn0|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)Nr|r}z<=r�rPr`r��iomark linestartr�rrzinsert lineendz>=r�rer�zend-1c linestartrm)r�rtrArxr��recallZ
tag_prevrangeZ
tag_nextranger��stripr�rr`r~rXZupdate_idletasksr�rv�runit)r=rd�sel�prev�next�indicesr�r'r'r(rM�sZ
�


zPyShell.enter_callbackc	CsLt�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�W|j�d�|j��n|j�d�|j��0dS)Nz^\s*\nrQz\n\s*$rmr�rhr�r`r�re�:rrz	^([ \t]*))�re�subr%rAZundo_block_startrgr�rx�rstrip�endswithrr`r�r~�search�grouprrr~Zundo_block_stop)r=r�rdry�prefixZorig_base_indentZnew_base_indentrr'r'r(r��s.



�zPyShell.recallcCs�|j�dd�}t|�}|dkr8||ddvr8|d}q|dkrX||ddkrX|d}|dkrz||ddvrz|d}qX|d|�}|j�|�dS)Nr�r�rrz 	rm)rArxr~r]r#)r=rr�r'r'r(r��s

z
PyShell.runitcCs\|jjr|j��Sz
tjWn tjdd|jd�YdS0ddlm	}||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(r0�s

�zPyShell.open_stack_viewercCs|j�d�|j�d�dS)Nr�r�)rAr~r�r'r'r(rS�szPyShell.view_restart_markcCs|jjdd�dS)z&Callback for Run/Restart Shell Cntl-F6Tr�N)r]r�r�r'r'r(rTszPyShell.restart_shellcCs:|��|j�|j�|j�dd�|��|j��dS)Nr`r�)	r�r�r rLrAr��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�rrIrBr�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)	rArxr[Zstorer`r�r�ZctipZremove_calltip_window)r=rr'r'r(r�szPyShell.resetoutputr'cCsXz0|j�dd�t�|||d�}|j�dd�Wn�Yn0|jrTd|_tsTt�|S)Nr��rightr�F)rAr�rr r9rr�)r=r�r��countr'r'r(r sz
PyShell.writecs:z|j�ddd�rWdSWnty.YdS0t���S)Nr|r�r�rf)rAr�r��superrNr���	__class__r'r(rN+s
zPyShell.rmenu_check_cutcs|j�ddd�rdSt���S)Nr`r�r�rf)rAr�r�rOr�r�r'r(rO3szPyShell.rmenu_check_paste)N)N)N)N)N)N)N)r'):r�r�r�r
rlr�rr�rrGrr�Zallow_line_numbersZidlelib.historyr=r@r\rtr�r9ryr�rur_r`rQrarRrbrcrhr6rr�r�rkrmrqr�r�rzr{rOrPrNrMr�r�r0rSrTr�r�r�r rNrO�
__classcell__r'r'r�r(r�Ish

�
C


�
	?




r�c
Cs2|jdkr.dD]}|�|dd|�|d��qdS)z6Make paste replace selection on x11.  See issue #5124.Zx11)�TextZEntryZSpinboxz	<<Paste>>z%catch {%W delete sel.first sel.last}
N)Z_windowingsystemZ
bind_class)rv�clsr'r'r(�
fix_x11_paste9s

��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
s\ddl}ddlm}ddlm}ddlm}td�dad}d}d}d}d}d}	z|�tj	dd�d�\}
}WnF|j
y�}z,td	|tftj
d
�t�d�WYd}~n
d}~00|
D]�\}
}|
dkr�|}d}|
d
kr�d}d}|
dkr�d}|
dk�rtj�t�t��|
dk�rd}|
dk�r6tdtj
d
�da|
dk�rj|}tj�|��rTntd|�t��d}|
dk�r|d}	d}|
dkr�|t_d}q�|�r�|ddk�r�tj��}d}tttj��D]}tj�tj|�tj|<�q�|�r
|ddk�r
dg|dd�t_	n�|�rdg|t_	n�|�r2|g|t_	n�|�r�d}g}|D]}|�tj�|���qD|D],}tj�|�}|tjv�rbtj�d|��qbn"t��}|tjv�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�rRtj�'�d#�}t#j)|d$�nZ|�*��s�t+d%k�rpd&�d'}nd(�d)}��fd*d+�|D�}d,d+�|D�}t#j,dg|�R�t-t#�t.t#�t/t#�a0|�1t#t0�|�r|�s|�s|dd�D] }t0�2|�du�r�|�3|��q�|�st0�4�|�rTt0�5�}|�s6dS|�*��rZt0j6�rZ|j7�8�nt0j9}|�rh|�:�|	�r�tj;�<d-��p�tj;�<d.�}|�r�tj�|��r�|j=�>|�|�s�|�r�|j=�?d/tj	f�|�r�|j=�@|�n|�r4|j=�A|�|j=�>|�n8|�r4|�Bt#�}|�r|�C|�|�D�}|�r4|�C|�t0jE�rHt#�F��q4t#�G�td�dS)0Nr)�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
            
)H�getoptrpr�rr�r�r-rr��argv�errorr�	usage_msgr��exitr�r rGrHr|r�rlr�rr�r~rr[�dirnamer`�getcwdrr�Z
NoDefaultRootrHrvrI�idlelib.runr	rI�__file__Z
wm_iconbitmapZisAquaTk�	TkVersionZwm_iconphotorr�r�rEZsetupApprprf�newrF�dictr��lowerr\rc�environrxr]rr�rr'ZtkVersionWarningr�ZpreferTabsPreferenceWarningZinversedictrwZdestroy)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�zs$ 


�



�



��
��


r�F)NN)Rr�r�r�rr�ImportErrorrrr8rpZctypesZPROCESS_SYSTEM_DPI_AWAREZOleDLLZSetProcessDpiAwarenessr!r"rr�rHrvrIr�r	rwr"rr0rGZos.pathr
r�r�r��textwraprr�r�rr+Zidlelib.colorizerrZidlelib.configrrrrZidlelib.editorrrZidlelib.filelistrZidlelib.outwinrrrrrZidlelib.undorr�r��eofr�rv�	NameErrorrr)r*r-�
checkcacher7r8r�r�r�Z	RPCClientr�r�r�r�r�r�r�r'r'r'r(�<module>s��
�
�

�
?0s66