Your IP : 216.73.216.196


Current Path : /opt/alt/python310/lib64/python3.10/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/idlelib/__pycache__/pyshell.cpython-310.opt-2.pyc

o

0�i��
@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�Zwin32Zshcore)�
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	CsP	|durt}z|�t|||||d��|�d�WdSttfy'YdSw)N)�linez>>> )�warning_stream�writer�AttributeError�OSError)�message�category�filename�linenorr�r(�6/opt/alt/python310/lib64/python3.10/idlelib/pyshell.py�idle_showwarningRs
��r*cCs<	|rtdurtjatt_dSdStdurtt_dadSdS�N)�_warnings_showwarning�warnings�showwarningr*)Zcapturer(r(r)�capture_warningses
��r/TcCsZ	tj}i}t|�D]}|dd�|dd�dkr!|�|�||<q
||�|�|�dS�Nr���z<>)�	linecache�cache�list�pop�update)r&Zorig_checkcacher3�save�keyr(r(r)�extended_linecache_checkcachets	�r9c@steZdZ	dd�Zgd�Zddd�Zdd�Zdd
d�Zddd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zd	S)�PyShellEditorWindowcGs�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|��|�dSr+)�restore_file_breaks)Zold_hook�selfr(r(r)�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�joinrZuserdir�breakpointPath�ioZfilename_change_hookZset_filename_change_hookr&r=�color_breakpoint_text)r>�argsr?r(r(r)rA�s�
�zPyShellEditorWindow.__init__))ZCutz<<cut>>�rmenu_check_cut)�Copyz<<copy>>�rmenu_check_copy)ZPastez	<<paste>>�rmenu_check_paste)NNN)zSet Breakpointr;N)zClear Breakpointr<NTcCsF	|jdurdS|rt��}t�|d�}nddd�}|j�d|�dS)N�break�)�
foreground�
background�BREAK)rLr�CurrentTheme�GetHighlightrBZ
tag_config)r>Zcolor�themeZcfgr(r(r)rM�s

z)PyShellEditorWindow.color_breakpoint_textcCs�|j}|jj}|�dd|d|d�z|j�|�Wnty+|j�|�Ynwz|jj	j
j}|�||�WdSYdS)NrWz%d.0r)
rBrLr&�tag_addr@�index�
ValueError�appendrF�pyshell�interprrD)r>r'rBr&�debugr(r(r)�set_breakpoint�s�z"PyShellEditorWindow.set_breakpointNcCs>|j}|jj}|s|��dStt|�d���}|�|�dS)N�insert)rBrLr&�bell�int�floatr\rb)r>�eventrBr&r'r(r(r)rD�sz'PyShellEditorWindow.set_breakpoint_herecCs�|j}|jj}|s|��dStt|�d���}z|j�|�WnY|�	ddd�z|j
jjj
}|�||�WdSYdS)NrcrW�insert linestartzinsert lineend +1char)rBrLr&rdrerfr\r@�remove�
tag_removerFr_r`rrE)r>rgrBr&r'rar(r(r)rE�s$�z)PyShellEditorWindow.clear_breakpoint_herecCsf|jr1|j}|jj}|s|��dSg|_|�ddt�z|jjj	j
}|�|�WdSYdSdS)NrW�1.0)r@rBrLr&rdrjZENDrFr_r`r�clear_file_breaks)r>rBr&rar(r(r)rl�s�z%PyShellEditorWindow.clear_file_breaksc
Cs\	|j}|jj}zt|jd��}|��}Wd�n1swYWnty/g}YnwzKt|jd��:}|D]}|�|d�sH|�|�q:|�	�|j}|rh|�|dt
|�d�Wd�WdSWd�WdS1stwYWdSty�}z&t|jdd�s�d|j_
tjdd	t
|�|jd
�WYd}~dSWYd}~dSd}~ww)N�r�w�=�
�breakpoint_error_displayedFTz
IDLE Errorz$Unable to update breakpoint list:
%s)�titler$r)r@rLr&�openrK�	readlinesr#�
startswithr!�update_breakpoints�str�getattr�rootrqr�	showerrorrB)r>Zbreaksr&�fp�linesZnew_filer�errr(r(r)�store_file_breaks�sH
���
��&������z%PyShellEditorWindow.store_file_breakscCs�|j��|jdurdS|jj}|durdStj�|j�rYt|jd��}|�	�}Wd�n1s2wY|D]!}|�
|d�rXt|t|�dd��}|D]}|�
|�qPq9dSdS)Nrmror)rBr6rLr&rHrI�isfilerKrsrtru�eval�lenrb)r>r&r{r|rZbreakpoint_linenumbersZbreakpoint_linenumberr(r(r)r=s$


���z'PyShellEditorWindow.restore_file_breakscCs&	|j}|�d�}|�|�}||_dS)NrW)rBZ
tag_ranges�ranges_to_linenumbersr@)r>rB�rangesZlinenumber_listr(r(r)rv+s



z&PyShellEditorWindow.update_breakpointscCshg}tdt|�d�D]'}tt||j��}tt||dj��}||kr1|�|�|d7}||ks$q
|S)Nr�r)�ranger�rerf�stringr^)r>r�r|r\r'�endr(r(r)r�2s
��z)PyShellEditorWindow.ranges_to_linenumberscCs	|��t�|�dSr+)rlr�_close�r>r(r(r)r�CszPyShellEditorWindow._close)Tr+)�__name__�
__module__�__qualname__rA�rmenu_specsrMrbrDrErlr~r=rvr�r�r(r(r(r)r:�s
	

	*r:c@s eZdZ	eZdZddd�ZdS)�PyShellFileListNcCs<|jr|jj��|jSt|�|_|jr|j��sdS|jSr+)r_�top�wakeup�PyShell�begin�r>rgr(r(r)rGRs
�
zPyShellFileList.open_shellr+)r�r�r�r:rr_rGr(r(r(r)r�Is
r�c@seZdZ	dd�Zdd�ZdS)�ModifiedColorDelegatorcCs*|�ddd�|�ddd�t�|�dS)NZTODOrk�iomarkZSYNC)rjr[r�recolorize_mainr�r(r(r)r�_sz&ModifiedColorDelegator.recolorize_maincCs|jD]	}|�|dd�qdS)Nr�r�)Ztagdefsrj)r>�tagr(r(r)�removecolorsds
�z#ModifiedColorDelegator.removecolorsN)r�r�r�r�r�r(r(r(r)r�]sr�cs2eZdZ	ddd�Zddd�Z�fdd�Z�ZS)	�ModifiedUndoDelegatorNcCsLz|j�|dd�r|j��WdSWn	tyYnwt�||||�dS�N�<r�)�delegate�comparerd�TclErrorrrc�r>r\�chars�tagsr(r(r)rcls
��zModifiedUndoDelegator.insertcCsJz|j�|dd�r|j��WdSWn	tyYnwt�|||�dSr�)r�r�rdr�r�delete)r>Zindex1Zindex2r(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�rc�super�
undo_eventr���	__class__r�r)r�~s
�z ModifiedUndoDelegator.undo_eventr+)r�r�r�rcr�r��
__classcell__r(r(r�r)r�js


		r�c@seZdZ	ddd�ZdS)�UserInputTaggingDelegatorNcCs |durd}|j�|||�dSr�)r�rcr�r(r(r)rc�sz UserInputTaggingDelegator.insertr+)r�r�r�rcr(r(r(r)r��sr�c@seZdZdd�ZdS)�MyRPCClientcCs	t�r+)�EOFErrorr�r(r(r)�
handle_EOF��zMyRPCClient.handle_EOFN)r�r�r�r�r(r(r(r)r��sr�cCs\	d|pd�d�}|t|�kr(t|t|�d�\}}||d�|�|d��S|dd�S)Nz= RESTART: ZShellz =r�ro���)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rA�
restarting�subprocess_arglist�PORT�port�compile�compiler�flags�original_compiler_flags)r>r�r�r(r(r)rA�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>�sz@ModifiedInterpreter.build_subprocess_arglist.<locals>.<listcomp>�main�Generalzdelete-exitfuncF�bool)�default�typez&__import__('idlelib.run').run.main(%r)�-c)r��warnoptionsr�	GetOption�
executablerwr�)r>rnZ	del_exitfZcommandr(r(r)r��s
�
z,ModifiedInterpreter.build_subprocess_arglistc	CsPt|jf}td�D]}t�|�zt|�|_Wnty!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�stderrrFr2r`T��with_cwd)�HOSTr�r��time�sleepr��rpccltr#�display_port_binding_error�listening_sockZgetsocknamer�Z
setsockopt�socketZ
SOL_SOCKETZSO_REUSEADDRr�Z
settimeout�accept�TimeoutError�display_no_subprocess_error�registerr�r�r�r�rFr2�
transfer_path�poll_subprocess)r>Zaddr�ir(r(r)�start_subprocess�sD


���z$ModifiedInterpreter.start_subprocessFrTcCs&|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-1crp�restart�left)r�r��getdebuggerrZclose_subprocess_debugger�close�terminate_subprocessr��	executingr�r�r�r�r��
stop_readlinerBr�r!r�r��mark_set�mark_gravity�
showpromptZrestart_subprocess_debugger�load_breakpointsr�r�r�r�)r>r�r&rar�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)�	threadingZThread�'_ModifiedInterpreter__request_interrupt�startr�r(r(r)�interrupt_subprocess"r�z(ModifiedInterpreter.interrupt_subprocesscCsz|jdur
|jj�|j�z|jj��Wn	tyYnwz|j��Wn	ty/Ynw|��d|j_	d|_dS�NF)
�_afteridr�rBZafter_cancelr�r�r�r"r�r�r�r(r(r)�kill_subprocess%s
��
z#ModifiedInterpreter.kill_subprocesscCsL	z|j��Wn
tyYdSwz|j��WdSty%YdSwr+)r��killr#�waitr�r(r(r)r�4s��z(ModifiedInterpreter.terminate_subprocesscCs2|rdg}|�tj�ntj}|�d|f�dS)NrTzRif 1:
        import sys as _sys
        _sys.path = %r
        del _sys
        
)�extendr�rI�
runcommand)r>r�rIr(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"rB�after�pollintervalr�r)r>Zclt�responseZhowZwhatr��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)Ni,)r�rBrrr�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_rr�Zstackviewer)rF)�ScrolledCanvas�TreeNode�normalrV)ZbgZhighlightthicknessrZboth)�expandZfill)�idlelibrr��remotequeuer�ryrdZStubObjectTreeItemZidlelib.treerrZToplevelrrXrY�frameZpackZcanvasr)r>rZoid�itemrrr�rZrVZscZnoder(r(r)r�sz'ModifiedInterpreter.remote_stack_viewerrcCs	|�|�}|�||�dSr+)�stuffsource�execfile�r>�sourcer&r(r(r)�
execsource�s
zModifiedInterpreter.execsourcec	Cs�	|dur.t�|��}|��}trdtj�|��d�|d}Wd�n1s)wYzt||d�}Wn$tt	fyZ|j
��td|j
j
d�t�||�|j
��YdSw|�|�dS)Nz__file__ = r'''z'''
z
del __file__r�zB*** Error in script or command!
Traceback (most recent call last):r)�tokenizers�read�use_subprocessrHrI�abspathr��
OverflowError�SyntaxErrorr�rr
r�r�showsyntaxerrorr��runcode)r>r&r'r{�coder(r(r)r%�s.����
��zModifiedInterpreter.execfilecCs	|�|�}t�|||�Sr+)r$r�	runsourcer&r(r(r)r2�s
zModifiedInterpreter.runsourcecCs@	d|j}|jd|_|�d�}t|�dd||ftj|<|S)Nz<pyshell#%d>rrpr)�gid�splitr�r2r3)r>r'r&r|r(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|pd}t|dd�p&d}t|d	d�p.d
}	|	d
kr7|d7}|dkrBd|	d}
n
d|d|	df}
|�||
�|��|�d
|�|�	�dS)Nrrkr��msgrTz<no detail available>r'r�offsetrziomark + %d charsz&iomark linestart + %d lines + %d charszSyntaxError: %s
)
r�rBrjr��exc_inforxZcolorize_syntax_errorrr!r�)r>r&r�rBr��value�tbr7r'r8�posr(r(r)r/�s&�z#ModifiedInterpreter.showsyntaxerrorcCs<	|j��|��t�|�|j�d�r|j��dSdS)Nr)r�r�checklinecacher�
showtracebackr�open_stack_viewerr�r(r(r)r>�s

�z!ModifiedInterpreter.showtracebackcCs>tj}t|���D]}|dd�|dd�dkr||=q	dSr0)r2r3r4�keys)r>�cr8r(r(r)r=�s��z"ModifiedInterpreter.checklinecachecCsD	|jjr|��dS|jr|j�dd|fi�dSt||j�dS)Nrr�r0r)r�r��display_executing_dialogr�r!r�r�)r>r1r(r(r)r�s�zModifiedInterpreter.runcommandcCsf	|jjr	|��|��|j}z�z*|j��|s*|jdur*|j�dd|fi�|_n|r4|�	||j
�nt||j
�WnKtyZ|jj
sWtjddd|jjd�rR�|��n�Yn-trqtd|jjd�|��|j��n|jjr�d	|j_td
|jjd�n|��YWts�z|j��WdSty�YdSwdSts�z|j��Wwty�Ywww)Nr�r0zExit?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��
SystemExitrrZaskyesnorBr>r+r
r�r�canceledr")r>r1rr(r(r)r0sh

���
�������zModifiedInterpreter.runcodecCs	|jj�|�Sr+)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
�rrzr�rBr�r(r(r)r�:s

�z.ModifiedInterpreter.display_port_binding_errorcCrH)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
rIr�r(r(r)r�Es

�z/ModifiedInterpreter.display_no_subprocess_errorcCrH)NzAlready executingzYThe Python Shell window is already executing a command; please wait until it is finished.r
rIr�r(r(r)rBMs

�z,ModifiedInterpreter.display_executing_dialog)FrT)Fr+)&r�r�r�rArr�r�r�r�r�r�r�r�rr�r�r	r�rrr�rrr3r(r%r2r$r6r/r>r=rr0r!r�r�rBr(r(r(r)r��sH	
+,


&

	
.r�cs&eZdZddlmZde�ZeZe	Z
gd�Zej
dgZ
deee�dd�e
���Ze
�ed	�[d
ZdZddlmZdd
lmZdfdd�Z�fdd�Z�fdd�Zdd�Zdd�Zdd�Zdfdd�Z d
Z!d
Z"d
Z#d
Z$d
Z%d
Z&dd�Z'dd �Z(dfd!d"�Z)d#d$�Z*dfd%d&�Z+d'd(�Z,d)d*�Z-d+d,�Z.d-d.�Z/d/d0�Z0d1d2�Z1d3d4�Z2d5d6�Z3d7d8�Z4d9Z5d:d;�Z6d<d=�Z7d>d?�Z8d@dA�Z9dfdBdC�Z:dDdE�Z;dFdG�Z<dHdI�Z=dJdK�Z>e?�@dL�ZAdMdN�ZBdfdOdP�ZCdfdQdR�ZDdfdSdT�ZEdUdV�ZFdWdX�ZGdYdZ�ZHdgd\d]�ZI�fd^d_�ZJ�fd`da�ZKdfdbdc�ZLddde�ZM�ZNS)hr�r)�SqueezerzIDLE Shell ))rZ_File)ZeditZ_Edit)raZ_Debug)ZoptionsZ_Options)ZwindowZ_Window)�helpZ_Help)ZSqueeze�<<squeeze-current-text>>rcCs|ddkS)NrrPr()Z
rmenu_itemr(r(r)r�mr�zPyShell.<lambda>)zCopy with prompts�<<copy-with-prompts>>rQFr�)�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)rPZShe_llF��ps1z>>>
rpr1�char)�wrapz<<newline-and-indent>>z<<plain-newline-and-indent>>z<<interrupt-execution>>z<<end-of-file>>z<<open-stack-viewer>>�<<toggle-debugger>>rrMz<<view-restart>>z<<restart-shell>>rL)�iomenur�r�r��backslashreplacer��2)>r+�
menu_specsrcr�r`�Tkr�withdrawr��
shell_sidebarrrAZusetabsZindentwidth�hasattrr�rR�sys_ps1r4Zprompt_last_line�promptrBZ	configurerC�enter_callback�linefeed_callback�cancel_callback�eof_callbackr?�toggle_debugger�toggle_jit_stack_viewer�copy_with_prompts_callback�view_restart_mark�
restart_shellrJ�squeezer�squeeze_current_text_eventr��save_stdoutr��save_stderrr��
save_stdinr rVr�encoding�errorsrr��pydocZ
plainpagerZpagerrrN�historyrrO�perr�Zinsertfilterr�)r>rFZmsryrBrVrpr(r(r)rA{s�
�����zPyShell.__init__cs&t���|jdur|j��dSdSr+)r��	ResetFontr\Zupdate_fontr�r�r(r)rs�s

�zPyShell.ResetFontcs�t���t��}ddd�t�|d�t�|d�t�|d�d�}|��D]\}}|jj|fi|��q#|jdur>|j�	�dSdS)N)rVrUr�r�r)r�r�r�r�)
r��ResetColorizerrrXrY�itemsrBZ
tag_configurer\Z
update_colors)r>rZZ
tag_colorsr�Ztag_colors_configr�r(r)rt�s



�
�zPyShell.ResetColorizercCstj|jdd�dS)Nr�)Zinsert_tagsrS)rrBr�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�||�}ttt|��tt|���}�fdd�|D�}d�dd�t||���D��dS)Ncsg|]	}�jj�|��qSr()r\Zline_prompts�get)r�r'r�r(r)r��s��z+PyShell.get_prompt_text.<locals>.<listcomp>rpcss.�|]\}}|dur|n|�d|��VqdS)N� r()r�r_rr(r(r)�	<genexpr>�s
��
�z*PyShell.get_prompt_text.<locals>.<genexpr>)rBrxr�rerfrJ�zip�
splitlines)r>�firstZlastrBZlineno_rangeZpromptsr(r�r)�get_prompt_text�s

�
�
��zPyShell.get_prompt_textcCs`	|j}|�d�}|durdS|�d�}|ddkr|�d�}|��|�||�}|�|�dS)Nzsel.first linestart�sel.lastr1�0zsel.last+1line linestart)rBr\Zclipboard_clearr~Zclipboard_append)r>rgrBZselfirstZsellastZprompt_textr(r(r)rf�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 idler
rS)	r�rrzrB�set_debugger_indicatorr`r��close_debugger�
open_debugger)r>rg�dbr(r(r)rds�
zPyShell.toggle_debuggercCs|j��}|�d|�dS)NrU)r`r�Zsetvar�r>r�r(r(r)r�'s
zPyShell.set_debugger_indicatorcCsdSr+r(r�r(r(r)re+r�zPyShell.toggle_jit_stack_viewercCsh|j��}|r.|j�d�|��|jjrt�|jj�|��|j�	d�|j
|_|��|�
�dS)Nz[DEBUG OFF]
)r`r�rr�r�rZclose_remote_debuggerrr�r!r^r_r�r�r�r(r(r)r�.s
zPyShell.close_debuggercCsX|jjr
t�|jj|�}nt�|�}|j�|�|��d|j|_	|�
�|��dS)Nz[DEBUG ON]
)r`r�rZstart_remote_debuggerrZDebuggerrr�r^r_r�r�)r>Zdbg_guir(r(r)r�;s
�
zPyShell.open_debuggercCs |jrdnd}|�dd|�dS)N�disabledrraz*tack*iewer)r�Zupdate_menu_state)r>�stater(r(r)�debug_menu_postcommandGszPyShell.debug_menu_postcommandcCs	|��d|_dS�NT)rr�r�r(r(r)rDKs
zPyShell.beginexecutingcCs	d|_d|_|��dSr)r�rGr�r�r(r(r)rPszPyShell.endexecutingcCsF	|jrtjddd|jd�}|durdS|��d|_d|_t�|�S)NzKill?z7Your program is still running!
 Do you want to kill it?�okrCFZcancelT)	r�rZaskokcancelrBr�rGrrr�)r>rr(r(r)r�Vs�
z
PyShell.closecCsX	|��tr|j��|jt_|jt_|j	t_
d|_d|_d|j_
d|_t�|�dSr+)r�r+r`rrkr�r�rlr�rmr�r�rFr_rqrr�r�r(r(r)r�es
zPyShell._closecCs	dSr�r(r5r(r(r)�ispythonsourceur�zPyShell.ispythonsourcecCrr+)�shell_titler�r(r(r)�short_titleyrzPyShell.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�rcrTFz�==== 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)rBr�rr+r`r�r�r�displayhookr�r!�version�platform�	COPYRIGHTZfocus_forcer��tkinterZ_support_default_rootZ
_default_root)r>ZnosubZclientr�r(r(r)r�s(
��
z
PyShell.begincCs|jsdSd|_|j��dSr�)�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)NTFrTr�r�rrp)r�r��mainloopr�rBrxr�rrGr+r
�	endoffile)r>r7rr(r(r)�readline�s(zPyShell.readlinecCsdSr�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!=rzKeyboardInterrupt
rSFT)rBr�r�r�rr`r!r�r�rGr�r�r�r�r�r�r�r(r(r)rb�s(�


zPyShell.cancel_callbackcCsh|jr|jsdS|j�ddd�r|j�ddd�sdS|js'|��|��dSd|_d|_|j�	�dS)Nr�z==rcr�FTrS)
r�r�rBr�rr�rGr�r�r�r�r(r(r)rc�s��
zPyShell.eof_callbackcCs2|jr|j�dd�|j�d�dS|�|�dS)NrcrprS)r�rBrc�see�newline_and_indent_eventr�r(r(r)ra�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�rz<=r�rSrcr��iomark linestartr�rr�z>=rz+1czinsert lineendrhr�zend-1c linestartrp)r�r�rBrxr��recallZ
tag_prevrangeZ	tag_namesZ
tag_nextranger\r��stripr�r�rcr�Zupdate_idletasksr�r��runit)	r>rg�sel�prevZ	prev_consZ	next_cons�next�indicesr�r(r(r)r`�sx�����



�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*\nrTz\n\s*$rpr�rkr�rcr�rh�:rrz	^([ \t]*))�re�subr4rBZundo_block_startrjr�rx�rstrip�endswithr�rcr��user_input_insert_tagsr��search�grouprur�Zundo_block_stop)r>r�rgr|�prefixZorig_base_indentZnew_base_indentrr(r(r)r�6s>


�
��
��zPyShell.recallz[ \t]*(\n[ \t]*)?\ZcCsj|j�d�}|j�dd�}|j�d|�}|j�|�}|s3|j�|�dkr,|j�|j|�|j	�
�dSdS)N�end-2cr�r�rTrp)rBr\rx�_last_newline_rer�r`r2rjr�r\�update_sidebar)r>Zindex_beforerZinput_is_completer(r(r)r�Ss�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)r
r)�StackBrowser)r`r�rr��last_tracebackrrzrBZidlelib.stackviewerr�ryrF)r>rgr�r(r(r)r?_s

�zPyShell.open_stack_viewercCs|j�d�|j�d�dS)Nr�r�)rBr�r�r(r(r)rgmszPyShell.view_restart_markcCs	|jjdd�dS)NTr�)r`r�r�r(r(r)rhqszPyShell.restart_shellcCs||��|j}|jr|�|j�r|dt|j��}|j�dd�|j�|�|j	�
�|j�dd�|��|j
��dS)Nr�z	iomark-1crcr�)rr_r^r�r�rBr[r�r!r\r�r��set_line_and_columnrLZ
reset_undo)r>r_r(r(r)r�us
zPyShell.showpromptcCsP|jjj}t|ddd�}d�|�|��}|�d�s|d7}|jj�	d|d�dS)N�T)r��tabsizeZexpand_tabsrpr�r�)
r`r�r�rrJrTr�rrZbottomrc)r>r7r��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�rp)	rBrxrqZstorercr�r�ZctipZremove_calltip_window)r>r'r(r(r)r�szPyShell.resetoutputr(cCsRz|j�dd�t�|||d�}|j�dd�Wn�|jr'd|_ts't�|S)Nr��rightr�F)rBr�rr!rGr+r
)r>r�r��countr(r(r)r!�sz
PyShell.writecs:z
|j�ddd�rWdSWn
tyYdSwt���S)Nr�r�r�r�)rBr�r�r�rOr�r�r(r)rO�s��
zPyShell.rmenu_check_cutcs|j�ddd�r
dSt���S)Nrcr�r�r�)rBr�r�rRr�r�r(r)rR�s
zPyShell.rmenu_check_pastecCs|j��|j��dSr+)riZsqueeze_current_textr\r�r�r(r(r)rj�s
z"PyShell.squeeze_current_text_eventcCs|j��dSr+)r\r�)r>r\rBr�r(r(r)�on_squeezed_expand�szPyShell.on_squeezed_expandr+)r()Or�r�r�Zidlelib.squeezerrJr
r�r�rr�rrYrr�r�r4�	itertools�	takewhileZ_idxrcZallow_line_numbersr�Zidlelib.historyrNZidlelib.sidebarrOrArsrtrvrwr~rfr�r�rGr�rr�r�r�rdr�rer�r�r�rDrr�r�r�r�r�r�r�r�r�rbrcrar`r�r�r�r�r�r?rgrhr�r�rr!rOrRrjr�r�r(r(r�r)r�Us�

�

�
N



�
	O






r�c
Cs8	|jdkrdD]}|�|dd|�|d��qdSdS)NZx11)ZTextZEntryZSpinboxz	<<Paste>>z%catch {%W delete sel.first sel.last}
)Z_windowingsystemZ
bind_class)ry�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
sJddl}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|�rs|j=�?d/tj	f�|�rc|j=�@|�n,|�rr|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�-rTr�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)rHrIrJ)r��size�ZextZicondirr(r)r�bs�zmain.<locals>.<listcomp>cSsg|]}tt|d��qS))Zmasterr)Z
PhotoImagery)r��iconfiler(r(r)r�ds�ZIDLESTARTUPZ
PYTHONSTARTUPzbif 1:
            import sys as _sys
            _sys.argv = %r
            del _sys
            
)H�getoptr�r�r r�r�r/r+r��argv�errorr
�	usage_msgr��exitr�r!rHrIrr�r�r�r*r�r�r,r^�dirnamerc�getcwdrr�Z
NoDefaultRootrZryr[�idlelib.runr	rJ�__file__Z
wm_iconbitmapZisAquaTk�	TkVersionZwm_iconphotorr�r�rFZsetupApprsri�newrG�dictr��lowerr_r��environrxr`r%rr(r6ZtkVersionWarningr�ZpreferTabsPreferenceWarningZinversedictr�Zdestroy)r�r�r�r�Zenable_shellZenable_editra�cmdZscriptZstartupZoptsrNr7�o�ar�Zpathxr&�dirZ
edit_startr	r�ZsizesZ	iconfilesZiconsrPZtkversionwarningZprefer_tabs_preference_warningr(r�r)r��s6���
�
���



��
�
�
���


�r�)NN)Xr�r�r�r��ImportErrorr
rrFr�ZctypesZPROCESS_SYSTEM_DPI_AWAREZOleDLLZSetProcessDpiAwarenessr"r#rr�rZryr[r�r	rzr1rr�r2rHZos.pathr
r�r�r��textwraprr�r�r)r-Zidlelib.colorizerrZidlelib.configrZidlelib.delegatorrr rrZidlelib.editorrrZidlelib.filelistrZidlelib.outwinrrrrrrZidlelib.undorr+r�r��eofr�r��	NameErrorr r*r,r/�
checkcacher9r:r�r�r�r�Z	RPCClientr�r�r�r�r�r�r�r(r(r(r)�<module>s���
��
�
�

�?
"0g6
6