add-determinism 0.7.3

RPM buildroot helper to strip nondeterministic bits in files
Documentation
3

�
�^s�c@s�ddlZyddlTWn*ek
r>edejd�ed��YnXejdkr�y ddlZdZej	d�j
e�Wneeefk
r�YnXddl
jZedkr�e�atj�dd	lmZet�ejd
detd�ed��dd
lmZddlZddlZddlZddlmZddlZddlZddlZddl 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<d8dd�Z=da>dd�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�ZGGd,d-�d-e�ZHGd.d/�d/e3�ZId0d1�ZJd2ZKd3d4�ZLeMd5k�r�ejNd5ejNd6<eL�e?d7�dS)9�N)Z*zJ** IDLE can't import Tkinter.
Your Python may not be configured for Tk. **��file�Zwin32Zshcoreg!@��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�PseudoInputFile�PseudoOutputFile)�
UndoDelegatorz	127.0.0.1cCsP|dkrt}y&|jt|||||d��|jd�Wnttfk
rJYnXdS)N)�line�>>> )�warning_stream�writer�AttributeError�OSError)�message�category�filename�linenorr�r#�'/usr/lib64/python3.6/idlelib/pyshell.py�idle_showwarningCsr%cCs0|rtdkr,tjatt_ntdk	r,tt_dadS�N)�_warnings_showwarning�warningsZshowwarningr%)Zcapturer#r#r$�capture_warningsVsr)TcCs\tj}i}x:t|�D].}|dd�|dd�dkr|j|�||<qW||�|j|�dS�Nrz<>�����)�	linecache�cache�listZpop�update)r!Zorig_checkcacher-�save�keyr#r#r$�extended_linecache_checkcacheesr2c@szeZdZdd�Zd&d'd(d)d*d+gZd,dd�Zdd�Zd-dd�Zd.dd�Zdd�Z	dd�Z
dd�Zd d!�Zd"d#�Z
d$d%�ZdS)/�PyShellEditorWindowcGs�g|_tj|f|��|jjd|j�|jjd|j�|jjd|jj�t	j
jtj
d�|_|jj|fdd�}|jj|�|jjr�|j�|j�dS)N�<<set-breakpoint-here>>�<<clear-breakpoint-here>>z<<open-python-shell>>zbreakpoints.lstcSs|j�|�dSr&)�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�joinrZuserdir�breakpointPath�ioZfilename_change_hookZset_filename_change_hookr!r6�color_breakpoint_text)r7�argsr8r#r#r$r;szPyShellEditorWindow.__init__�Cut�<<cut>>�rmenu_check_cut�Copy�<<copy>>�rmenu_check_copy�Paste�	<<paste>>�rmenu_check_pasteN�Set Breakpointr4�Clear Breakpointr5TcCsD|jdkrdS|r(tj�}tj|d�}n
ddd�}|jjd|�dS)N�break�)�
foreground�
background�BREAK)rFr�CurrentTheme�GetHighlightr<Z
tag_config)r7Zcolor�themeZcfgr#r#r$rG�s

z)PyShellEditorWindow.color_breakpoint_textcCs�|j}|jj}|jdd|d|d�y|jj|�Wn tk
rX|jj|�YnXy|jj	j
j}|j||�WnYnXdS)NrXz%d.0r)
r<rFr!�tag_addr:�indexZ
ValueError�appendr@�pyshell�interprr>)r7r"r<r!�debugr#r#r$�set_breakpoint�sz"PyShellEditorWindow.set_breakpointcCs>|j}|jj}|s|j�dStt|jd���}|j|�dS)N�insert)r<rFr!�bell�int�floatr]rb)r7�eventr<r!r"r#r#r$r>�sz'PyShellEditorWindow.set_breakpoint_herecCs�|j}|jj}|s|j�dStt|jd���}y|jj|�WnYnX|j	ddd�y|j
jjj
}|j||�WnYnXdS)NrcrX�insert linestartzinsert lineend +1char)r<rFr!rdrerfr]r:�remove�
tag_remover@r_r`rr?)r7rgr<r!r"rar#r#r$r?�s"z)PyShellEditorWindow.clear_breakpoint_herec	Csd|jr`|j}|jj}|s$|j�dSg|_|jddt�y|jjj	j
}|j|�WnYnXdS)NrX�1.0)r:r<rFr!rdrjZENDr@r_r`r�clear_file_breaks)r7r<r!rar#r#r$rl�sz%PyShellEditorWindow.clear_file_breakscCs|j}|jj}y$t|jd��}|j�}WdQRXWntk
rJg}YnXynt|jd��X}x$|D]}|j|d�sb|j|�qbW|j	�|j}|r�|j|dt
|�d�WdQRXWnVtk
�r}z8t|jdd��sd|j_
tjdd	t
|�|jd
�WYdd}~XnXdS)N�r�w�=�
�breakpoint_error_displayedFTz
IDLE Errorz$Unable to update breakpoint list:
%s)Ztitlerr)r:rFr!�openrE�	readlinesr�
startswithr�update_breakpoints�str�getattr�rootrq�tkMessageBox�	showerrorr<)r7Zbreaksr!�fp�linesZnew_filerZerrr#r#r$�store_file_breaks�s.

(z%PyShellEditorWindow.store_file_breakscCs�|jj�|jdkrdS|jj}|dkr,dStjj|j�r�t|jd��}|j	�}WdQRXxJ|D]B}|j
|d�r`t|t|�dd��}x|D]}|j
|�q�Wq`WdS)Nrmror)r<r/rFr!rBrC�isfilerErrrsrtZeval�lenrb)r7r!r{r|rZbreakpoint_linenumbersZbreakpoint_linenumberr#r#r$r6
s



z'PyShellEditorWindow.restore_file_breakscCs$|j}|jd�}|j|�}||_dS)NrX)r<Z
tag_ranges�ranges_to_linenumbersr:)r7r<�rangesZlinenumber_listr#r#r$rus

z&PyShellEditorWindow.update_breakpointscCsjg}x`tdt|�d�D]L}tt||j��}tt||dj��}x||kr`|j|�|d7}qDWqW|S)Nr�r)�rangerrerfZstringr^)r7r�r|r]r"�endr#r#r$r�"s

z)PyShellEditorWindow.ranges_to_linenumberscCs|j�tj|�dSr&)rlr�_close�r7r#r#r$r�3r9zPyShellEditorWindow._close)rIrJrK)rLrMrN)rOrPrQ)NNN)rRr4N)rSr5N�Tr&r&)�__name__�
__module__�__qualname__r;�rmenu_specsrGrbr>r?rlr}r6rur�r�r#r#r#r$r3|s"

	
*r3c@seZdZeZdZddd�ZdS)�PyShellFileListNcCs8|jr|jjj�nt|�|_|jr2|jj�s2dS|jSr&)r_�topZwakeup�PyShell�begin�r7rgr#r#r$rABs

zPyShellFileList.open_shellr&)r�r�r�r3rr_rAr#r#r#r$r�9sr�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ModifiedColorDelegatorcCstj|�|j�dSr&)rr;�LoadTagDefsr�r#r#r$r;P�
zModifiedColorDelegator.__init__cCs*|jddd�|jddd�tj|�dS)NZTODOrk�iomarkZSYNC)rjr\r�recolorize_mainr�r#r#r$r�Tsz&ModifiedColorDelegator.recolorize_maincCsJtj|�tj�}|jjddd�tj|d�tj|d�tj|d�d��dS)N)rWrV�stdout�stderr�console)�stdinr�r�r�)rr�rrY�tagdefsr/rZ)r7r[r#r#r$r�Ys


z"ModifiedColorDelegator.LoadTagDefscCs"x|jD]}|j|dd�qWdS)Nr�r�)r�rj)r7�tagr#r#r$�removecolorscsz#ModifiedColorDelegator.removecolorsN)r�r�r�r;r�r�r�r#r#r#r$r�Ms
r�c@s eZdZddd�Zddd�ZdS)�ModifiedUndoDelegatorNc
CsLy"|jj|dd�r |jj�dSWntk
r6YnXtj||||�dS�N�<r�)�delegate�comparerd�TclErrorrrc)r7r]Zchars�tagsr#r#r$rck�
zModifiedUndoDelegator.insertcCsJy"|jj|dd�r |jj�dSWntk
r6YnXtj|||�dSr�)r�r�rdr�r�delete)r7Zindex1Zindex2r#r#r$r�tr�zModifiedUndoDelegator.deleter&r&)r�r�r�rcr�r#r#r#r$r�hs
	r�c@seZdZdd�ZdS)�MyRPCClientcCst�dSr&)�EOFErrorr�r#r#r$�
handle_EOF��zMyRPCClient.handle_EOFN)r�r�r�r�r#r#r#r$r�~sr�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�ModifiedInterpretercCsH||_tjdj}tj||d�d|_d|_d|_t	|_
|jjj
|_dS)N�__main__)�localsF)�	tkconsole�sys�modulesZ__dict__rr;�save_warnings_filters�
restarting�subprocess_arglist�PORT�port�compile�compiler�flags�original_compiler_flags)r7r�r�r#r#r$r;�szModifiedInterpreter.__init__NcCs&|jdkr|j�|_tj|j�|_dSr&)r��build_subprocess_arglist�
subprocessZPopen�
rpcsubprocr�r#r#r$�spawn_subprocess�s

z$ModifiedInterpreter.spawn_subprocesscCs^dd�tjD�}tjdddddd�}td	kr8d
|f}n
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�typezidlelib.pyshellz&__import__('idlelib.run').run.main(%r)z__import__('run').main(%r)�-c)r�Zwarnoptionsr�	GetOptionr�Z
executablervr�)r7rnZ	del_exitfZcommandr#r#r$r��s


z,ModifiedInterpreter.build_subprocess_arglistcCsZt|jf}xLtd�D]4}tj|�yt|�|_PWqtk
rFYqXqW|j�dS|jj	j
�d|_tdkr�|jj	jt
jt
jd�|j�|jj	jd�y|jj�Wnt
jk
r�|j�dSX|jjd|j�|jjd|jj�|jjd|jj�|jjd|jj�|jjd	|jj�|jjd
t�|jjd|�|jdd
�|j�|jS)Nirri
r�r�r�r�r@r,r`T��with_cwd)�HOSTr�r��timeZsleepr��rpccltr�display_port_binding_error�listening_sockZgetsocknamer�Z
setsockopt�socketZ
SOL_SOCKETZSO_REUSEADDRr�Z
settimeout�accept�timeout�display_no_subprocess_errorZregisterr�r�r�r�r@r,�
transfer_path�poll_subprocess)r7Zaddr�ir#r#r$�start_subprocess�s>




z$ModifiedInterpreter.start_subprocessFrUcCsT|jr|jSd|_|j�}|r<ytj|j�WnYnX|jj�|j�|j}|j}d|_|j	�y|jj
�Wntjk
r�|j
�dSX|j|d�|j�|jjdd�d|r�|nd}t|j�t|�dd	d
}|jdj||��|jjdd�|jjdd
�|�s"|j�|�r<tj|j�|j�|j|jj_d|_|jS)NTFr�r��end-1cz	RESTART: ZShellir�roz
{0} {1} {0}�restart�left) r�r��getdebuggerrZclose_subprocess_debugger�close�terminate_subprocessr��	executingr�r�r�r�r�r��
stop_readliner<r�re�widthrrZformat�mark_set�mark_gravity�
showpromptZrestart_subprocess_debugger�load_breakpointsr�r�r�r�)r7r�r!rar�Z
was_executingr�Zhalfbarr#r#r$�restart_subprocess�sH
z&ModifiedInterpreter.restart_subprocesscCs|jjddfi�dS)N�execZinterrupt_the_server)r�Z
remotecallr�r#r#r$Z__request_interrupt�z'ModifiedInterpreter.__request_interruptcCstj|jd�j�dS)N)Ztarget)�	threadingZThread�'_ModifiedInterpreter__request_interrupt�startr�r#r#r$�interrupt_subprocessr�z(ModifiedInterpreter.interrupt_subprocesscCs~|jdk	r|jjj|j�y|jjj�Wntk
r>YnXy|jj�Wntk
rbYnX|j�d|j_	d|_dS)NF)
�_afteridr�r<Zafter_cancelr�r�r�rr�r�r�r#r#r$�kill_subprocesss
z#ModifiedInterpreter.kill_subprocesscCsLy|jj�Wntk
r"dSXy|jj�Wntk
rFdSXdSr&)r�Zkillr�waitr�r#r#r$r�sz(ModifiedInterpreter.terminate_subprocesscCs2|rdg}|jtj�ntj}|jd|f�dS)NrUzRif 1:
        import sys as _sys
        _sys.path = %r
        del _sys
        
)Zextendr�rC�
runcommand)r7r�rCr#r#r$r�#sz!ModifiedInterpreter.transfer_pathcCs6|j}|dkrdSy|j|jdd�}Wn2tttfk
rX|jjrHdSd}|j�YnX|�r|jj	�d|_|\}}|jj
}|dkr�|dk	r�tt|�|d�nH|dkr�|jj
d�r�|j�n*|dkr�d}t||tjd�t|||d�y|jj�Wntk
�rYnX|jj�s2|jjj|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��printZrepr�getvar�remote_stack_viewerr��
__stderr__�endexecutingrr<�after�pollintervalr�r�)r7Zclt�responseZhowZwhatr�Zerrmsgr#r#r$r�2s@


z#ModifiedInterpreter.poll_subprocesscCs
||_dSr&r
)r7rr#r#r$�setdebuggerZr�zModifiedInterpreter.setdebuggercC�|jSr&r
r�r#r#r$r�]r�zModifiedInterpreter.getdebuggercCs|jjjd|j�dS)Ni,)r�r<r�r�r�r#r#r$�open_remote_stack_viewer`s
z,ModifiedInterpreter.open_remote_stack_viewercCs�ddlm}|jjddd
i�}|dkr6|jjj�dS|j|j|�}ddlm	}m
}t|jj�}tj
�}tj|d�d}|||dd	�}	|	jjd
dd�||	jd|�}
|
j�dS)Nr)�
debugobj_rr�Zstackviewerr@)�ScrolledCanvas�TreeNodeZnormalrW)ZbgZhighlightthicknessrZboth)�expandZfill)r@)�idlelibr�r��remotequeuer�rxrdZStubObjectTreeItemZidlelib.treerrZToplevelrrYrZZframeZpackZcanvasr)r7r�ZoidZitemrrr�r[rWZscZnoder#r#r$r�msz'ModifiedInterpreter.remote_stack_viewerrcCs|j|�}|j||�dSr&)�stuffsource�execfile�r7�sourcer!r#r#r$�
execsource�s
zModifiedInterpreter.execsourcecCs�|dkrFtj|��.}|j�}tr<dtjj|��d�|d}WdQRXyt||d�}WnHtt	fk
r�|j
j�td|j
j
d�tj||�|j
j�YnX|j|�dS)Nz__file__ = r'''z'''
z
del __file__r�zB*** Error in script or command!
Traceback (most recent call last):r)�tokenizerr�read�use_subprocessrBrC�abspathr�Z
OverflowErrorZSyntaxErrorr�r�r�r�r�showsyntaxerrorr��runcode)r7r!rr{�coder#r#r$r�s&
zModifiedInterpreter.execfilec
Csd|j|�}d|_tjdd�|_tjdtd�ztj|||�S|jdk	r^|jtjdd�<d|_XdS)Nr�error)Zactionr )	rZmorer(�filtersr�ZfilterwarningsZ
SyntaxWarningr�	runsourcerr#r#r$r�s

zModifiedInterpreter.runsourcecCs>d|j}|jd|_|jd�}t|�dd||ftj|<|S)Nz<pyshell#%d>rrpr)�gid�splitrr,r-)r7rr!r|r#r#r$r�s


zModifiedInterpreter.stuffsourcecCs|jd|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��r7r!r#r#r$�prepend_syspath�sz#ModifiedInterpreter.prepend_syspathcCs�|j}|j}|jddd�tj�\}}}t|dd�p:|p:d}t|dd�pJd}t|d	d�pZd
}	|	d
krl|d7}|dkr�d|	d}
nd|d|	df}
|j||
�|j�|jd
|�|j	�dS)Nr�rkr��msgrUz<no detail available>r"r�offsetrziomark + %d charsz&iomark linestart + %d lines + %d charszSyntaxError: %s
)
r�r<rjr�Zexc_inforwZcolorize_syntax_errorr�rr�)r7r!r�r<r�ZvalueZtbrr"rZposr#r#r$r�s"z#ModifiedInterpreter.showsyntaxerrorcCs6|jj�|j�tj|�|jjd�r2|jj�dS)Nr�)r�r��checklinecacher�
showtracebackr��open_stack_viewerr�r#r#r$r�s


z!ModifiedInterpreter.showtracebackcCsBtj}x6t|j��D]&}|dd�|dd�dkr||=qWdSr*)r,r-r.Zkeys)r7Zcr1r#r#r$r�sz"ModifiedInterpreter.checklinecachecCs@|jjr|j�dS|jr0|jjdd|fi�nt||j�dS)Nrr�rr)r�r��display_executing_dialogr�rr�r�)r7rr#r#r$r��szModifiedInterpreter.runcommandcCst|jjr|jj�|j�|jdk	r:|jtjdd�<d|_|j}�z�yV|jj	�|rx|j
dk	rx|j
jdd|fi�|_n |r�|j
||j�nt||j�Wn�tk
r�|jjs�tjddd|jjd�r̂q�|j�n�Ynbt�rtd|jjd�|j�|jj�n,|jj�r0d	|j_td
|jjd�n|j�YnXWdt�sny|jj�Wntk
�rlYnXXdS)Nr�rzExit?zDo you want to exit altogether?Zyes�r�rz IDLE internal error in runcode()rFr�)r�r�r`r�rr�r(rr�beginexecutingr�Z
asyncqueuer�Zrunr�r��
SystemExitr�ryZaskyesnor<rrr�r�r��canceledr)r7rrr#r#r$r�sP





zModifiedInterpreter.runcodecCs|jjj|�Sr&)r�r�r)r7r�r#r#r$r+r�zModifiedInterpreter.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�ryrzr�r<r�r#r#r$r�/sz.ModifiedInterpreter.display_port_binding_errorcCr")NzSubprocess Startup Errorz�IDLE's subprocess didn't make connection.  Either IDLE can't start a subprocess or personal firewall software is blocking the connection.rr#r�r#r#r$r�:sz/ModifiedInterpreter.display_no_subprocess_errorcCr")NzAlready executingzYThe Python Shell window is already executing a command; please wait until it is finished.rr#r�r#r#r$rBsz,ModifiedInterpreter.display_executing_dialog)FrU)Fr&r&)&r�r�r�r;r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�r�r�rr	rrrrrrrr�rrr�r�rr#r#r#r$r��sF
+
-

&


1r�cs�eZdZde�dZeZeZdZd[d\d]d^d_gZ	e
jd`gZddlm
Z
dadd�Zdd�ZdZdZdZdZdZdZdd�Zdd�Zdbdd�Zdd �Zdcd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Z d/d0�Z!d1d2�Z"d3Z#d4d5�Z$d6d7�Z%d8d9�Z&d:d;�Z'ddd<d=�Z(d>d?�Z)d@dA�Z*dBdC�Z+dDdE�Z,dFdG�Z-dedHdI�Z.dfdJdK�Z/dgdLdM�Z0dNdO�Z1dPdQ�Z2dRdS�Z3ffdTdU�Z4�fdVdW�Z5�fdXdY�Z6�Z7S)hr�zPython z Shellr�_File�edit�_Editra�_Debug�options�_Options�window�_Window�help�_Help�Squeeze�<<squeeze-current-text>>r)�HistoryNc	Cs�tr&|j}|dddkr&|jdd�t|�|_|dkrVt�}t|�|j�t|�}t	j
||dd�d|_d|_t
td�r�tjnd|_|jjd	�d|_|j|_|j}|jdd�|jd
|j�|jd|j�|jd|j�|jd|j�|jd|j�|jd|j�|jd|j�t�r8|jd|j�|jd|j�tj |_!tj"|_#tj$|_%ddl&m'}t(|d|j)�|_$t*|d|j)�|_ t*|d|j)�|_"t*|d|j)�|_+t�s�|j t_ |j"t_"|j$t_$yddl,}|j-|_.Wntj/t_"�YnX|j0|j�|_1d|_2dS)Nr�r�shell�She_llT��ps1rrpr�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>>)�iomenur�r�r�r�i2)r1r2r+)3r�
menu_specsrcr�r`�Tkr�withdrawr�rr;ZusetabsZindentwidthZhasattrr�r4�sys_ps1rZprompt_last_line�promptr<Z	configurer=�enter_callback�linefeed_callback�cancel_callback�eof_callbackr�toggle_debugger�toggle_jit_stack_viewer�view_restart_mark�
restart_shellr��save_stdoutr��save_stderrr��
save_stdinrr8rZencodingrr��pydocZ
plainpagerZpagerr�r0�historyr�)r7r@Zmsrxr<r8rIr#r#r$r;ds`
zPyShell.__init__cCstjdd�S)NT)Z
shell_only)rZ
GetExtensionsr�r#r#r$�get_standard_extension_names�r�z$PyShell.get_standard_extension_namesFcCs|adSr&�r)r7Zstreamr#r#r$�set_warning_stream�r�zPyShell.set_warning_streamcCstSr&rLr�r#r#r$�get_warning_stream�r�zPyShell.get_warning_streamcCsH|jr$tjdd|jd�|j�dS|jj�}|r<|j�n|j�dS)NzDon't debug nowz*You can only toggle the debugger when idlerrT)	r�ryrzr<�set_debugger_indicatorr`r��close_debugger�
open_debugger)r7rg�dbr#r#r$rB�s


zPyShell.toggle_debuggercCs|jj�}|jd|�dS)Nr7)r`r�Zsetvar�r7rRr#r#r$rO�r�zPyShell.set_debugger_indicatorcCsdSr&r#r�r#r#r$rC�r�zPyShell.toggle_jit_stack_viewercCsh|jj�}|r\|jjd�|j�|jjr8tj|jj�|j�|jj	d�|j
|_|j�|j
�dS)Nz[DEBUG OFF]
)r`r�r�r�r�rZclose_remote_debuggerr�r�rr<r=r�rOrSr#r#r$rP�s
zPyShell.close_debuggercCsX|jjrtj|jj|�}n
tj|�}|jj|�|j�d|j|_	|j
�|j�dS)Nz[DEBUG ON]
)r`r�rZstart_remote_debuggerrZDebuggerr�r�r<r=r�rO)r7Zdbg_guir#r#r$rQ�s

zPyShell.open_debuggercCs|j�d|_dS)Nr)r�r�r�r#r#r$r�r9zPyShell.beginexecutingcCsd|_d|_|j�dS)Nr)r�r!r�r�r#r#r$r��szPyShell.endexecutingcCsD|jr&tjddd|jd�}|dkr&dS|j�d|_d|_tj|�S)NzKill?z7Your program is still running!
 Do you want to kill it?ZokrFZcancelT)	r�ryZaskokcancelr<r�r!r�rr�)r7r�r#r#r$r��s
z
PyShell.closecCsV|j�tr|jj�|jt_|jt_|j	t_
d|_d|_d|j_
d|_tj|�dSr&)rPrr`r�rFr�r�rGr�rHr�r�r@r_rJrr�r�r#r#r$r��s
zPyShell._closecC�dS�NTr#rr#r#r$�ispythonsource	r�zPyShell.ispythonsourcecCr�r&)�shell_titler�r#r#r$�short_title
r�zPyShell.short_titlezHType "help", "copyright", "credits" or "license()" for more information.cCs�|jjdd�|j�tr:d}|jj�}|sF|j�dSnd}tjt	_|j
d	t	jt	j|j
|f�|jj�|j�d
dl}d|_dS)Nr�rcrUFz==== No Subprocess ====

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

zPython %s on %s
%s
%srTzR==== No Subprocess ====

WARNING: Running IDLE without a Subprocess is deprecated
z�==== No Subprocess ====

WARNING: Running IDLE without a Subprocess is deprecated
and will be removed in a later version. See Help/IDLE Help
z�==== No Subprocess ====

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

)r<r�r�rr`r�r�rZdisplayhookr�rZversion�platform�	COPYRIGHTZfocus_forcer��tkinterZ
_default_root)r7ZnosubZclientr[r#r#r$r�s$

z
PyShell.begincCs|js
dSd|_|jj�dSrU)�reading�_stop_readline_flagr��quitr�r#r#r$r�+szPyShell.stop_readlinecCs�|j}zd|_|jj�Wd||_X|jr4d|_dS|jjdd�}t|�dkrRd}|j�|jrnd|_t	snt
�|jr~d|_d}|S)NrFrUr�r�rrp)r\r��mainloopr]r<�getrr�r!rr��	endoffile)r7r0rr#r#r$�readline1s(zPyShell.readlinecCrTrUr#r�r#r#r$�isattyHr�zPyShell.isattyc
Cs�y|jjddd�rdSWnYnX|jp0|jsR|j�|jjd�|j�dSd|_d|_	|jr�|jj
r�|jj�r�|jj�n
|jj
�|jr�|jj�dS)N�	sel.firstz!=�sel.lastzKeyboardInterrupt
rTrr)r<r�r�r\r�r`rr�rar!r�r�r�r�r�r^r�r#r#r$r@Ks&


zPyShell.cancel_callbackcCsh|jr|jrdS|jjddd�o0|jjddd�s6dS|jsN|j�|j�nd|_d|_|jj	�dS)Nr�z==rcr�rrrT)
r�r\r<r�r�r�r!rar�r^r�r#r#r$rAas

zPyShell.eof_callbackcCs0|jr"|jjdd�|jjd�n
|j|�dS)NrcrprT)r\r<rc�see�newline_and_indent_eventr�r#r#r$r?ps

zPyShell.linefeed_callbackcCs<|jr|jrdSy6|jjdd�}|rF|jjddd�rF|j||�dSWnYnX|jjddd��rX|jjd	d�}|r�|jjdd|d
�r�|j|jj|d|d
�|�dS|jjd	d�}|r�|jjdd
|d�r�|j|jj|d|d
�|�dS|jjdd�}|�r>|jj|ddd��r>|j|jj|d
d�|�n|j|jjdd�|�dS|jjddd��rx|jjdd�|jjdd�}|�r�|j	��r�|jj
dd�|jjddd��r�|j|�dS|jjdd�|j�r�|jjdd�|jj
d�n
|j|�|jjd	dd�|jj�|j�r0|jj�n|j�dS)Nrdrez<=r�rTrcr��iomark linestartr�rrzinsert lineendz>=r�rhr�zend-1c linestartrp)r�r\r<r`r��recallZ
tag_prevrangeZ
tag_nextranger��stripr�rgrcrfr\Zupdate_idletasksr�r^�runit)r7rg�selZprevZnextZindicesr�r#r#r$r>ysX


zPyShell.enter_callbackcCs<tjdd|�}tjdd|�}|jd�}|jj�z�|jjddd�|jjdd	�|jjd
d�}|j�j	d�r�|j
|�|jjd
d�}|jjd|dj��t
|�d
k�rtjd|d�jd�}tjd|�jd�}xJ|d
d�D]:}|j|��r||t
|�d�}|jjdd|j��q�WWd|jjd�|jj�XdS)Nz^\s*\nrUz\n\s*$rprlrkr�rcr�rhz:rrz	^([ \t]*))�reZsubrr<Zundo_block_startrjr�r`Zrstrip�endswithrgrcrjrZsearchZgrouprtrfZundo_block_stop)r7r�rgr|ZprefixZorig_base_indentZnew_base_indentrr#r#r$ri�s*


zPyShell.recallcCs�|jjdd�}t|�}x$|dkr:||ddkr:|d}qW|dkr\||ddkr\|d}x$|dkr�||ddkr�|d}q^W|d|�}|jj|�dS)Nr�r�rrz 	rp)r<r`rr`r)r7rr�r#r#r$rk�sz
PyShell.runitcCsX|jjr|jj�Sy
tjWntjdd|jd�dSddlm	}||j
|j�dS)NzNo stack tracez@There is no stack trace yet.
(sys.last_traceback is not defined)rr)�StackBrowser)r`r�r�r�Zlast_tracebackryrzr<Zidlelib.stackviewerrorxr@)r7rgror#r#r$r�s


zPyShell.open_stack_viewercCs|jjd�|jjd�dS)Nr�r�)r<rfr�r#r#r$rD�szPyShell.view_restart_markcCs|jjdd�dS)NTr�)r`r�r�r#r#r$rE�r�zPyShell.restart_shellcCs:|j�|jj|j�|jjdd�|j�|jj�dS)Nrcr�)	r�r�rr=r<r��set_line_and_columnrFZ
reset_undor�r#r#r$r��s
zPyShell.showpromptcCsP|jjj}t|ddd�}dj|j|��}|jd�s:|d7}|jjj	d|d�dS)Nr3T)r�ZtabsizeZexpand_tabsrprhr�)
r`r�r�r
rDr6rnZperZbottomrc)r7rr�ZwrapperZwrapped_msgr#r#r$�show_warning�s

zPyShell.show_warningcCsX|jjdd�}|jr |jj|�|jjd�dkr>|jjdd�|jjdd�|j�dS)Nr�r�zend-2crp)r<r`rJZstorercr�rp)r7rr#r#r$r�szPyShell.resetoutputcCs�t|t�rRt|�rRt|�dkrRxt|�D]\}}|dkr(Pq(Wtd|||dd��y0|jjdd�tj	|||d�}|jjdd�Wn�YnX|j
r�d|_
ts�t�|S)	Nu￿zUCS-2rz%Non-BMP character not supported in Tkr�Zrightr�r)
Z
isinstancervrZmaxZ	enumerateZUnicodeEncodeErrorr<r�rrr!rr�)r7r�r�r�r5Zcountr#r#r$rs"z
PyShell.writecs8y|jjddd�rdSWntk
r,dSXt�j�S)Nrdr�r��disabled)r<r�r��superrKr��Z	__class__r#r$rK&szPyShell.rmenu_check_cutcs|jjddd�rdSt�j�S)Nrcr�r�rr)r<r�rsrQr�rtr#r$rQ.szPyShell.rmenu_check_paste)rr$)r%r&)rar')r(r))r*r+)r,r-)r.r/r&r&r&r&r&r&r&)8r�r�r�r	rWr�rr�rr9rr�Zidlelib.historyr0r;rKr\r�r!rar�r]rMrNrBrOrCrPrQrr�r�r�rVrXrZr�r�rbrcr@rAr?r>rirkrrDrEr�rqr�rrKrQZ
__classcell__r#r#rtr$r�Jsj
<



	?


	r�cCs6|jdkr2x&dD]}|j|dd|j|d��qWdS)NZx11�Text�Entry�Spinboxz	<<Paste>>z%catch {%W delete sel.first sel.last}
)rurvrw)Z_windowingsystemZ
bind_class)rxZclsr#r#r$�
fix_x11_paste4s

rxa�
USAGE: idle  [-deins] [-t title] [file]*
       idle  [-dns] [-t title] (-c cmd | -r file) [arg]*
       idle  [-dns] [-t title] - [arg]*

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

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

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

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

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

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

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

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

Examples:

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

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

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

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

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

echo "import sys; print(sys.argv)" | idle - "foobar"
        Open a shell window, run the script piped in, passing '' in sys.argv[0]
        and "foobar" in sys.argv[1].
cs\ddl}ddlm}ddlm}ddlm}td�dad}d}d}d}d}d}	y|jtj	dd�d�\}
}WnD|j
k
r�}z&td	|tftj
d
�tjd�WYdd}~XnXx�|
D]�\}
}|
dkr�|}d}|
d
kr�d}d}|
dkr�d}|
dk�rtjjt�tj�|
dk�rd}|
dk�r6tdtj
d
�da|
dk�rj|}tjj|��rTntd|�tj�d}|
dk�r|d}	d}|
dkr�|t_d}q�W|�r�|ddk�r�tjj�}d}x0tttj��D]}tjjtj|�tj|<�q�W|�r|ddk�rdg|dd�t_	n�|�r$dg|t_	n�|�r8|g|t_	n�|�r�d}g}x |D]}|jtjj|���qLWxX|D],}tjj|�}|tjk�rntjjd|��qnWn"tj�}|tjk�r�tjjd|�tj ddddd�}|�p�|}|�p�|}t�r�|�r�t!�t"dd�a#t#j$�dd l%m&}|t#�tjj'tjjt(�d!��|�d"k�rbtjj'�d#�}t#j)|d$�nBt*d%k�rpd&nd'���fd(d)�d1D�}d-d)�|D�}t#j+d2|��t,t#�t-t#�t.t#�a/|j0t#t/�|�r|�p�|�sx0|dd�D] }t/j1|�dk�r�|j2|��q�W|�st/j3�|�rPt/j4�}|�s2dS|j5��rVt/j6�rV|j7j8�nt/j9}|�rd|j:�|	�r�tj;j<d.��p�tj;j<d/�}|�r�tjj|��r�|j=j>|�|�s�|�r�|j=j?d0tj	f�|�r�|j=j@|�n|�r0|j=jA|�|j=j>|�n8|�r0|jBt#�}|�r|jC|�|jD�}|�r0|jC|�xt/jE�rFt#jF��q2Wt#jG�td�dS)3Nr)�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-tz-rUr�r�zeditor-on-startupr�)r�ZIdle)Z	classNamerZIconsZWindowszidle.ico)r�g333333!@z.pngz.gifcs"g|]}tjj�d|�f��qS)z	idle_%d%s)rBrCrD)r�Zsize�ZextZicondirr#r$r���zmain.<locals>.<listcomp>�� �0cSsg|]}tt|d��qS))Zmasterr)Z
PhotoImagerx)r��iconfiler#r#r$r��r}ZIDLESTARTUPZ
PYTHONSTARTUPzbif 1:
            import sys as _sys
            _sys.argv = %r
            del _sys
            
)r~rr�r�)H�getoptrYryrrzr{r)rr�Zargvrr��	usage_msgr�Zexitr�rrBrCr~r�rWr�rr�rr
r^ZdirnamercZgetcwdrr�Z
NoDefaultRootr:rxr;�idlelib.runrrDZ__file__Z
wm_iconbitmap�	TkVersionZwm_iconphotorrxr�r@ZsetupApprrriZnewrAZisAquaTkZdictr�Zlowerr_rQZenvironr`r`rr�r	rZtkVersionWarningrqZpreferTabsPreferenceWarningZinversedictr_Zdestroy)r�ryrzr{Zenable_shellZenable_editraZcmdZscriptZstartupZoptsrHrZoZar�Zpathxr!ZdirZ
edit_startrr�Z	iconfilesZiconsr1ZtkversionwarningZprefer_tabs_preference_warningr#r|r$r�us
















r�r�r_F)NN)Or�r[ZImportErrorr�r�r rYZctypesZPROCESS_SYSTEM_DPI_AWAREZOleDLLZSetProcessDpiAwarenessrrZtkinter.messageboxZ
messageboxryr�r:rxr;r�rrzrrr,rBZos.pathr	rmr�r�Ztextwrapr
r�r�r
r(Zidlelib.colorizerrZidlelib.configrrrrZidlelib.editorrrZidlelib.filelistrZidlelib.outwinrrrrrZidlelib.undorr�r�rr%r'r)Z
checkcacher2r3r�r�r�Z	RPCClientr�r�r�rxr�r�r�r�r#r#r#r$Z<module>s�




>Hm?1