B
    v9aÚá  ã            
   @   sÌ  d dl Z edkr e jd e jd< yd dlT W n* ek
rV   ede jd edƒ‚Y nX e jdkržy d dl	Z	dZ
e	 d	¡ e
¡ W n eeefk
rœ   Y nX d dlmZ ed
k rðeƒ at ¡  d dlmZ etƒ ejdde td edƒ‚d dlmZ d dlZd dlZd dlZd dlmZ d dlZd dl Z d dl!Z!d dl"m#Z# d dl$Z$d dl%Z%d dl&Z&d dl'Z'd dl(m)Z) d dl*m+Z+ d dl,m-Z- d dl,m.Z. d dl/m0Z0m1Z1 d dl2m3Z3 d dl4m5Z5 d dl,m6Z6 d dlm7Z7m8Z8m9Z9 d dl:m;Z; dZ<d Z=e ja>d8dd„Z?da@dd „ ZAeAd!ƒ dejBfd"d#„ZCeCe_BG d$d%„ d%e0ƒZDG d&d'„ d'e3ƒZEG d(d)„ d)e)ƒZFG d*d+„ d+e;ƒZGG d,d-„ d-e6jHƒZIG d.d/„ d/eƒZJG d0d1„ d1e5ƒZKd2d3„ ZLd4ZMd5d6„ ZNedkrÀeNƒ  eAd7ƒ dS )9é    NÚ__main__zidlelib.pyshell)Ú*zJ** IDLE can't import Tkinter.
Your Python may not be configured for Tk. **)Úfileé   Úwin32Zshcoreg      !@)Úfix_scalingzIdle 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.1c          	   C   sP   |dkrt }y&| t| ||||d¡ | d¡ W n ttfk
rJ   Y nX dS )a   Show 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Úlinenor   r   © r"   ú/usr/lib/python3.7/pyshell.pyÚidle_showwarningE   s    r$   c             C   s0   | rt dkr,tja tt_nt dk	r,t t_da dS )z>Replace warning.showwarning with idle_showwarning, or reverse.N)Ú_warnings_showwarningÚwarningsÚshowwarningr$   )Zcapturer"   r"   r#   Úcapture_warningsX   s    r(   Tc             C   s\   t j}i }x:t|ƒD ].}|dd… |dd…  dkr| |¡||< qW || ƒ | |¡ dS )ao  Extend 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   éÿÿÿÿz<>)Ú	linecacheÚcacheÚlistÚpopÚupdate)r    Zorig_checkcacher+   ÚsaveÚkeyr"   r"   r#   Úextended_linecache_checkcacheg   s    r1   c               @   s~   e Zd ZdZdd„ Zdddddd	gZd dd„Zdd„ Zd!dd„Zd"dd„Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )#ÚPyShellEditorWindowz6Regular text edit window in IDLE, supports breakpointsc             G   s”   g | _ tj| f|žŽ  | j d| j¡ | j d| j¡ | j d| jj¡ t	j
 tjd¡| _| jj| fdd„}| j |¡ | jjrˆ|  ¡  |  ¡  d S )Nz<<set-breakpoint-here>>z<<clear-breakpoint-here>>z<<open-python-shell>>zbreakpoints.lstc             S   s   |  ¡  | ƒ  d S )N)Úrestore_file_breaks)Zold_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Újoinr   ZuserdirÚbreakpointPathÚioZfilename_change_hookZset_filename_change_hookr    r3   Úcolor_breakpoint_text)r4   Úargsr5   r"   r"   r#   r7      s    zPyShellEditorWindow.__init__)ZCutz<<cut>>Úrmenu_check_cut)ZCopyz<<copy>>Zrmenu_check_copy)ZPastez	<<paste>>Úrmenu_check_paste)NNN)zSet Breakpointz<<set-breakpoint-here>>N)zClear Breakpointz<<clear-breakpoint-here>>NTc             C   sD   | j dkrdS |r(t ¡ }t |d¡}n
dddœ}| j d|¡ dS )z,Turn colorizing of breakpoint text on or offNÚbreakÚ )Ú
foregroundÚ
backgroundÚBREAK)rB   r   ÚCurrentThemeÚGetHighlightr8   Z
tag_config)r4   ZcolorÚthemeZcfgr"   r"   r#   rC      s    

z)PyShellEditorWindow.color_breakpoint_textc             C   sˆ   | j }| jj}| dd| d|d  ¡ y| j |¡ W n  tk
rX   | j |¡ Y nX y| jj	j
j}| ||¡ W n   Y nX d S )NrK   z%d.0r   )r8   rB   r    Útag_addr6   ÚindexÚ
ValueErrorÚappendr<   ÚpyshellÚinterpr   r:   )r4   r!   r8   r    Údebugr"   r"   r#   Úset_breakpoint©   s    z"PyShellEditorWindow.set_breakpointNc             C   s>   | j }| jj}|s| ¡  d S tt| d¡ƒƒ}|  |¡ d S )NÚinsert)r8   rB   r    ÚbellÚintÚfloatrP   rV   )r4   Úeventr8   r    r!   r"   r"   r#   r:   ·   s    z'PyShellEditorWindow.set_breakpoint_herec             C   sŠ   | j }| jj}|s| ¡  d S tt| d¡ƒƒ}y| j |¡ W n   Y nX | 	ddd¡ y| j
jjj}| ||¡ W n   Y nX d S )NrW   rK   zinsert linestartzinsert lineend +1char)r8   rB   r    rX   rY   rZ   rP   r6   ÚremoveÚ
tag_remover<   rS   rT   r   r;   )r4   r[   r8   r    r!   rU   r"   r"   r#   r;   À   s"    z)PyShellEditorWindow.clear_breakpoint_herec             C   sd   | j r`| j}| jj}|s$| ¡  d S g | _ | ddt¡ y| jjj	j
}| |¡ W n   Y nX d S )NrK   z1.0)r6   r8   rB   r    rX   r]   ZENDr<   rS   rT   r   Úclear_file_breaks)r4   r8   r    rU   r"   r"   r#   r^   Ó   s    z%PyShellEditorWindow.clear_file_breaksc          
   C   s  | j }| jj}y$t| jdƒ}| ¡ }W dQ R X W n tk
rJ   g }Y nX ynt| jdƒX}x$|D ]}| |d ¡sb| |¡ qbW |  	¡  | j }|r®| |d t
|ƒ d ¡ W dQ R X W nT tk
r } z4t| jddƒsþd| j_tjd	d
t
|ƒ | jd W dd}~X Y nX dS )z#Save breakpoints when file is savedÚrNÚwú=Ú
Úbreakpoint_error_displayedFTz
IDLE Errorz$Unable to update breakpoint list:
%s)Útitler   r   )r6   rB   r    ÚopenrA   Ú	readlinesr   Ú
startswithr   Úupdate_breakpointsÚstrÚgetattrÚrootrc   ÚtkMessageBoxÚ	showerrorr8   )r4   Zbreaksr    ÚfpÚlinesZnew_filer   Úerrr"   r"   r#   Ústore_file_breaksâ   s.    

(z%PyShellEditorWindow.store_file_breaksc          	   C   sª   | j  ¡  | jd krd S | jj}|d kr,d S tj | j¡r¦t| jdƒ}| 	¡ }W d Q R X xJ|D ]B}| 
|d ¡r`t|t|ƒd d … ƒ}x|D ]}|  |¡ qW q`W d S )Nr_   ra   r   )r8   r.   rB   r    r>   r?   ÚisfilerA   re   rf   rg   ÚevalÚlenrV   )r4   r    rn   ro   r   Zbreakpoint_linenumbersZbreakpoint_linenumberr"   r"   r#   r3     s    



z'PyShellEditorWindow.restore_file_breaksc             C   s$   | j }| d¡}|  |¡}|| _dS )z3Retrieves all the breakpoints in the current windowrK   N)r8   Z
tag_rangesÚranges_to_linenumbersr6   )r4   r8   ÚrangesZlinenumber_listr"   r"   r#   rh     s    

z&PyShellEditorWindow.update_breakpointsc             C   sj   g }x`t dt|ƒdƒD ]L}tt|| jƒƒ}tt||d  jƒƒ}x||k r`| |¡ |d7 }qDW qW |S )Nr   é   r   )Úrangert   rY   rZ   ÚstringrR   )r4   rv   ro   rP   r!   Úendr"   r"   r#   ru   $  s    

z)PyShellEditorWindow.ranges_to_linenumbersc             C   s   |   ¡  t | ¡ dS )z7Extend base method - clear breaks when module is closedN)r^   r   Ú_close)r4   r"   r"   r#   r{   5  s    zPyShellEditorWindow._close)T)N)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r7   Úrmenu_specsrC   rV   r:   r;   r^   rq   r3   rh   ru   r{   r"   r"   r"   r#   r2   ~   s$   

	
*r2   c               @   s"   e Zd ZdZeZdZddd„ZdS )ÚPyShellFileListz8Extend base class: IDLE supports a shell and breakpointsNc             C   s8   | j r| j j ¡  nt| ƒ| _ | j r2| j  ¡ s2d S | j S )N)rS   ÚtopÚwakeupÚPyShellÚbegin)r4   r[   r"   r"   r#   r=   D  s    

zPyShellFileList.open_shell)N)r|   r}   r~   r   r2   r   rS   r=   r"   r"   r"   r#   r   ;  s   r   c               @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚModifiedColorDelegatorz8Extend base class: colorizer for the shell window itselfc             C   s   t  | ¡ |  ¡  d S )N)r   r7   ÚLoadTagDefs)r4   r"   r"   r#   r7   R  s    
zModifiedColorDelegator.__init__c             C   s*   |   ddd¡ |  ddd¡ t | ¡ d S )NZTODOz1.0ÚiomarkZSYNC)r]   rO   r   Úrecolorize_main)r4   r"   r"   r#   r‰   V  s    z&ModifiedColorDelegator.recolorize_mainc          	   C   sJ   t  | ¡ t ¡ }| j d d dœt |d¡t |d¡t |d¡dœ¡ d S )N)rJ   rI   ÚstdoutÚstderrÚconsole)ÚstdinrŠ   r‹   rŒ   )r   r‡   r   rL   Útagdefsr.   rM   )r4   rN   r"   r"   r#   r‡   [  s    


z"ModifiedColorDelegator.LoadTagDefsc             C   s"   x| j D ]}|  |dd¡ qW d S )Nrˆ   rz   )rŽ   r]   )r4   Útagr"   r"   r#   Úremovecolorse  s    z#ModifiedColorDelegator.removecolorsN)r|   r}   r~   r   r7   r‰   r‡   r   r"   r"   r"   r#   r†   O  s
   
r†   c               @   s$   e Zd ZdZddd„Zddd„ZdS )	ÚModifiedUndoDelegatorz;Extend base class: forbid insert/delete before the I/O markNc             C   sL   y"| j  |dd¡r | j  ¡  d S W n tk
r6   Y nX t | |||¡ d S )Nú<rˆ   )ÚdelegateÚcomparerX   ÚTclErrorr   rW   )r4   rP   ÚcharsÚtagsr"   r"   r#   rW   m  s    
zModifiedUndoDelegator.insertc             C   sJ   y"| j  |dd¡r | j  ¡  d S W n tk
r6   Y nX t | ||¡ d S )Nr’   rˆ   )r“   r”   rX   r•   r   Údelete)r4   Zindex1Zindex2r"   r"   r#   r˜   v  s    
zModifiedUndoDelegator.delete)N)N)r|   r}   r~   r   rW   r˜   r"   r"   r"   r#   r‘   j  s   
	r‘   c               @   s   e Zd Zdd„ ZdS )ÚMyRPCClientc             C   s   t ‚dS )z0Override the base class - just re-raise EOFErrorN)ÚEOFError)r4   r"   r"   r#   Ú
handle_EOF‚  s    zMyRPCClient.handle_EOFN)r|   r}   r~   r›   r"   r"   r"   r#   r™   €  s   r™   c               @   s  e Zd Zdd„ ZdZdZdZdd„ Zdd„ Zdd	„ Z	d?dd„Z
dd„ Zdd„ Zdd„ Zdd„ Zd@dd„ZdZdd„ ZdZdd„ Zdd„ Zdd„ Zd d!„ Zd"Zd#d$„ ZdAd%d&„Zd'd(„ Zd)d*„ Zd+d,„ ZdBd-d.„Zd/d0„ Zd1d2„ Zd3d4„ Z d5d6„ Z!d7d8„ Z"d9d:„ Z#d;d<„ Z$d=d>„ Z%dS )CÚModifiedInterpreterc             C   sH   || _ tjd j}tj| |d d | _d| _d | _t	| _
| jjj| _d S )Nr   )ÚlocalsF)Ú	tkconsoleÚsysÚmodulesÚ__dict__r	   r7   Úsave_warnings_filtersÚ
restartingÚsubprocess_arglistÚPORTÚportÚcompileÚcompilerÚflagsÚoriginal_compiler_flags)r4   rž   r   r"   r"   r#   r7   ‰  s    zModifiedInterpreter.__init__Nc             C   s&   | j d kr|  ¡ | _ t | j ¡| _d S )N)r¤   Úbuild_subprocess_arglistÚ
subprocessÚPopenÚ
rpcsubproc)r4   r"   r"   r#   Úspawn_subprocess—  s    

z$ModifiedInterpreter.spawn_subprocessc             C   sJ   dd„ t jD ƒ}tjdddddd}d	|f }t jg| d
|t| jƒg S )Nc             S   s   g | ]}d | ‘qS )z-Wr"   )Ú.0Úsr"   r"   r#   ú
<listcomp>Ÿ  s    z@ModifiedInterpreter.build_subprocess_arglist.<locals>.<listcomp>ÚmainÚGeneralzdelete-exitfuncFÚbool)ÚdefaultÚtypez&__import__('idlelib.run').run.main(%r)z-c)rŸ   Úwarnoptionsr   Ú	GetOptionÚ
executableri   r¦   )r4   r`   Z	del_exitfZcommandr"   r"   r#   r«   œ  s
    


z,ModifiedInterpreter.build_subprocess_arglistc          	   C   sZ  t | jf}xLtdƒD ]4}t |¡ yt|ƒ| _P W q tk
rF   Y qX qW |  ¡  d S | jj	 
¡ d | _tdkrˆ| jj	 tjtjd¡ |  ¡  | jj	 d¡ y| j ¡  W n tjk
rÊ   |  ¡  d S X | j d| j¡ | j d| jj¡ | j d| jj¡ | j d| jj¡ | j d	| jj¡ | j d
t¡ | j d| ¡ | jdd |  ¡  | jS )Né   r   r   é
   rŒ   r   rŠ   r‹   r<   r*   rT   T)Úwith_cwd)ÚHOSTr¦   rx   ÚtimeZsleepr™   Úrpccltr   Údisplay_port_binding_errorÚlistening_sockZgetsocknamer¥   Z
setsockoptÚsocketZ
SOL_SOCKETZSO_REUSEADDRr¯   Z
settimeoutÚacceptÚtimeoutÚdisplay_no_subprocess_errorÚregisterrž   r   rŠ   r‹   r<   r*   Útransfer_pathÚpoll_subprocess)r4   ZaddrÚir"   r"   r#   Ústart_subprocess¨  s>    




z$ModifiedInterpreter.start_subprocessFrH   c             C   sT  | j r| jS d| _ |  ¡ }|r<yt | j¡ W n   Y nX | j ¡  |  ¡  | j}|j}d|_|  	¡  y| j 
¡  W n tjk
r”   |  ¡  d S X | j|d | ¡  |j dd¡ d|rÂ|nd }t|jƒt|ƒ d d	 d
 }| d ||¡¡ |j dd¡ |j dd¡ |s"| ¡  |r<t | j¡ | ¡  | j| jj_d| _ | jS )NTF)r½   rˆ   zend-1cz	RESTART: ZShellé   rw   ra   z
{0} {1} {0}ÚrestartÚleft) r£   rÀ   Úgetdebuggerr   Zclose_subprocess_debuggerÚcloseÚterminate_subprocessrž   Ú	executingr¯   rÄ   rÃ   rÅ   rÆ   rÈ   Ústop_readliner8   r˜   rY   Úwidthrt   r   ÚformatÚmark_setÚmark_gravityÚ
showpromptZrestart_subprocess_debuggerÚload_breakpointsrª   r§   r¨   r©   )r4   r½   r    rU   rŒ   Zwas_executingr   Zhalfbarr"   r"   r#   Úrestart_subprocessÓ  sH    
z&ModifiedInterpreter.restart_subprocessc             C   s   | j  dddi ¡ d S )NÚexecZinterrupt_the_serverr"   )rÀ   Z
remotecall)r4   r"   r"   r#   Z__request_interrupt   s    z'ModifiedInterpreter.__request_interruptc             C   s   t j| jd ¡  d S )N)Útarget)Ú	threadingZThreadÚ'_ModifiedInterpreter__request_interruptÚstart)r4   r"   r"   r#   Úinterrupt_subprocess  s    z(ModifiedInterpreter.interrupt_subprocessc             C   s~   | j d k	r| jj | j ¡ y| jj ¡  W n tk
r>   Y nX y| j ¡  W n tk
rb   Y nX |  ¡  d| j_	d | _d S )NF)
Ú_afteridrž   r8   Zafter_cancelrÀ   rÂ   rÐ   r   rÑ   rÒ   )r4   r"   r"   r#   Úkill_subprocess  s    
z#ModifiedInterpreter.kill_subprocessc             C   sL   y| j  ¡  W n tk
r"   dS X y| j  ¡  W n tk
rF   dS X dS )z"Make sure subprocess is terminatedN)r®   Úkillr   Úwait)r4   r"   r"   r#   rÑ     s    z(ModifiedInterpreter.terminate_subprocessc             C   s2   |rdg}|  tj¡ ntj}|  d|f ¡ d S )NrH   zRif 1:
        import sys as _sys
        _sys.path = %r
        del _sys
        
)ÚextendrŸ   r?   Ú
runcommand)r4   r½   r?   r"   r"   r#   rÈ   "  s    z!ModifiedInterpreter.transfer_pathc          
   C   s6  | j }|d krd S y|j| jdd}W n2 tttfk
rX   | jjrHd S d }|  ¡  Y nX |r| j 	¡  d | _|\}}| jj
}|dkr¢|d k	rêtt|ƒ|d nH|dkrÀ| j d¡rê|  ¡  n*|dkrêd}t||tjd t|||d y| j ¡  W n tk
r   Y nX | jjs2| jj | jj| j¡| _d S )	Ngš™™™™™©?)rä   ZOK)r   Z	EXCEPTIONz<<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   r8   ÚafterÚpollintervalrÉ   rá   )r4   ZcltÚresponseZhowZwhatrŒ   Úerrmsgr"   r"   r#   rÉ   1  s@    


z#ModifiedInterpreter.poll_subprocessc             C   s
   || _ d S )N)r   )r4   r   r"   r"   r#   ÚsetdebuggerY  s    zModifiedInterpreter.setdebuggerc             C   s   | j S )N)r   )r4   r"   r"   r#   rÏ   \  s    zModifiedInterpreter.getdebuggerc             C   s   | j j d| j¡ dS )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ž   r8   rò   rï   )r4   r"   r"   r#   Úopen_remote_stack_viewer_  s    
z,ModifiedInterpreter.open_remote_stack_viewerc             C   s°   ddl m} | j dddi ¡}|d kr6| jj ¡  d S | | j|¡}ddlm	}m
} t| jjƒ}t ¡ }t |d¡d }|||dd	}	|	jjd
dd ||	jd |ƒ}
|
 ¡  d S )Nr   )Ú
debugobj_rrÛ   Zstackviewer)r<   )ÚScrolledCanvasÚTreeNodeZnormalrJ   )ÚbgZhighlightthicknessr   Zboth)ÚexpandÚfill)Úidlelibrø   rÀ   Úremotequeuerž   rk   rX   ZStubObjectTreeItemZidlelib.treerù   rú   ZToplevelr   rL   rM   ÚframeÚpackZcanvasrü   )r4   rø   ZoidÚitemrù   rú   r‚   rN   rJ   ZscZnoder"   r"   r#   rï   l  s    z'ModifiedInterpreter.remote_stack_viewerr   c             C   s   |   |¡}|  ||¡ dS )z1Like runsource() but assumes complete exec sourceN)ÚstuffsourceÚexecfile)r4   Úsourcer    r"   r"   r#   Ú
execsource  s    
zModifiedInterpreter.execsourcec          	   C   s®   |dkrFt  |¡.}| ¡ }tr<dtj |¡› d| d }W dQ R X yt||dƒ}W nH tt	fk
rž   | j
 ¡  td| j
jd t | |¡ | j
 ¡  Y nX |  |¡ dS )zExecute an existing fileNz__file__ = r'''z'''
z
del __file__rÛ   zB*** Error in script or command!
Traceback (most recent call last):)r   )Útokenizere   ÚreadÚuse_subprocessr>   r?   Úabspathr§   ÚOverflowErrorÚSyntaxErrorrž   rë   rì   r‹   r	   ÚshowsyntaxerrorrØ   Úruncode)r4   r    r  rn   Úcoder"   r"   r#   r  „  s    &
zModifiedInterpreter.execfilec          
   C   sd   |   |¡}d| _tjdd… | _tjdtd zt | ||¡S | jdk	r^| jtjdd…< d| _X dS )zBExtend base class method: Stuff the source in the line cache firstr   NÚerror)Úactionr   )	r  Zmorer&   Úfiltersr¢   ÚfilterwarningsÚSyntaxWarningr	   Ú	runsource)r4   r  r    r"   r"   r#   r  ˜  s    

zModifiedInterpreter.runsourcec             C   s>   d| j  }| j d | _ | d¡}t|ƒd d||ftj|< |S )z"Stuff source in the filename cachez<pyshell#%d>r   rb   r   )ÚgidÚsplitrt   r*   r+   )r4   r  r    ro   r"   r"   r#   r  ±  s
    

zModifiedInterpreter.stuffsourcec             C   s   |   d|f ¡ dS )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æ   )r4   r    r"   r"   r#   Úprepend_syspath¹  s    z#ModifiedInterpreter.prepend_syspathc             C   sÄ   | j }|j}| ddd¡ t ¡ \}}}t|ddƒp:|p:d}t|ddƒpJd}t|d	dƒpZd
}	|	d
krl|d7 }|dkr‚d|	d  }
nd|d |	d f }
| ||
¡ | ¡  |  d| ¡ | 	¡  dS )z§Override Interactive Interpreter method: Use Colorizing

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

        rç   z1.0rz   ÚmsgrH   z<no detail available>r!   r   Úoffsetr   ziomark + %d charsz&iomark linestart + %d lines + %d charszSyntaxError: %s
N)
rž   r8   r]   rŸ   Úexc_inforj   Zcolorize_syntax_errorrë   r   rØ   )r4   r    rž   r8   r·   ÚvalueÚtbr  r!   r  Úposr"   r"   r#   r  Å  s"    z#ModifiedInterpreter.showsyntaxerrorc             C   s6   | j  ¡  |  ¡  t | ¡ | j  d¡r2| j  ¡  dS )z1Extend base class method to reset output properlyz<<toggle-jit-stack-viewer>>N)rž   rë   Úchecklinecacher	   Úshowtracebackrî   Úopen_stack_viewer)r4   r"   r"   r#   r   ß  s
    

z!ModifiedInterpreter.showtracebackc             C   sB   t j}x6t| ¡ ƒD ]&}|d d… |dd …  dkr||= qW d S )Nr   r)   z<>)r*   r+   r,   Úkeys)r4   Úcr0   r"   r"   r#   r  ç  s    z"ModifiedInterpreter.checklinecachec             C   s@   | j jr|  ¡  dS | jr0| j dd|fi ¡ nt|| jƒ dS )z*Run the code without invoking the debuggerr   rÛ   r  r   )rž   rÒ   Údisplay_executing_dialogrÀ   rÿ   rÛ   r   )r4   r  r"   r"   r#   ræ   í  s    zModifiedInterpreter.runcommandc             C   sp  | j jr| j ¡  |  ¡  | jdk	r:| jtjdd…< d| _| j}züyT| j  	¡  |st| j
dk	rt| j
 dd|fi ¡| _n |rˆ| || j¡ nt|| jƒ W n¢ tk
rØ   | j jsÒtjddd| j jdrÈ‚ qÔ|  ¡  n‚ Y nb   trtd| j jd	 |  ¡  | j  ¡  n,| j jr,d
| j _td| j jd	 n|  ¡  Y nX W dtsjy| j  ¡  W n tk
rh   Y nX X dS )zOverride base class methodNrÛ   r  zExit?zDo you want to exit altogether?Zyes)r¶   r   z IDLE internal error in runcode())r   Fré   )rž   rÒ   rT   rÚ   r  r¢   r&   r  r   ÚbeginexecutingrÀ   Z
asyncqueuerè   Úrunr   rÛ   Ú
SystemExitrê   rl   Zaskyesnor8   r   r	  rì   r‹   rñ   Úcanceledr   )r4   r  r   r"   r"   r#   r  ù  sP    





zModifiedInterpreter.runcodec             C   s   | j j |¡S )zOverride base class method)rž   r‹   r   )r4   r±   r"   r"   r#   r   *  s    zModifiedInterpreter.writec             C   s   t jdd| jjd d S )NzPort Binding ErroraA  IDLE 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   )rl   rm   rž   r8   )r4   r"   r"   r#   rÁ   .  s    z.ModifiedInterpreter.display_port_binding_errorc             C   s   t jdd| jjd d S )NzSubprocess 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-failure)r   )rl   rm   rž   r8   )r4   r"   r"   r#   rÆ   9  s    z/ModifiedInterpreter.display_no_subprocess_errorc             C   s   t jdd| jjd d S )NzAlready executingzYThe Python Shell window is already executing a command; please wait until it is finished.)r   )rl   rm   rž   r8   )r4   r"   r"   r#   r$  A  s    z,ModifiedInterpreter.display_executing_dialog)FrH   )F)N)N)&r|   r}   r~   r7   rá   rÀ   r®   r¯   r«   rË   rÚ   rÞ   rà   râ   rÑ   rÈ   rè   rÉ   r   rö   rÏ   r÷   rï   r  r  r  r  r  r  r  r   r  ræ   r  r   rÁ   rÆ   r$  r"   r"   r"   r#   rœ   ‡  sF   
+
-
&

1rœ   c                   s’  e Zd Zdeƒ  d ZeZeZddddddgZ	e
jd	g Zd
dlmZ dTdd„Zdd„ ZdZdZdZdZdZdZdd„ Zdd„ ZdUdd„Zdd„ ZdVdd„Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Z d(d)„ Z!d*d+„ Z"d,Z#d-d.„ Z$d/d0„ Z%d1d2„ Z&d3d4„ Z'dWd5d6„Z(d7d8„ Z)d9d:„ Z*d;d<„ Z+d=d>„ Z,d?d@„ Z-dXdAdB„Z.dYdCdD„Z/dZdEdF„Z0dGdH„ Z1dIdJ„ Z2dKdL„ Z3d[dNdO„Z4‡ fdPdQ„Z5‡ fdRdS„Z6‡  Z7S )\r„   zPython z Shell)r   Z_File)ZeditZ_Edit)rU   Z_Debug)ÚoptionsZ_Options)ZwindowZ_Window)ÚhelpZ_Help)ZSqueezez<<squeeze-current-text>>r   )ÚHistoryNc             C   s  t r&| j}|d d dkr&| dd¡ t| ƒ| _|d krVtƒ }t|ƒ | ¡  t|ƒ}t	 
| |d d ¡ d| _d| _ttdƒr‚tjnd| _| j d	¡d
 | _| j| _| j}|jdd | d| j¡ | d| j¡ | d| j¡ | d| j¡ | d| j¡ | d| j¡ | d| j¡ t r8| d| j¡ | d| j¡ |   | ¡}| d|j!¡ tj"| _#tj$| _%tj&| _'ddl(m)} t*| d|j+ƒ| _&t,| d|j+ƒ| _"t,| d|j+ƒ| _$t,| d|j+ƒ| _-t sÒ| j"t_"| j$t_$| j&t_&ydd l.}|j/|_0W n   tj1t_$‚ Y nX |  2| j¡| _3d| _4d S )Nrw   r   Úshell)r,  ZShe_llTé   Úps1z>>> rb   r)   Úchar)Úwrapz<<newline-and-indent>>z<<plain-newline-and-indent>>z<<interrupt-execution>>z<<end-of-file>>z<<open-stack-viewer>>z<<toggle-debugger>>z<<toggle-jit-stack-viewer>>z<<view-restart>>z<<restart-shell>>z<<squeeze-current-text>>)Úiomenur   rŠ   r‹   rŒ   é2   )5r	  Ú
menu_specsrW   rœ   rT   ÚTkr   Úwithdrawr   r   r7   ZusetabsZindentwidthÚhasattrrŸ   r.  Úsys_ps1r  Zprompt_last_lineÚpromptr8   Z	configurer9   Úenter_callbackÚlinefeed_callbackÚcancel_callbackÚeof_callbackr!  Útoggle_debuggerÚtoggle_jit_stack_viewerÚview_restart_markÚrestart_shellZSqueezerZsqueeze_current_text_eventrŠ   Úsave_stdoutr‹   Úsave_stderrr   Ú
save_stdinrþ   r1  r   Úencodingr   rŒ   ÚpydocZ
plainpagerZpagerrð   r+  Úhistoryró   )r4   r<   Úmsrk   r8   Zsqueezerr1  rE  r"   r"   r#   r7   c  sf    

zPyShell.__init__c             C   s   t jddS )NT)Z
shell_only)r   ZGetExtensions)r4   r"   r"   r#   Úget_standard_extension_names¢  s    z$PyShell.get_standard_extension_namesFc             C   s   |a d S )N)r   )r4   Ústreamr"   r"   r#   Úset_warning_stream¬  s    zPyShell.set_warning_streamc             C   s   t S )N)r   )r4   r"   r"   r#   Úget_warning_stream°  s    zPyShell.get_warning_streamc             C   sH   | j r$tjdd| jd |  ¡  dS | j ¡ }|r<|  ¡  n|  ¡  d S )NzDon't debug nowz*You can only toggle the debugger when idle)r   rG   )	rÒ   rl   rm   r8   Úset_debugger_indicatorrT   rÏ   Úclose_debuggerÚopen_debugger)r4   r[   Údbr"   r"   r#   r=  ³  s    


zPyShell.toggle_debuggerc             C   s   | j  ¡ }|  d|  ¡ d S )Nz<<toggle-debugger>>)rT   rÏ   Zsetvar)r4   rO  r"   r"   r#   rL  Á  s    
zPyShell.set_debugger_indicatorc             C   s   d S )Nr"   )r4   r[   r"   r"   r#   r>  Å  s    zPyShell.toggle_jit_stack_viewerc             C   sh   | j  ¡ }|r\| j  d ¡ | ¡  | j jr8t | j j¡ |  ¡  | j 	d¡ | j
| _|  ¡  |  ¡  d S )Nz[DEBUG OFF]
)rT   rÏ   rö   rÐ   rÀ   r   Zclose_remote_debuggerrë   rŒ   r   r7  r8  rØ   rL  )r4   rO  r"   r"   r#   rM  È  s    
zPyShell.close_debuggerc             C   sX   | j jrt | j j| ¡}n
t | ¡}| j  |¡ | ¡  d| j | _	|  
¡  |  ¡  d S )Nz[DEBUG ON]
)rT   rÀ   r   Zstart_remote_debuggerr   ZDebuggerrö   rÙ   r7  r8  rØ   rL  )r4   Zdbg_guir"   r"   r#   rN  Õ  s    

zPyShell.open_debuggerc             C   s   |   ¡  d| _dS )zHelper for ModifiedInterpreterr   N)rë   rÒ   )r4   r"   r"   r#   r%  á  s    zPyShell.beginexecutingc             C   s   d| _ d| _|  ¡  dS )zHelper for ModifiedInterpreterr   N)rÒ   r(  rØ   )r4   r"   r"   r#   rñ   æ  s    zPyShell.endexecutingc             C   sD   | j r&tjddd| jd}|dkr&dS |  ¡  d| _d| _t | ¡S )zExtend EditorWindow.close()zKill?z7Your program is still running!
 Do you want to kill it?Úok)r¶   r   FZcancelT)	rÒ   rl   Zaskokcancelr8   rÓ   r(  rê   r   rÐ   )r4   rô   r"   r"   r#   rÐ   ì  s    
zPyShell.closec             C   sV   |   ¡  tr| j ¡  | jt_| jt_| j	t_
d| _d| _d| j_d| _t | ¡ dS )zEExtend EditorWindow._close(), shut down debugger and execution serverN)rM  r	  rT   râ   rA  rŸ   rŠ   rB  r‹   rC  r   rŒ   r<   rS   rF  r   r{   )r4   r"   r"   r#   r{   û  s    
zPyShell._closec             C   s   dS )z8Override EditorWindow method: never remove the colorizerTr"   )r4   r    r"   r"   r#   Úispythonsource  s    zPyShell.ispythonsourcec             C   s   | j S )N)Úshell_title)r4   r"   r"   r#   Úshort_title  s    zPyShell.short_titlezHType "help", "copyright", "credits" or "license()" for more information.c             C   s†   | j  dd¡ |  ¡  tr:d}| j ¡ }|sF|  ¡  dS nd}tjt	_|  
dt	jt	j| j|f ¡ | j  ¡  |  ¡  dd l}d |_dS )	Nrˆ   rW   rH   Fz›==== No Subprocess ====

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

zPython %s on %s
%s
%sr   T)r8   rÖ   rë   r	  rT   rË   rÐ   r   ÚdisplayhookrŸ   r   ÚversionÚplatformÚ	COPYRIGHTZfocus_forcerØ   ÚtkinterZ_default_root)r4   ZnosubZclientrX  r"   r"   r#   r…     s"    

zPyShell.beginc             C   s   | j s
d S d| _| j ¡  d S )NT)ÚreadingÚ_stop_readline_flagr‚   Úquit)r4   r"   r"   r#   rÓ   -  s    zPyShell.stop_readlinec             C   s‚   | j }zd| _ | j ¡  W d || _ X | jr4d| _dS | j dd¡}t|ƒdkrRd}|  ¡  | jrnd| _t	snt
‚| jr~d| _d}|S )Nr   FrH   rˆ   zend-1cr   rb   )rY  r‚   ÚmainlooprZ  r8   Úgetrt   rë   r(  r	  ré   Ú	endoffile)r4   r/   r   r"   r"   r#   Úreadline3  s(    zPyShell.readlinec             C   s   dS )NTr"   )r4   r"   r"   r#   ÚisattyJ  s    zPyShell.isattyc             C   s    y| j  ddd¡rd S W n   Y nX | jsR| jsR|  ¡  | j d¡ |  ¡  dS d| _d| _	| jrŒ| jj
rŒ| j ¡ r‚| j ¡  n
| j ¡  | jrœ| j ¡  dS )Nz	sel.firstz!=zsel.lastzKeyboardInterrupt
rG   r   r   )r8   r”   rÒ   rY  rë   rT   r   rØ   r^  r(  rÀ   rÏ   rÚ   rà   r‚   r[  )r4   r[   r"   r"   r#   r;  M  s&    


zPyShell.cancel_callbackc             C   sf   | j r| jsd S | j ddd¡r0| j ddd¡s4d S | j sL|  ¡  |  ¡  nd| _d| _| j 	¡  dS )Nrˆ   z==rW   zend-1cr   r   rG   )
rÒ   rY  r8   r”   rë   rÐ   r(  r^  r‚   r[  )r4   r[   r"   r"   r#   r<  c  s    

zPyShell.eof_callbackc             C   s0   | j r"| j dd¡ | j d¡ n
|  |¡ dS )NrW   rb   rG   )rY  r8   rW   ÚseeÚnewline_and_indent_event)r4   r[   r"   r"   r#   r:  r  s
    
zPyShell.linefeed_callbackc             C   s8  | j r| jsd S y6| j dd¡}|rD| j ddd¡rD|  ||¡ dS W n   Y nX | j ddd¡rV| j d	d¡}|r®| j dd|d
 ¡r®|  | j |d |d
 ¡|¡ dS | j d	d¡}|rö| j dd|d ¡rö|  | j |d |d
 ¡|¡ dS | j dd¡}|r<| j |d dd¡r<|  | j |d
 d¡|¡ n|  | j dd¡|¡ dS | j ddd¡rv| j dd¡ | j dd¡}|r¢| 	¡ s¢| j 
dd¡ | j ddd¡rÂ|  |¡ dS | j dd¡ | jrô| j dd¡ | j d¡ n
|  |¡ | j d	dd¡ | j ¡  | jr,| j ¡  n|  ¡  dS )Nz	sel.firstzsel.lastz<=rˆ   rG   rW   r’   ziomark linestartr   r   r   zinsert lineendz>=rŒ   zinsert linestartzend-1czend-1c linestartrb   )rÒ   rY  r8   r]  r”   ÚrecallZtag_prevrangeZtag_nextrangerÖ   Ústripr˜   rb  rW   ra  rO   Zupdate_idletasksr‚   r[  Úrunit)r4   r[   ÚselÚprevÚnextÚindicesr±   r"   r"   r#   r9  {  sX    


zPyShell.enter_callbackc          	   C   s<  t  dd|¡}t  dd|¡}| d¡}| j ¡  zî| j ddd¡ | j dd	¡ | j d
d¡}| ¡  	d¡r„|  
|¡ | j d
d¡}| j d|d  ¡ ¡ t|ƒdkrt  d|d ¡ d¡}t  d|¡ d¡}xJ|dd … D ]:}| |¡r||t|ƒd …  }| j dd| ¡  ¡ qÞW W d | j d¡ | j ¡  X d S )Nz^\s*\nrH   z\n\s*$rb   rf  z1.0rz   rW   zend-1czinsert linestartú:r   r   z	^([ \t]*))ÚreÚsubr  r8   Zundo_block_startr]   rÖ   r]  ÚrstripÚendswithrb  rW   rd  rt   ÚsearchÚgrouprg   ra  Zundo_block_stop)r4   r±   r[   ro   ÚprefixZorig_base_indentZnew_base_indentr   r"   r"   r#   rc  º  s*    


zPyShell.recallc             C   sž   | j  dd¡}t|ƒ}x$|dkr:||d  dkr:|d }qW |dkr\||d  dkr\|d }x$|dkr€||d  dkr€|d }q^W |d |… }| j |¡ d S )Nrˆ   zend-1cr   r   z 	rb   )r8   r]  rt   rT   r  )r4   r   rÊ   r"   r"   r#   re  Ô  s    zPyShell.runitc             C   sX   | j jr| j  ¡ S y
tj W n   tjdd| jd d S ddlm	} || j
| jƒ d S )NzNo stack tracez@There is no stack trace yet.
(sys.last_traceback is not defined))r   r   )ÚStackBrowser)rT   rÀ   rï   rŸ   Úlast_tracebackrl   rm   r8   Zidlelib.stackviewerrr  rk   r<   )r4   r[   rr  r"   r"   r#   r!  â  s    


zPyShell.open_stack_viewerc             C   s   | j  d¡ | j  d¡ d S )Nrˆ   rÍ   )r8   ra  )r4   r[   r"   r"   r#   r?  ð  s    zPyShell.view_restart_markc             C   s   | j jdd dS )z&Callback for Run/Restart Shell Cntl-F6T)r½   N)rT   rÚ   )r4   r[   r"   r"   r#   r@  ô  s    zPyShell.restart_shellc             C   s:   |   ¡  | j | j¡ | j dd¡ |  ¡  | j ¡  d S )NrW   zend-1c)	rë   rŒ   r   r8  r8   rÖ   Úset_line_and_columnrB   Z
reset_undo)r4   r"   r"   r#   rØ   ø  s
    zPyShell.showpromptc             C   sP   | j jj}t|ddd}d | |¡¡}| d¡s:|d7 }| jj 	d|d¡ d S )Nr-  T)rÔ   ÚtabsizeZexpand_tabsrb   ziomark linestartr‹   )
rT   rž   rÔ   r   r@   r0  rn  ZperZbottomrW   )r4   r  rÔ   ÚwrapperZwrapped_msgr"   r"   r#   Úshow_warningÿ  s    

zPyShell.show_warningc             C   sX   | j  dd¡}| jr | j |¡ | j  d¡dkr>| j  dd¡ | j  dd¡ |  ¡  d S )Nrˆ   zend-1czend-2crb   )r8   r]  rF  ÚstorerW   rÖ   rt  )r4   r  r"   r"   r#   rë     s    zPyShell.resetoutputr"   c             C   sª   t |tƒrRt|ƒrRt|ƒdkrRxt|ƒD ]\}}|dkr(P q(W td|||d dƒ‚y0| j dd¡ t 	| ||d¡}| j dd¡ W n   ‚ Y nX | j
r¦d| _
ts¦t‚|S )	Nu   ï¿¿zUCS-2r   z%Non-BMP character not supported in Tkrˆ   ÚrightrÎ   r   )Ú
isinstanceri   rt   ÚmaxÚ	enumerateÚUnicodeEncodeErrorr8   r×   r   r   r(  r	  ré   )r4   r±   r—   rß   r/  Úcountr"   r"   r#   r     s"    zPyShell.writec                s8   y| j  ddd¡rdS W n tk
r,   dS X tƒ  ¡ S )Nz	sel.firstr’   rˆ   Údisabled)r8   r”   r•   ÚsuperrE   )r4   )Ú	__class__r"   r#   rE   (  s    zPyShell.rmenu_check_cutc                s   | j  ddd¡rdS tƒ  ¡ S )NrW   r’   rˆ   r  )r8   r”   r€  rF   )r4   )r  r"   r#   rF   0  s    zPyShell.rmenu_check_paste)N)N)N)N)N)N)N)r"   )8r|   r}   r~   r
   rR  r†   r   r‘   r   r3  r   r€   Zidlelib.historyr+  r7   rH  rY  rÒ   r(  r^  rê   rZ  rJ  rK  r=  rL  r>  rM  rN  r%  rñ   rÐ   r{   rQ  rS  rW  r…   rÓ   r_  r`  r;  r<  r:  r9  rc  re  r!  r?  r@  rØ   rw  rë   r   rE   rF   Ú__classcell__r"   r"   )r  r#   r„   I  sj   
?


	?


	
r„   c          
   C   s6   | j dkr2x&dD ]}|  |dd|  |d¡ ¡ qW dS )z6Make paste replace selection on x11.  See issue #5124.Zx11)ZTextZEntryZSpinboxz	<<Paste>>z%catch {%W delete sel.first sel.last}
N)Z_windowingsystemZ
bind_class)rk   Úclsr"   r"   r#   Úfix_x11_paste6  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           
      sd  dd l } ddlm} ddlm} ddlm} tdƒ dad}d}d}d }d }d}	y|   tj	dd … d¡\}
}W nD | j
k
r² } z$td	|tf tjd
 t d¡ W d d }~X Y nX xÜ|
D ]Ô\}}|dkrÒ|}d}|dkrâd}d}|dkrîd}|dkrtj t¡ t ¡  |dkrd}|dkr6tdtjd
 da|dkrj|}tj |¡rTntd|ƒ t ¡  d}|dkr|d}	d}|dkrº|t_d}qºW |r´|d dkr´tj ¡ }d}x0tttjƒƒD ]}tj tj| ¡tj|< qÄW |r|d dkrdg|dd …  t_	n²|r$dg| t_	nž|r8|g| t_	nŠ|r d}g }x |D ]}| tj |¡¡ qLW xX|D ],}tj |¡}|tjkrntj d|¡ qnW n"t ¡ }|tjkrÂtj d|¡ tj ddddd}|pÜ|}|pè| }trü|süt!ƒ  t"dda#t# $¡  dd l%m&} |t#ƒ tj 'tj t(¡d!¡‰|ƒ d"kr`tj 'ˆd#¡}t#j)|d$ nL| *¡ s¬t+d%krxd&nd'‰ ‡ ‡fd(d)„d*D ƒ}d+d)„ |D ƒ}t#j,d/|žŽ  t-t#ƒ t.t#ƒ t/t#ƒa0| 1t#t0¡ |r"|s"|s"x0|d d … D ] }t0 2|¡d krð| 3|¡ qðW |s"t0 4¡  |rXt0 5¡ }|s:d S | *¡ r^t0j6r^|j7 8¡  nt0j9}|rl| :¡  |	r¬tj; <d,¡pŠtj; <d-¡}|r¬tj |¡r¬|j= >|¡ |s¸|r |j= ?d.tj	f ¡ |rà|j= @|¡ n|r8|j= A|¡ |j= >|¡ n8|r8| Bt#¡}|r | C|¡ | D¡ }|r8| C|¡ xt0jErNt# F¡  q:W t# G¡  tdƒ d S )0Nr   )Úsystem)Útesting)ÚmacosxTFr   zc:deihnr:st:zError: %s
%s)r   rw   z-cz-dz-ez-hz-iz-nz: Warning: running IDLE without a subprocess is deprecated.z-rzNo script file: z-sz-tú-rH   r³   r´   zeditor-on-startuprµ   )r·   ZIdle)Z	className)r   ZIconsZWindowszidle.ico)r¶   g333333!@z.pngz.gifc                s"   g | ]}t j ˆd |ˆ f ¡‘qS )z	idle_%d%s)r>   r?   r@   )r°   Úsize)ÚextÚicondirr"   r#   r²   Û  s   zmain.<locals>.<listcomp>)é   é    é0   c             S   s   g | ]}t t|d ‘qS ))Zmasterr   )Z
PhotoImagerk   )r°   Úiconfiler"   r"   r#   r²   Ý  s   ZIDLESTARTUPZPYTHONSTARTUPzbif 1:
            import sys as _sys
            _sys.argv = %r
            del _sys
            
)T)HÚgetoptrV  r…  rþ   r†  r‡  r(   r	  rŸ   Úargvr  rì   Ú	usage_msgr‹   ÚexitrŠ   r   r>   r?   rr   r„   rR  r   r  rx   rt   r
  rR   ÚdirnamerW   Úgetcwdr   r¹   ZNoDefaultRootr4  rk   r5  Úidlelib.runr   r@   Ú__file__Zwm_iconbitmapZisAquaTkÚ	TkVersionZwm_iconphotor   r„  r   r<   ZsetupAppre   r\   Únewr=   Údictr‚   ÚlowerrS   rN  Úenvironr]  rT   r  ræ   r  r  ZtkVersionWarningrw  ZpreferTabsPreferenceWarningZinversedictr\  Zdestroy)r  r…  r†  r‡  Zenable_shellZenable_editrU   ÚcmdZscriptZstartupZoptsrD   r  ÚoÚarÊ   Zpathxr    ÚdirZ
edit_startr   r  Z	iconfilesZiconsr,  ZtkversionwarningZprefer_tabs_preference_warningr"   )rŠ  r‹  r#   r³   w  s   

















r³   F)NN)OrŸ   r|   r    rX  ÚImportErrorrì   rð   r'  rV  ZctypesZPROCESS_SYSTEM_DPI_AWAREZOleDLLZSetProcessDpiAwarenessr   r   Ztkinter.messageboxZ
messageboxrl   r˜  r4  rk   r5  r–  r   rm   r  r	   r*   r>   Zos.pathr
   rk  rÃ   r¬   Útextwrapr   rÝ   r¿   r  r&   Zidlelib.colorizerr   Zidlelib.configr   rþ   r   r   Zidlelib.editorr   r   Zidlelib.filelistr   Zidlelib.outwinr   r   r   r   r   Zidlelib.undor   r¾   r¥   r   r$   r%   r(   Ú
checkcacher1   r2   r   r†   r‘   Z	RPCClientr™   rœ   r„   r„  r’  r³   r"   r"   r"   r#   Ú<module>   sž   


 >   E   p? 1
