Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 18.218.250.235
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : pyshell.cpython-310.pyc
o

_b���
@s,ddlZedkrejdejd<zddlTWney(edejd�ed��wejdkrKzddl	Z	dZ
e	�d	��e
�Wnee
efyJYnwdd
lmZedkrte�at��ddlmZet�ejd
detd�ed��ddlmZddlZddlZddlZddlZddlmZddlZddlZddl Z ddl!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/ddl0m1Z1m2Z2ddl3m4Z4ddl5m6Z6ddl-m7Z7ddl-m8Z8ddlm9Z9m:Z:m;Z;ddl<m=Z=da>d Z?dZ@z
d!ZAeAeB_AeAeC_AWn
eD�yYnwejaE	d@d"d#�ZFdaGd$d%�ZHeHd&�dejIfd'd(�ZJeJe_IGd)d*�d*e1�ZKGd+d,�d,e4�ZLGd-d.�d.e(�ZMGd/d0�d0e=�ZNGd1d2�d2e,�ZOGd3d4�d4e8jP�ZQd5d6�ZRGd7d8�d8e�ZSGd9d:�d:e6�ZTd;d<�ZUd=ZVd>d?�ZWedk�r�eW�eHd�dS)A�N�__main__zidlelib.pyshell)�*zJ** IDLE can't import Tkinter.
Your Python may not be configured for Tk. **��file��win32Zshcore)�
messageboxg!@��fix_scalingzIdle Cannot Startz"Idle requires tcl/tk 8.5+, not %s.��parent)�InteractiveInterpreter)�python_version)�TextWrapper)�ColorDelegator)�idleConf)�	Delegator��debugger)�
debugger_r)�EditorWindow�
fixwordbreaks)�FileList)�OutputWindow)�replace)�rpc)�idle_formatwarning�StdInputFile�
StdOutputFile)�
UndoDelegatorFz	127.0.0.1zCtrl-D (end-of-file)c	CsN|durt}z|�t|||||d��|�d�WdSttfy&YdSw)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)�linez>>> )�warning_stream�writer�AttributeError�OSError)�message�category�filename�linenorr �r)�8/usr/local/python-3.10/lib/python3.10/idlelib/pyshell.py�idle_showwarningRs
��r+cCs:|rtdurtjatt_dSdStdurtt_dadSdS)z>Replace warning.showwarning with idle_showwarning, or reverse.N)�_warnings_showwarning�warnings�showwarningr+)�capturer)r)r*�capture_warningses
��r0TcCsXtj}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_checkcacher4�save�keyr)r)r*�extended_linecache_checkcachets�r:c@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�|�|jjrE|��|��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��
z;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@�argsrAr)r)r*rD�s�
�zPyShellEditorWindow.__init__))ZCutz<<cut>>�rmenu_check_cut)�Copyz<<copy>>�rmenu_check_copy)ZPastez	<<paste>>�rmenu_check_paste)NNN)zSet Breakpointr<N)zClear Breakpointr=NTcCsD|jdurdS|rt��}t�|d�}nddd�}|j�d|�dS)z,Turn colorizing of breakpoint text on or offN�break�)�
foreground�
background�BREAK)rOr�CurrentTheme�GetHighlightrEZ
tag_config)r@Zcolor�themeZcfgr)r)r*rP�s

z)PyShellEditorWindow.color_breakpoint_textcCs�|j}|jj}|�dd|d|d�z|j�|�Wnty+|j�|�Ynwz|jj	j
j}|�||�WdSYdS)NrZz%d.0r)
rErOr'�tag_addrC�index�
ValueError�appendrI�pyshell�interprrG)r@r(rEr'�debugr)r)r*�set_breakpoint�s�z"PyShellEditorWindow.set_breakpointNcCs>|j}|jj}|s|��dStt|�d���}|�|�dS)N�insert)rErOr'�bell�int�floatr_re)r@�eventrEr'r(r)r)r*rG�sz'PyShellEditorWindow.set_breakpoint_herecCs�|j}|jj}|s|��dStt|�d���}z|j�|�WnY|�	ddd�z|j
jjj
}|�||�WdSYdS)NrfrZ�insert linestartzinsert lineend +1char)rErOr'rgrhrir_rC�remove�
tag_removerIrbrcrrH)r@rjrEr'r(rdr)r)r*rH�s$�z)PyShellEditorWindow.clear_breakpoint_herecCsf|jr1|j}|jj}|s|��dSg|_|�ddt�z|jjj	j
}|�|�WdSYdSdS)NrZ�1.0)rCrErOr'rgrmZENDrIrbrcr�clear_file_breaks)r@rEr'rdr)r)r*ro�s�z%PyShellEditorWindow.clear_file_breaksc
CsZ|j}|jj}zt|jd��}|��}Wd�n1swYWnty.g}YnwzKt|jd��:}|D]}|�|d�sG|�|�q9|�	�|j}|rg|�|dt
|�d�Wd�WdSWd�WdS1sswYWdSty�}z&t|jdd�s�d|j_
tjd	d
t
|�|jd�WYd}~dSWYd}~dSd}~ww)z#Save breakpoints when file is saved�rN�w�=�
�breakpoint_error_displayedFTz
IDLE Errorz$Unable to update breakpoint list:
%s)�titler%r)rCrOr'�openrN�	readlinesr$�
startswithr"�update_breakpoints�str�getattr�rootrtr�	showerrorrE)r@Zbreaksr'�fp�linesZnew_filer �errr)r)r*�store_file_breaks�sF
���
��&������z%PyShellEditorWindow.store_file_breakscCs�|j��|jdurdS|jj}|durdStj�|j�rYt|jd��}|�	�}Wd�n1s2wY|D]!}|�
|d�rXt|t|�dd��}|D]}|�
|�qPq9dSdS)Nrprrr)rEr7rOr'rKrL�isfilerNrvrwrx�eval�lenre)r@r'r~rr Zbreakpoint_linenumbersZbreakpoint_linenumberr)r)r*r?s$


���z'PyShellEditorWindow.restore_file_breakscCs$|j}|�d�}|�|�}||_dS)z3Retrieves all the breakpoints in the current windowrZN)rEZ
tag_ranges�ranges_to_linenumbersrC)r@rE�rangesZlinenumber_listr)r)r*ry+s


z&PyShellEditorWindow.update_breakpointscCshg}tdt|�d�D]'}tt||j��}tt||dj��}||kr1|�|�|d7}||ks$q
|S)Nr�r)�ranger�rhri�stringra)r@r�rr_r(�endr)r)r*r�2s
��z)PyShellEditorWindow.ranges_to_linenumberscCs|��t�|�dS)z7Extend base method - clear breaks when module is closedN)ror�_close�r@r)r)r*r�CszPyShellEditorWindow._close)Tr>)�__name__�
__module__�__qualname__�__doc__rD�rmenu_specsrPrerGrHror�r?ryr�r�r)r)r)r*r;�s
	

	*r;c@s"eZdZdZeZdZddd�ZdS)�PyShellFileListz8Extend base class: IDLE supports a shell and breakpointsNcCs<|jr|jj��|jSt|�|_|jr|j��sdS|jSr>)rb�top�wakeup�PyShell�begin�r@rjr)r)r*rJRs
�
zPyShellFileList.open_shellr>)r�r�r�r�r;rrbrJr)r)r)r*r�Is
r�c@s eZdZdZdd�Zdd�ZdS)�ModifiedColorDelegatorz8Extend base class: colorizer for the shell window itselfcCs*|�ddd�|�ddd�t�|�dS)NZTODOrn�iomarkZSYNC)rmr^r�recolorize_mainr�r)r)r*r�_sz&ModifiedColorDelegator.recolorize_maincCs|jD]	}|�|dd�qdS)Nr�r�)Ztagdefsrm)r@�tagr)r)r*�removecolorsds
�z#ModifiedColorDelegator.removecolorsN)r�r�r�r�r�r�r)r)r)r*r�]sr�cs4eZdZdZd	dd�Zd	dd�Z�fdd�Z�ZS)
�ModifiedUndoDelegatorz;Extend base class: forbid insert/delete before the I/O markNcCsLz|j�|dd�r|j��WdSWn	tyYnwt�||||�dS�N�<r�)�delegate�comparerg�TclErrorrrf�r@r_�chars�tagsr)r)r*rfls
��zModifiedUndoDelegator.insertcCsJz|j�|dd�r|j��WdSWn	tyYnwt�|||�dSr�)r�r�rgr�r�delete)r@Zindex1�index2r)r)r*r�us
��zModifiedUndoDelegator.deletecs>|jj��fdd�|j_z
t��|�W�|j_dS�|j_w)Ncs�||d�S�N�stdinr))r_r��Zorig_insertr)r*�<lambda>��z2ModifiedUndoDelegator.undo_event.<locals>.<lambda>)r�rf�super�
undo_eventr���	__class__r�r*r�~s
�z ModifiedUndoDelegator.undo_eventr>)r�r�r�r�rfr�r��
__classcell__r)r)r�r*r�js


		r�c@seZdZdZddd�ZdS)�UserInputTaggingDelegatorz.Delegator used to tag user input with "stdin".NcCs |durd}|j�|||�dSr�)r�rfr�r)r)r*rf�sz UserInputTaggingDelegator.insertr>)r�r�r�r�rfr)r)r)r*r��sr�c@seZdZdd�ZdS)�MyRPCClientcCst�)z0Override the base class - just re-raise EOFError)�EOFErrorr�r)r)r*�
handle_EOF��zMyRPCClient.handle_EOFN)r�r�r�r�r)r)r)r*r��sr�cCsZd|pd�d�}|t|�kr't|t|�d�\}}||d�|�|d��S|dd�S)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�rrN���)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,�ZdAd-d.�Zd/d0�Zd1d2�Zd3d4�Z d5d6�Z!d7d8�Z"d9d:�Z#d;d<�Z$d=d>�Z%dS)B�ModifiedInterpretercCsB||_tjdj}tj||d�d|_d|_t|_	|j
jj|_
dS)Nr)�localsF)�	tkconsole�sys�modules�__dict__r
rD�
restarting�subprocess_arglist�PORT�port�compile�compiler�flags�original_compiler_flags)r@r�r�r)r)r*rD�szModifiedInterpreter.__init__NcCs&|jdur
|��|_t�|j�|_dSr>)r��build_subprocess_arglist�
subprocess�Popen�
rpcsubprocr�r)r)r*�spawn_subprocess�s

z$ModifiedInterpreter.spawn_subprocesscCs\|jdks	Jd��dd�tjD�}tjddddd	d
�}d|f}tjg|d|t|j�gS)
Nrz/Socket should have been assigned a port number.cSsg|]}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�r��warnoptionsr�	GetOption�
executablerz)r@rqZ	del_exitfZcommandr)r)r*r��s�
�
z,ModifiedInterpreter.build_subprocess_arglistc	CsPt|jf}td�D]}t�|�zt|�|_Wq(ty!Yq	w|��dS|jj	�
�d|_tdkr@|jj	�t
jt
jd�|��|jj	�d�z|j��Wnty`|��YdSw|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�
�consoler��stdout�stderrrIr3rcT��with_cwd)�HOSTr�r��time�sleepr��rpccltr$�display_port_binding_error�listening_sock�getsocknamer��
setsockopt�socket�
SOL_SOCKET�SO_REUSEADDRr��
settimeout�accept�TimeoutError�display_no_subprocess_error�registerr�r�r�r�rIr3�
transfer_path�poll_subprocess)r@�addr�ir)r)r*�start_subprocess�sD


���z$ModifiedInterpreter.start_subprocessFrWcCs&|jr|jSd|_|��}|rzt�|j�WnY|j��|��|j}|j}d|_|�	�z|j�
�WntyG|��YdSw|j
|d�|��|j�dd�|�d�|�t|j|��|j�dd�|j�dd�|s{|��|r�t�|j�|��|j|jj_d|_|jS)	NTFr�r��end-1crs�restart�left)r�r��getdebuggerrZclose_subprocess_debugger�close�terminate_subprocessr��	executingr�r�r�r�r��
stop_readlinerEr�r"r�r��mark_set�mark_gravity�
showpromptZrestart_subprocess_debugger�load_breakpointsr�r�r�r�)r@r�r'rdr�Z
was_executingr)r)r*�restart_subprocess�sH
�
z&ModifiedInterpreter.restart_subprocesscCs|j�dddi�dS)N�execZinterrupt_the_serverr))r�Z
remotecallr�r)r)r*Z__request_interrupt�z'ModifiedInterpreter.__request_interruptcCstj|jd���dS)N)�target)�	threading�Thread�'_ModifiedInterpreter__request_interrupt�startr�r)r)r*�interrupt_subprocess"rz(ModifiedInterpreter.interrupt_subprocesscCsz|jdur
|jj�|j�z|jj��Wn	tyYnwz|j��Wn	ty/Ynw|��d|j_	d|_dS)NF)
�_afteridr�rEZafter_cancelr�r�r�r#r�r�r�r)r)r*�kill_subprocess%s
��
z#ModifiedInterpreter.kill_subprocesscCsJz|j��Wn
tyYdSwz|j��WdSty$YdSw)z"Make sure subprocess is terminatedN)r��killr$�waitr�r)r)r*r�4s��z(ModifiedInterpreter.terminate_subprocesscCs2|rdg}|�tj�ntj}|�d|f�dS)NrWzRif 1:
        import sys as _sys
        _sys.path = %r
        del _sys
        
)�extendr�rL�
runcommand)r@r�rLr)r)r*r�As
�z!ModifiedInterpreter.transfer_pathc
Cs2|j}|dur	dSz
|j|jdd�}Wntttfy,|jjr$YdSd}|��Ynw|r�|j�	�d|_|\}}|jj
}|dkrP|durOtt|�|d�n$|dkr_|j�
d�r^|��n|dkrtd}t||tjd�t|||d�z|j��Wn	ty�Ynw|jjs�|jj�|jj|j�|_dSdS)	Ng�������?)rZOKrZ	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#rE�after�pollintervalr�r)r@Zclt�response�howZwhatr��errmsgr)r)r*r�PsL�
���

��z#ModifiedInterpreter.poll_subprocesscCs
||_dSr>r)r@rr)r)r*�setdebuggerxs
zModifiedInterpreter.setdebuggercC�|jSr>rr�r)r)r*r�{�zModifiedInterpreter.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�rErrr�r)r)r*�open_remote_stack_viewer~s
z,ModifiedInterpreter.open_remote_stack_viewercCs�ddlm}|j�dddi�}|dur|jj��dS|�|j|�}ddlm	}m
}t|jj�}t�
�}t�|d�d}|||dd	�}	|	jjd
dd�||	jd|�}
|
��dS)
Nr)�
debugobj_rrZstackviewer)rI)�ScrolledCanvas�TreeNode�normalrY)�bgZhighlightthicknessrZboth)�expand�fill)�idlelibr'r��remotequeuer�r|rgZStubObjectTreeItemZidlelib.treer(r)ZToplevelrr[r\�frame�packZcanvasr,)r@r'Zoid�itemr(r)r�r]rYZscZnoder)r)r*r�s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�|dur-t�|��}|��}trdtj�|��d�|d}Wd�n1s(wYzt||d�}Wn$tt	fyY|j
��td|j
j
d�t�||�|j
��YdSw|�|�dS)zExecute an existing fileNz__file__ = r'''z'''
z
del __file__rzB*** Error in script or command!
Traceback (most recent call last):r)�tokenizerv�read�use_subprocessrKrL�abspathr��
OverflowError�SyntaxErrorr�rrr�r
�showsyntaxerrorr�runcode)r@r'r6r~�coder)r)r*r4�s,����
��zModifiedInterpreter.execfilecCs&|�|�}t|t�sJ�t�|||�S)zBExtend base class method: Stuff the source in the line cache first)r3�
isinstancerzr
�	runsourcer5r)r)r*rB�s
zModifiedInterpreter.runsourcecCs>d|j}|jd|_|�d�}t|�dd||ftj|<|S)z"Stuff source in the filename cachez<pyshell#%d>rrsr)�gid�splitr�r3r4)r@r6r'rr)r)r*r3�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|pd}t|dd�p%d}t|d	d�p-d
}	|	d
kr6|d7}|dkrAd|	d}
n
d|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.

        rrnr��msgrWz<no detail available>r(r�offsetrziomark + %d charsz&iomark linestart + %d lines + %d charszSyntaxError: %s
N)
r�rErmr��exc_infor{Zcolorize_syntax_errorrr"r)r@r'r�rEr��value�tbrGr(rH�posr)r)r*r>�s$�z#ModifiedInterpreter.showsyntaxerrorcCs:|j��|��t�|�|j�d�r|j��dSdS)z1Extend base class method to reset output properlyrN)r�r�checklinecacher
�
showtracebackr�open_stack_viewerr�r)r)r*rN�s

�z!ModifiedInterpreter.showtracebackcCs>tj}t|���D]}|dd�|dd�dkr||=q	dS)Nrr1r2)r3r4r5�keys)r@�cr9r)r)r*rM�s��z"ModifiedInterpreter.checklinecachecCsB|jjr
|��dS|jr|j�dd|fi�dSt||j�dS)z*Run the code without invoking the debuggerrrr?r)r�r��display_executing_dialogr�r/rr�)r@r@r)r)r*r�s�zModifiedInterpreter.runcommandcCsd|jjr|��|��|j}z�z*|j��|s)|jdur)|j�dd|fi�|_n|r3|�	||j
�nt||j
�WnKtyY|jj
sVtjddd|jjd�rQ�|��n�Yn-trptd|jjd	�|��|j��n|jjr�d
|j_td|jjd	�n|��YWts�z|j��WdSty�YdSwdSts�z|j��Wwty�Ywww)�Override base class methodNrr?zExit?zDo you want to exit altogether?Zyes�r�rz IDLE internal error in runcode()rFr)r�r�rrMr�beginexecutingr�Z
asyncqueuer�runr�r�
SystemExitrrZaskyesnorErNr:rr�r�canceledr#)r@r@rr)r)r*r?sf

���
�������zModifiedInterpreter.runcodecCs|jj�|�S)rS)r�r�r")r@r�r)r)r*r"6szModifiedInterpreter.writecC�tjdd|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�rr}r�rEr�r)r)r*r�:s

�z.ModifiedInterpreter.display_port_binding_errorcCrY)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-failurerrZr�r)r)r*r�Es

�z/ModifiedInterpreter.display_no_subprocess_errorcCrY)NzAlready executingzYThe Python Shell window is already executing a command; please wait until it is finished.rrZr�r)r)r*rRMs

�z,ModifiedInterpreter.display_executing_dialog)FrW)Fr>)&r�r�r�rDrr�r�r�r�r�rr	rr
r�r�rr�rr#r�r&rrCr7r4rBr3rFr>rNrMrr?r"r�r�rRr)r)r)r*r��sH	
+,


&

	
.r�cseZdZddlmZde�ZeZe	Z
gd�Zej
dgZ
deee�dd�e
���Ze
�ed	�[d
ZdZddlmZdd
lmZdddd�Z�fdd�Z�fdd�Zdd�Zdd�Zdddd�Zd
Z d
Z!d
Z"d
Z#d
Z$d
Z%dd�Z&dd�Z'dddd �Z(d!d"�Z)ddd#d$�Z*d%d&�Z+d'd(�Z,d)d*�Z-d+d,�Z.d-d.�Z/d/d0�Z0d1d2�Z1d3d4�Z2d5d6�Z3d7Z4d8d9�Z5d:d;�Z6d<d=�Z7d>d?�Z8ddd@dA�Z9dBdC�Z:dDdE�Z;dFdG�Z<dHdI�Z=e>�?dJ�Z@dKdL�ZAdddMdN�ZBdddOdP�ZCdddQdR�ZDdSdT�ZEdUdV�ZFdWdX�ZGdedZd[�ZH�fd\d]�ZI�fd^d_�ZJddd`da�ZKdbdc�ZL�ZMS)fr�r)�SqueezerzIDLE Shell ))rZ_File)ZeditZ_Edit)rdZ_Debug)�optionsZ_Options)ZwindowZ_Window)�helpZ_Help)ZSqueeze�<<squeeze-current-text>>rcCs|ddkS)NrrSr))Z
rmenu_itemr)r)r*r�mr�zPyShell.<lambda>)zCopy with prompts�<<copy-with-prompts>>rTFr�)�History)�ShellSidebarNcCsXtr|j}|dddkr|�dd�t|�|_|dur+t�}t|�|��t|�}d|_	t
�||dd�d|_d|_
ttd�rDtjnd|_|j�d	�d
|_|j|_|j}|jdd�|�d
|j�|�d|j�|�d|j�|�d|j�|�d|j�|�d|j�|�d|j�|�d|j�tr�|�d|j �|�d|j!�|�"|�|_#|�d|j$�tj%|_&tj'|_(tj)|_*ddl+m,}t-|d|j.|j/�|_)t0|d|j.|j/�|_%t0|d|j.d�|_'t0|d|j.|j/�|_1ts�|j%t_%|j't_'|j)t_)z
ddl2}|j3|_4Wntj5t_'�|�6|j�|_7d|_8|�9|�|_	|j:j;j|j_|j:�<t=��dS)Nr�r�shell)rbZShe_llF��ps1z>>>
rsr1�char)�wrapz<<newline-and-indent>>z<<plain-newline-and-indent>>z<<interrupt-execution>>z<<end-of-file>>z<<open-stack-viewer>>�<<toggle-debugger>>rr_z<<view-restart>>z<<restart-shell>>r^)�iomenur�r�r��backslashreplacer��2)>r:�
menu_specsrfr�rc�Tkr�withdrawr��
shell_sidebarrrDZusetabsZindentwidth�hasattrr�rd�sys_ps1rDZprompt_last_line�promptrEZ	configurerF�enter_callback�linefeed_callback�cancel_callback�eof_callbackrO�toggle_debugger�toggle_jit_stack_viewer�copy_with_prompts_callback�view_restart_mark�
restart_shellr[�squeezer�squeeze_current_text_eventr��save_stdoutr��save_stderrr��
save_stdinr.rhr�encoding�errorsrr��pydocZ
plainpagerZpagerrr`�historyrra�perr�Zinsertfilterr�)r@rI�msr|rErhr�r)r)r*rD{s�
�����zPyShell.__init__cs&t���|jdur|j��dSdSr>)r��	ResetFontrnZupdate_fontr�r�r)r*r��s

�zPyShell.ResetFontcs�t���t��}ddd�t�|d�t�|d�t�|d�d�}|��D]\}}|jj|fi|��q#|jdur>|j�	�dSdS)N)rYrXr�r�r*)r�r�r�r�)
r��ResetColorizerrr[r\�itemsrEZ
tag_configurernZ
update_colors)r@r]Z
tag_colorsr�Ztag_colors_configr�r)r*r��s



�
�zPyShell.ResetColorizercCstj|jdd�dS)Nr�)Zinsert_tagsrV)rrEr�r)r)r*�
replace_event�szPyShell.replace_eventcCstjdd�S)NT)Z
shell_only)rZ
GetExtensionsr�r)r)r*�get_standard_extension_names�sz$PyShell.get_standard_extension_namescs��j}�j�d��j�d�f}|ddurdS�jj|�}ttt|d��tt|d���}�fdd�|D�}d�d	d
�t||���D��d}|�	�|�
|�dS)aCopy selected lines to the clipboard, with prompts.

        This makes the copied text useful for doc-tests and interactive
        shell code examples.

        This always copies entire lines, even if only part of the first
        and/or last lines is selected.
        zsel.first linestartzsel.last +1line linestartrNrcsg|]	}�jj�|��qSr))rnZline_prompts�get)r�r(r�r)r*r��s��z6PyShell.copy_with_prompts_callback.<locals>.<listcomp>rscss.�|]\}}|dur|n|�d|��VqdS)N� r))r�rqr r)r)r*�	<genexpr>s
��
�z5PyShell.copy_with_prompts_callback.<locals>.<genexpr>)rEr_r�r�rhrirM�zip�
splitlinesZclipboard_clearZclipboard_append)r@rjrEZselection_indexesZ
selected_textZselection_lineno_rangeZpromptsZselected_text_with_promptsr)r�r*rx�s*	

��
�
��z"PyShell.copy_with_prompts_callbackcCs|adSr>�r!)r@�streamr)r)r*�set_warning_streamszPyShell.set_warning_streamcCstSr>r�r�r)r)r*�get_warning_stream�zPyShell.get_warning_streamcCsJ|jrtjdd|jd�|��dS|j��}|r|��dS|��dS)NzDon't debug nowz*You can only toggle the debugger when idlerrV)	r�rr}rE�set_debugger_indicatorrcr��close_debugger�
open_debugger)r@rj�dbr)r)r*rvs�
zPyShell.toggle_debuggercCs|j��}|�d|�dS)Nrg)rcr�Zsetvar�r@r�r)r)r*r�&s
zPyShell.set_debugger_indicatorcCsdSr>r)r�r)r)r*rw*r�zPyShell.toggle_jit_stack_viewercCsh|j��}|r.|j�d�|��|jjrt�|jj�|��|j�	d�|j
|_|��|�
�dS)Nz[DEBUG OFF]
)rcr�r#r�r�rZclose_remote_debuggerrr�r"rprqrr�r�r)r)r*r�-s
zPyShell.close_debuggercCsX|jjr
t�|jj|�}nt�|�}|j�|�|��d|j|_	|�
�|��dS)Nz[DEBUG ON]
)rcr�rZstart_remote_debuggerrZDebuggerr#rrprqrr�)r@Zdbg_guir)r)r*r�:s
�
zPyShell.open_debuggercCs |jrdnd}|�dd|�dS)N�disabledr*rdz*tack*iewer)r�Zupdate_menu_state)r@�stater)r)r*�debug_menu_postcommandFszPyShell.debug_menu_postcommandcCs|��d|_dS)�Helper for ModifiedInterpreterTN)rr�r�r)r)r*rUJrBzPyShell.beginexecutingcCsd|_d|_|��dS)r�FN)r�rXrr�r)r)r*rOszPyShell.endexecutingcCsD|jrtjddd|jd�}|durdS|��d|_d|_t�|�S)zExtend EditorWindow.close()zKill?z7Your program is still running!
 Do you want to kill it?�okrTF�cancelT)	r�rZaskokcancelrEr�rXrrr�)r@r r)r)r*r�Us�
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)r�r:rcr
r}r�r�r~r�rr�r�rIrbr�rr�r�r)r)r*r�ds
zPyShell._closecC�dS)z8Override EditorWindow method: never remove the colorizerTr)rEr)r)r*�ispythonsourcetr�zPyShell.ispythonsourcecCr$r>)�shell_titler�r)r)r*�short_titlexr%zPyShell.short_titlezHType "help", "copyright", "credits" or "license()" for more information.cCs�|j�dd�|��trd}|j��}|s|��dSnd}tjt	_|�
dt	jt	j|j
|f�|j��|��ddl}d|_d|_dS)	Nr�rfrWFz�==== 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)rEr�rr:rcr�r�r�displayhookr�r"�version�platform�	COPYRIGHTZfocus_forcer�tkinterZ_support_default_rootZ
_default_root)r@Znosub�clientr�r)r)r*r�~s(
��
z
PyShell.begincCs|jsdSd|_|j��dS�NT)�reading�_stop_readline_flagr��quitr�r)r)r*r��szPyShell.stop_readlinecCs�|j}z
d|_|j��W||_n||_w|jrd|_dS|j�dd�}t|�dkr,d}|��|jr:d|_t	s:t
�|jrBd|_d}|S)NTFrWr�r�rrs)r�r��mainloopr�rEr�r�rrXr:r�	endoffile)r@r8r r)r)r*�readline�s(zPyShell.readlinecCr�r�r)r�r)r)r*�isatty�r�zPyShell.isattycCs�z
|j�ddd�rWdSWnY|js(|js(|��|j�d�|��dSd|_d|_	|jrE|jj
rE|j��r@|j��n|j�
�|jrM|j��dS)N�	sel.firstz!=�sel.lastzKeyboardInterrupt
rVFT)rEr�r�r�rrcr"rr�rXr�r�rrr�r�r�r)r)r*rt�s(�


zPyShell.cancel_callbackcCsh|jr|jsdS|j�ddd�r|j�ddd�sdS|js'|��|��dSd|_d|_|j�	�dS)Nr�z==rfr�FTrV)
r�r�rEr�rr�rXr�r�r�r�r)r)r*ru�s��
zPyShell.eof_callbackcCs2|jr|j�dd�|j�d�dS|�|�dS)NrfrsrV)r�rErf�see�newline_and_indent_eventr�r)r)r*rs�s
�zPyShell.linefeed_callbackc	Cs|jr|jsdSz|j�dd�}|r#|j�ddd�r#|�||�WdSWnY|j�ddd��r|j�d	d�}|r�|j�dd|d
�r�d|j�d�vr�|j�dd�}|rj|j�|d
d|d
�rj|d
|d
f}|j�dd�}|r�|j�|d
d|d
�r�|d
|j�	|d
d�f}|�|j�|d
|d
�|�dS|j�d	d�}|r�|j�dd|d
�r�|j�dd�}|r�|j�|d
d|d
�r�|d
|j�	|d
d�f}|�|j�|d
|d
�|�dS|j�dd�}|�r	|j�|d
dd��r	|�|j�|d
d�|�dS|�|j�dd�|�dS|j�ddd��r&|j�
dd�|j�dd�}|�r<|���s<|j�dd�|j�ddd��rL|�
|�dS|j�
dd�|j�re|j�dd�|j�d�n|�
|�|j��|j�rz|j��dS|��dS)Nr�r�z<=r�rVrfr��iomark linestartr�rr�z>=rz+1czinsert lineendrkr�zend-1c linestartrs)r�r�rEr�r��recallZ
tag_prevrangeZ	tag_namesZ
tag_nextranger_r��stripr�r�rfr�Zupdate_idletasksr�r��runit)	r@rj�sel�prevZ	prev_consZ	next_cons�next�indicesr�r)r)r*rr�sz������



�zPyShell.enter_callbackc	Cslt�dd|�}t�dd|�}|�d�}|j��z�|j�ddd�|j�dd	�|j�d
d�}|���	d�rB|�
|�|j�d
d�}|j�d|d��|j
�t|�d
kr�t�d|d��d�}t�d|��d�}|d
d�D],}|�|�r�||t|�d�}|j�dd|��|j
�qoW|j�d�|j��dSW|j�d�|j��dS|j�d�|j��w)Nz^\s*\nrWz\n\s*$rsr�rnr�rfr�rk�:rrz	^([ \t]*))�re�subrDrEZundo_block_startrmr�r��rstrip�endswithr�rfr��user_input_insert_tagsr��search�grouprxr�Zundo_block_stop)r@r�rjr�prefixZorig_base_indentZnew_base_indentr r)r)r*r�5s>


�
��
��zPyShell.recallz[ \t]*(\n[ \t]*)?\ZcCsj|j�d�}|j�dd�}|j�d|�}|j�|�}|s3|j�|�dkr,|j�|j|�|j	�
�dSdS)N�end-2cr�r�rWrs)rEr_r��_last_newline_rer�rcrBrmr�rn�update_sidebar)r@Zindex_beforer Zinput_is_completer)r)r*r�Rs�z
PyShell.runitcCsZ|jjr	|j��SztjWntjdd|jd�YdSddlm	}||j
|j�dS)NzNo stack tracez@There is no stack trace yet.
(sys.last_traceback is not defined)rr)�StackBrowser)rcr�rr��last_tracebackrr}rEZidlelib.stackviewerr�r|rI)r@rjr�r)r)r*rO^s

�zPyShell.open_stack_viewercCs|j�d�|j�d�dS)Nr�r�)rEr�r�r)r)r*rylszPyShell.view_restart_markcCs|jjdd�dS)z&Callback for Run/Restart Shell Cntl-F6Tr�N)rcrr�r)r)r*rzpszPyShell.restart_shellcCs||��|j}|jr|�|j�r|dt|j��}|j�dd�|j�|�|j	�
�|j�dd�|��|j
��dS)Nr�z	iomark-1crfr�)rrqrpr�r�rEr^r�r"rnr�r��set_line_and_columnrOZ
reset_undo)r@rqr)r)r*rts
zPyShell.showpromptcCsP|jjj}t|ddd�}d�|�|��}|�d�s|d7}|jj�	d|d�dS)N�T)r��tabsizeZexpand_tabsrsr�r�)
rcr�r�rrMrfr�r�Zbottomrf)r@rGr��wrapperZwrapped_msgr)r)r*�show_warning�s

zPyShell.show_warningcCsb|j�dd�}|jr|j�|�|j�d�dkr|j�dd�|j�dd�|��|j��dS)Nr�r�r�rs)	rEr�r��storerfr�r�ZctipZremove_calltip_window)r@r6r)r)r*r�szPyShell.resetoutputr)cCsRz|j�dd�t�|||d�}|j�dd�Wn�|jr'd|_ts't�|S)Nr��rightr�F)rErrr"rXr:r)r@r�r��countr)r)r*r"�sz
PyShell.writecs:z
|j�ddd�rWdSWn
tyYdSwt���S)Nr�r�r�r�)rEr�r�r�rRr�r�r)r*rR�s��
zPyShell.rmenu_check_cutcs|j�ddd�r
dSt���S)Nrfr�r�r�)rEr�r�rUr�r�r)r*rU�s
zPyShell.rmenu_check_pastecCs|j��|j��dSr>)r{Zsqueeze_current_textrnr�r�r)r)r*r|�s
z"PyShell.squeeze_current_text_eventcCs|j��dSr>)rnr�)r@r_rEr�r)r)r*�on_squeezed_expand�szPyShell.on_squeezed_expandr>)r))Nr�r�r�Zidlelib.squeezerr[rr�r�rr�rrkrr�r�r5�	itertools�	takewhileZ_idxrfZallow_line_numbersr�Zidlelib.historyr`Zidlelib.sidebarrarDr�r�r�r�rxr�r�rXr�rr�r�r�rvr�rwr�r�r�rUrr�r�r�r�r�r�r�r�r�rtrursrrr�r�r�r�r�rOryrzrr�rr"rRrUr|r�r�r)r)r�r*r�Us�

�

�
N
$


�
	O






r�c
Cs6|jdkrdD]}|�|dd|�|d��qdSdS)z6Make paste replace selection on x11.  See issue #5124.Zx11)ZTextZEntryZSpinboxz	<<Paste>>z%catch {%W delete sel.first sel.last}
N)Z_windowingsystemZ
bind_class)r|�clsr)r)r*�
fix_x11_paste�s

���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
sLddl}ddlm}ddlm}ddlm}td�dad}d}d}d}d}d}	z|�tj	dd�d�\}
}Wn#|j
yZ}ztd	|tftj
d
�t�d�WYd}~nd}~ww|
D]d\}
}|
dkri|}d}|
d
krqd}d}|
dkrwd}|
dkr�tj�t�t��|
dkr�d}|
dkr�tdtj
d
�da|
dkr�|}tj�|�r�n	td|�t��d}|
dkr�d}	d}|
dkr�|t_d}q]|r�|ddkr�tj��}d}tttj��D]}tj�tj|�tj|<q�|r�|ddkr�dg|dd�t_	nU|�rdg|t_	nK|�r|g|t_	nA|�r>d}g}|D]}|�tj�|���q|D]}tj�|�}|tjv�r;tj�d|��q&nt��}|tjv�rOtj�d|�tj ddddd�}|�p\|}|�pb|}t�rl|�slt!�t"dd�a#t#�$�dd l%m&}|t#�tj�'tj�t(�d!��|�d"k�r�tj�'�d#�}t#j)|d$�n-|�*��s�t+d%k�r�d&�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�|�rt0�5�}|�sdS|�*��rt0j6�r|j7�8�nt0j9}|�r)|�:�|	�rItj;�<d-��p8tj;�<d.�}|�rItj�|��rI|j=�>|�|�sO|�rt|j=�?d/tj	f�|�rd|j=�@|��q�|�rs|j=�A|�|j=�>|�n|�r�|�Bt#�}|�r�|�C|�|�D�}|�r�|�C|�t0jE�r�t#�F�t0jE�s�t#�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�-rWr�r�zeditor-on-startupr�)r�ZIdle)Z	classNamer	ZIconsZWindowszidle.ico)r�g333333!@z.png)�� �0�z.gif)r�r�r�cs"g|]
}tj��d|�f��qS)z	idle_%d%s)rKrLrM)r��size��extZicondirr)r*r�as�zmain.<locals>.<listcomp>cSsg|]}tt|d��qS))Zmasterr)Z
PhotoImager|)r��iconfiler)r)r*r�cs�ZIDLESTARTUPZ
PYTHONSTARTUPzbif 1:
            import sys as _sys
            _sys.argv = %r
            del _sys
            
)H�getoptr�r�r.r�r�r0r:r��argv�errorr�	usage_msgr��exitr�r"rKrLr�r�r�r�r9r�r�r;ra�dirnamerf�getcwdrr�Z
NoDefaultRootrlr|rm�idlelib.runr
rM�__file__Z
wm_iconbitmapZisAquaTk�	TkVersionZwm_iconphotorr�r�rIZsetupApprvrl�newrJ�dictr��lowerrbr��environr�rcr4rr7rFZtkVersionWarningr�ZpreferTabsPreferenceWarningZinversedictr�Zdestroy)r�r�r�r�Zenable_shellZenable_editrd�cmdZscriptZstartupZoptsrQrG�o�ar�Zpathxr'�dirZ
edit_startr
r�ZsizesZ	iconfilesZiconsrbZtkversionwarningZprefer_tabs_preference_warningr)r�r*r��s6���
�
���



��
�
�
���


�r�)NN)Xr�r�r�r��ImportErrorrrrWr�ZctypesZPROCESS_SYSTEM_DPI_AWAREZOleDLLZSetProcessDpiAwarenessr#r$rr�rlr|rmr�r
r}r@r
r�r3rKZos.pathrr�r�r��textwraprrr�r8r-Zidlelib.colorizerrZidlelib.configrZidlelib.delegatorrr.rrZidlelib.editorrrZidlelib.filelistrZidlelib.outwinrrrrrrZidlelib.undorr:r�r��eofr�r��	NameErrorr!r+r,r0�
checkcacher:r;r�r�r�r�Z	RPCClientr�r�r�r�r�r�r�r)r)r)r*�<module>s���
��
�
�

�?
"0f6
6
© 2025 GrazzMean