<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
 f                 @   s  d dl Z yd dlT W n* ek
r>   ede jd edY nX e jdkry d dlZdZej	dj
e W n eeefk
r   Y nX d dljZedk re atj  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-m.Z.m/Z/ d dl0m1Z1 d dl2m3Z3 d dl*m4Z4 d dlm5Z5m6Z6m7Z7 d dl8m9Z9 dZ:d Z;e ja<d8ddZ=da>dd Z?e?d dej@fd d!ZAeAe_@G d"d# d#e.ZBG d$d% d%e1ZCG d&d' d'e'ZDG d(d) d)e9ZEG d*d+ d+e4jFZGG d,d- d-eZHG d.d/ d/e3ZId0d1 ZJd2ZKd3d4 ZLeMd5kre jNd5 e jNd6< eL  e?d7 dS )9    N)*zJ** IDLE can't import Tkinter.
Your Python may not be configured for Tk. **)file   Z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&|jt| ||||d |j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    4/opt/alt/python36/lib64/python3.6/idlelib/pyshell.pyidle_showwarningC   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_warningsV   s    r&   Tc             C   s\   t j}i }x:t|D ].}|dd |dd  dkr|j|||< qW ||  |j| 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_checkcachee   s    r/   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 )0PyShellEditorWindowz6Regular text edit window in IDLE, supports breakpointsc             G   s   g | _ tj| f|  | jjd| j | jjd| j | jjd| jj t	j
jtjd| _| jj| fdd}| jj| | jjr| j  | j  d S )Nz<<set-breakpoint-here>>z<<clear-breakpoint-here>>z<<open-python-shell>>zbreakpoints.lstc             S   s   |j   |   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   r1   color_breakpoint_text)r2   argsr3   r    r    r!   r5      s    zPyShellEditorWindow.__init__Cut<<cut>>rmenu_check_cutCopy<<copy>>rmenu_check_copyPaste	<<paste>>rmenu_check_pasteNSet Breakpoint<<set-breakpoint-here>>Clear Breakpoint<<clear-breakpoint-here>>Tc             C   sD   | j dkrdS |r(tj }tj|d}n
ddd}| jjd| dS )z,Turn colorizing of breakpoint text on or offNbreak )
foreground
backgroundBREAK)r@   r   CurrentThemeGetHighlightr6   Z
tag_config)r2   ZcolorthemeZcfgr    r    r!   rA      s    

z)PyShellEditorWindow.color_breakpoint_textc             C   s   | j }| jj}|jdd| d|d   y| jj| W n  tk
rX   | jj| Y nX y| jj	j
j}|j|| W n   Y nX d S )NrT   z%d.0r   )r6   r@   r   tag_addr4   index
ValueErrorappendr:   pyshellinterpr   r8   )r2   r   r6   r   debugr    r    r!   set_breakpoint   s    z"PyShellEditorWindow.set_breakpointc             C   s>   | j }| jj}|s|j  d S tt|jd}| j| d S )Ninsert)r6   r@   r   bellintfloatrY   r_   )r2   eventr6   r   r   r    r    r!   r8      s    z'PyShellEditorWindow.set_breakpoint_herec             C   s   | j }| jj}|s|j  d S tt|jd}y| jj| W n   Y nX |j	ddd y| j
jjj}|j|| W n   Y nX d S )Nr`   rT   zinsert linestartzinsert lineend +1char)r6   r@   r   ra   rb   rc   rY   r4   remove
tag_remover:   r\   r]   r   r9   )r2   rd   r6   r   r   r^   r    r    r!   r9      s"    z)PyShellEditorWindow.clear_breakpoint_herec          	   C   sd   | j r`| j}| jj}|s$|j  d S g | _ |jddt y| jjj	j
}|j| W n   Y nX d S )NrT   z1.0)r4   r6   r@   r   ra   rf   ZENDr:   r\   r]   r   clear_file_breaks)r2   r6   r   r^   r    r    r!   rg      s    z%PyShellEditorWindow.clear_file_breaksc             C   s  | j }| jj}y$t| jd}|j }W dQ R X W n tk
rJ   g }Y nX ynt| jdX}x$|D ]}|j|d sb|j| qbW | j	  | j }|r|j|d t
| d  W dQ R X W nV tk
r } z8t| jdds d| j_tjd	d
t
| | jd W Y dd}~X 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   )r4   r@   r   openr?   	readlinesr   
startswithr   update_breakpointsstrgetattrrootrl   tkMessageBox	showerrorr6   )r2   Zbreaksr   fplinesZnew_filer   errr    r    r!   store_file_breaks   s.    

(z%PyShellEditorWindow.store_file_breaksc             C   s   | j j  | jd krd S | jj}|d kr,d S tjj| jrt| jd}|j	 }W d Q R X xJ|D ]B}|j
|d r`t|t|d d  }x|D ]}| j| qW q`W d S )Nrh   rj   r   )r6   r,   r@   r   r<   r=   isfiler?   rn   ro   rp   evallenr_   )r2   r   rw   rx   r   Zbreakpoint_linenumbersZbreakpoint_linenumberr    r    r!   r1   
  s    



z'PyShellEditorWindow.restore_file_breaksc             C   s$   | j }|jd}| j|}|| _dS )z3Retrieves all the breakpoints in the current windowrT   N)r6   Z
tag_rangesranges_to_linenumbersr4   )r2   r6   rangesZlinenumber_listr    r    r!   rq     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`|j| |d7 }qDW qW |S )Nr      r   )ranger}   rb   rc   stringr[   )r2   r   rx   rY   r   endr    r    r!   r~   "  s    

z)PyShellEditorWindow.ranges_to_linenumbersc             C   s   | j   tj|  dS )z7Extend base method - clear breaks when module is closedN)rg   r   _close)r2   r    r    r!   r   3  s    zPyShellEditorWindow._close)rC   rD   rE   )rF   rG   rH   )rI   rJ   rK   )NNN)rL   rM   N)rN   rO   N)T)N)N)__name__
__module____qualname____doc__r5   rmenu_specsrA   r_   r8   r9   rg   rz   r1   rq   r~   r   r    r    r    r!   r0   |   s$   

	
*r0   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j  nt| | _ | j r2| j j s2d S | j S )N)r\   topwakeupPyShellbegin)r2   rd   r    r    r!   r;   B  s    

zPyShellFileList.open_shell)N)r   r   r   r   r0   r   r\   r;   r    r    r    r!   r   9  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 j|  | j  d S )N)r
   r5   LoadTagDefs)r2   r    r    r!   r5   P  s    
zModifiedColorDelegator.__init__c             C   s*   | j ddd | jddd tj|  d S )NZTODOz1.0iomarkZSYNC)rf   rX   r
   recolorize_main)r2   r    r    r!   r   T  s    z&ModifiedColorDelegator.recolorize_mainc             C   sJ   t j|  tj }| jjd d dtj|dtj|dtj|dd d S )N)rS   rR   stdoutstderrconsole)stdinr   r   r   )r
   r   r   rU   tagdefsr,   rV   )r2   rW   r    r    r!   r   Y  s    


z"ModifiedColorDelegator.LoadTagDefsc             C   s"   x| j D ]}| j|dd qW d S )Nr   r   )r   rf   )r2   tagr    r    r!   removecolorsc  s    z#ModifiedColorDelegator.removecolorsN)r   r   r   r   r5   r   r   r   r    r    r    r!   r   M  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 j|ddr | j j  d S W n tk
r6   Y nX tj| ||| d S )N<r   )delegatecomparera   TclErrorr   r`   )r2   rY   charstagsr    r    r!   r`   k  s    
zModifiedUndoDelegator.insertc             C   sJ   y"| j j|ddr | j j  d S W n tk
r6   Y nX tj| || d S )Nr   r   )r   r   ra   r   r   delete)r2   Zindex1Zindex2r    r    r!   r   t  s    
zModifiedUndoDelegator.delete)N)N)r   r   r   r   r`   r   r    r    r    r!   r   h  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)r2   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 )N__main__)localsF)	tkconsolesysmodules__dict__r   r5   save_warnings_filters
restartingsubprocess_arglistPORTportcompilecompilerflagsoriginal_compiler_flags)r2   r   r   r    r    r!   r5     s    zModifiedInterpreter.__init__Nc             C   s&   | j d kr| j | _ tj| j | _d S )N)r   build_subprocess_arglist
subprocessPopen
rpcsubproc)r2   r    r    r!   spawn_subprocess  s    

z$ModifiedInterpreter.spawn_subprocessc             C   sp   | j dkstddd tjD }tjddddd	d
}tdkrJd|f }n
d|f }tjg| d|t| j g S )Nr   z/Socket should have been assigned a port number.c             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idlelib.pyshellz&__import__('idlelib.run').run.main(%r)z__import__('run').main(%r)z-c)	r   AssertionErrorr   warnoptionsr   	GetOptionr   
executablerr   )r2   ri   Z	del_exitfZcommandr    r    r!   r     s    


z,ModifiedInterpreter.build_subprocess_arglistc             C   sZ  t | jf}xLtdD ]4}tj| yt|| _P W q tk
rF   Y qX qW | j  d S | jj	j
 d | _tdkr| jj	jtjtjd | j  | jj	jd y| jj  W n tjk
r   | j  d S X | jjd| j | jjd| jj | jjd| jj | jjd| jj | jjd	| jj | jjd
t | jjd|  | jdd | j  | jS )N   r   r   
   r   r   r   r   r:   r(   r]   T)with_cwd)HOSTr   r   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)r2   Zaddrir    r    r!   start_subprocess  s>    




z$ModifiedInterpreter.start_subprocessFrQ   c             C   sT  | j r| jS d| _ | j }|r<ytj| j W n   Y nX | jj  | j  | j}|j}d|_| j	  y| jj
  W n tjk
r   | j  d S X | j|d |j  |jjdd d|r|nd }t|jt| d d	 d
 }|jdj|| |jjdd |jjdd |s"|j  |r<tj| j |j  | j| jj_d| _ | jS )NTF)r   r   zend-1cz	RESTART: ZShell   r   rj   z
{0} {1} {0}restartleft) r   r   getdebuggerr   Zclose_subprocess_debuggercloseterminate_subprocessr   	executingr   r   r   r   r   r   stop_readliner6   r   rb   widthr}   r   formatmark_setmark_gravity
showpromptZrestart_subprocess_debuggerload_breakpointsr   r   r   r   )r2   r   r   r^   r   Zwas_executingr   Zhalfbarr    r    r!   restart_subprocess  sH    
z&ModifiedInterpreter.restart_subprocessc             C   s   | j jddf i  d S )NexecZinterrupt_the_server)r   Z
remotecall)r2   r    r    r!   Z__request_interrupt  s    z'ModifiedInterpreter.__request_interruptc             C   s   t j| jdj  d S )N)target)	threadingZThread'_ModifiedInterpreter__request_interruptstart)r2   r    r    r!   interrupt_subprocess  s    z(ModifiedInterpreter.interrupt_subprocessc             C   s~   | j d k	r| jjj| j  y| jjj  W n tk
r>   Y nX y| jj  W n tk
rb   Y nX | j  d| j_	d | _d S )NF)
_afteridr   r6   Zafter_cancelr   r   r   r   r   r   )r2   r    r    r!   kill_subprocess  s    
z#ModifiedInterpreter.kill_subprocessc             C   sL   y| j j  W n tk
r"   dS X y| j j  W n tk
rF   dS X dS )z"Make sure subprocess is terminatedN)r   killr   wait)r2   r    r    r!   r     s    z(ModifiedInterpreter.terminate_subprocessc             C   s2   |rdg}|j tj ntj}| jd|f  d S )NrQ   zRif 1:
        import sys as _sys
        _sys.path = %r
        del _sys
        
)extendr   r=   
runcommand)r2   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 }| j  Y nX |r| jj	  d | _|\}}| jj
}|dkr|d k	rtt||d nH|dkr| jjdr| j  n*|dkrd}t||tjd t|||d y| jj  W n tk
r   Y nX | jjs2| j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   r6   afterpollintervalr   r   )r2   ZcltresponseZhowZwhatr   errmsgr    r    r!   r   2  s@    


z#ModifiedInterpreter.poll_subprocessc             C   s
   || _ d S )N)r   )r2   r   r    r    r!   setdebuggerZ  s    zModifiedInterpreter.setdebuggerc             C   s   | j S )N)r   )r2   r    r    r!   r   ]  s    zModifiedInterpreter.getdebuggerc             C   s   | j 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   r6   r   r   )r2   r    r    r!   open_remote_stack_viewer`  s    
z,ModifiedInterpreter.open_remote_stack_viewerc             C   s   ddl m} | jjdddi }|d kr6| jjj  d S |j| j|}ddlm	}m
} t| jj}tj }tj|dd }|||dd	}	|	jjd
dd ||	jd |}
|
j  d S )Nr   )
debugobj_rr   Zstackviewerr:   )ScrolledCanvasTreeNodeZnormalrS   )ZbgZhighlightthicknessr   Zboth)expandZfill)r:   )idlelibr  r   remotequeuer   rt   ra   ZStubObjectTreeItemZidlelib.treer  r  ZToplevelr   rU   rV   frameZpackZcanvasr  )r2   r  Zoiditemr  r  r   rW   rS   ZscZnoder    r    r!   r   m  s    z'ModifiedInterpreter.remote_stack_viewerr   c             C   s   | j |}| j|| dS )z1Like runsource() but assumes complete exec sourceN)stuffsourceexecfile)r2   sourcer   r    r    r!   
execsource  s    
zModifiedInterpreter.execsourcec             C   s   |dkrFt j|.}|j }tr<dtjj| d| d }W dQ R X yt||d}W nH tt	fk
r   | j
j  td| j
jd tj| | | j
j  Y nX | j| 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   )tokenizern   readuse_subprocessr<   r=   abspathr   OverflowErrorSyntaxErrorr   r   r   r   r   showsyntaxerrorr   runcode)r2   r   r  rw   coder    r    r!   r    s    &
zModifiedInterpreter.execfilec             C   sr   | j |}d| _tjdd | _tjdtd t|ts<t	zt
j| ||S | jdk	rl| 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SyntaxWarning
isinstancerr   r   r   	runsource)r2   r  r   r    r    r!   r    s    
	
zModifiedInterpreter.runsourcec             C   s>   d| j  }| j d | _ |jd}t|d d||ftj|< |S )z"Stuff source in the filename cachez<pyshell#%d>r   rk   r   )gidsplitr}   r(   r)   )r2   r  r   rx   r    r    r!   r    s
    

zModifiedInterpreter.stuffsourcec             C   s   | j 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   )r2   r   r    r    r!   prepend_syspath  s    z#ModifiedInterpreter.prepend_syspathc             C   s   | j }|j}|jddd tj \}}}t|ddp:|p:d}t|ddpJd}t|d	dpZd
}	|	d
krl|d7 }|dkrd|	d  }
nd|d |	d f }
|j||
 |j  | jd|  |j	  dS )zOverride Interactive Interpreter method: Use Colorizing

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

        r   z1.0r   msgrQ   z<no detail available>r   r   offsetr   ziomark + %d charsz&iomark linestart + %d lines + %d charszSyntaxError: %s
N)
r   r6   rf   r   exc_infors   Zcolorize_syntax_errorr   r   r   )r2   r   r   r6   r   valuetbr"  r   r#  posr    r    r!   r    s"    z#ModifiedInterpreter.showsyntaxerrorc             C   s6   | j j  | j  tj|  | j jdr2| j j  dS )z1Extend base class method to reset output properlyz<<toggle-jit-stack-viewer>>N)r   r   checklinecacher   showtracebackr   open_stack_viewer)r2   r    r    r!   r)    s
    

z!ModifiedInterpreter.showtracebackc             C   sB   t j}x6t|j D ]&}|d d |dd   dkr||= qW d S )Nr   z<>r'   )r(   r)   r*   keys)r2   cr.   r    r    r!   r(    s    z"ModifiedInterpreter.checklinecachec             C   s@   | j jr| j  dS | jr0| j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   )r2   r  r    r    r!   r     s    zModifiedInterpreter.runcommandc             C   st  | j jr| jj  | j  | jdk	r:| jtjdd< d| _| j} zyV| j j	  | rx| j
dk	rx| j
jdd|fi | _n |r|j|| j nt|| j W n tk
r   | j jstjddd| j jdr̂ q| j  n Y nb   trtd| j jd	 | j  | j j  n,| j jr0d
| j _td| j jd	 n| j  Y nX W dtsny| j j  W n tk
rl   Y nX X dS )zOverride base class methodNr   r  zExit?zDo you want to exit altogether?yes)r   r   z IDLE internal error in runcode())r   Fr   )r   r   r]   r   r(  r   r$   r  r   beginexecutingr   Z
asyncqueuer   Zrunr   r   
SystemExitr   ru   Zaskyesnor6   r)  r  r   r   r   canceledr   )r2   r  r   r    r    r!   r    sP    





zModifiedInterpreter.runcodec             C   s   | j jj|S )zOverride base class method)r   r   r   )r2   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   )ru   rv   r   r6   )r2   r    r    r!   r   /  s    z.ModifiedInterpreter.display_port_binding_errorc             C   s   t jdd| jjd d S )NzSubprocess Startup ErrorzIDLE's subprocess didn't make connection.  Either IDLE can't start a subprocess or personal firewall software is blocking the connection.)r   )ru   rv   r   r6   )r2   r    r    r!   r   :  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   )ru   rv   r   r6   )r2   r    r    r!   r-  B  s    z,ModifiedInterpreter.display_executing_dialog)FrQ   )F)N)N)&r   r   r   r5   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dZd[d\d]d^d_gZ	e
jd`g ZddlmZ daddZdd ZdZdZdZdZdZdZdd Zdd ZdbddZdd  Zdcd!d"Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-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 Z3f fdTdUZ4 fdVdWZ5 fdXdYZ6  Z7S )hr   zPython z Shellr   _Fileedit_Editr^   _Debugoptions_Optionswindow_Windowhelp_HelpSqueeze<<squeeze-current-text>>r   )HistoryNc          	   C   s  t r&| j}|d d dkr&|jdd t| | _|d krVt }t| |j  t|}t	j
| |d d  d| _d| _ttdrtjnd| _| jjd	d | _| j| _| j}|jdd |jd| j |jd| j |jd| j |jd| j |jd| j |jd| j |jd| j t r8|jd| j |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-|_.W n   tj/t_" Y nX | j0| j| _1d| _2d S )Nr   r   shellShe_llT   ps1z>>> rk   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>>)iomenur   r   r   r   2   )r?  r@  r'   )3r  
menu_specsr`   r   r]   Tkr   withdrawr   r   r5   ZusetabsZindentwidthhasattrr   rB  sys_ps1r   Zprompt_last_linepromptr6   Z	configurer7   enter_callbacklinefeed_callbackcancel_callbackeof_callbackr*  toggle_debuggertoggle_jit_stack_viewerview_restart_markrestart_shellr   save_stdoutr   save_stderrr   
save_stdinr  rE  r   encodingr   r   pydocZ
plainpagerZpagerr   r>  historyr   )r2   r:   Zmsrt   r6   rE  rY  r    r    r!   r5   d  s`    
zPyShell.__init__c             C   s   t jddS )NT)Z
shell_only)r   ZGetExtensions)r2   r    r    r!   get_standard_extension_names  s    z$PyShell.get_standard_extension_namesFc             C   s   |a d S )N)r   )r2   streamr    r    r!   set_warning_stream  s    zPyShell.set_warning_streamc             C   s   t S )N)r   )r2   r    r    r!   get_warning_stream  s    zPyShell.get_warning_streamc             C   sH   | j r$tjdd| jd | j  dS | jj }|r<| j  n| j  d S )NzDon't debug nowz*You can only toggle the debugger when idle)r   rP   )	r   ru   rv   r6   set_debugger_indicatorr]   r   close_debuggeropen_debugger)r2   rd   dbr    r    r!   rQ    s    


zPyShell.toggle_debuggerc             C   s   | j j }| jd|   d S )Nz<<toggle-debugger>>)r]   r   Zsetvar)r2   rb  r    r    r!   r_    s    
zPyShell.set_debugger_indicatorc             C   s   d S )Nr    )r2   rd   r    r    r!   rR    s    zPyShell.toggle_jit_stack_viewerc             C   sh   | j j }|r\| j jd  |j  | j jr8tj| j j | j  | jj	d | j
| _| j  | j  d S )Nz[DEBUG OFF]
)r]   r   r  r   r   r   Zclose_remote_debuggerr   r   r   rK  rL  r   r_  )r2   rb  r    r    r!   r`    s    
zPyShell.close_debuggerc             C   sX   | j jrtj| j j| }n
tj| }| j j| |j  d| j | _	| j
  | j  d S )Nz[DEBUG ON]
)r]   r   r   Zstart_remote_debuggerr   ZDebuggerr  r   rK  rL  r   r_  )r2   Zdbg_guir    r    r!   ra    s    

zPyShell.open_debuggerc             C   s   | j   d| _dS )zHelper for ModifiedInterpreterr   N)r   r   )r2   r    r    r!   r/    s    zPyShell.beginexecutingc             C   s   d| _ d| _| j  dS )zHelper for ModifiedInterpreterr   N)r   r1  r   )r2   r    r    r!   r     s    zPyShell.endexecutingc             C   sD   | j r&tjddd| jd}|dkr&dS | j  d| _d| _tj| S )zExtend EditorWindow.close()zKill?z7Your program is still running!
 Do you want to kill it?ok)r   r   FZcancelT)	r   ru   Zaskokcancelr6   r   r1  r   r   r   )r2   r   r    r    r!   r     s    
zPyShell.closec             C   sV   | j   tr| jj  | jt_| jt_| j	t_
d| _d| _d| j_d| _tj|  dS )zEExtend EditorWindow._close(), shut down debugger and execution serverN)r`  r  r]   r   rU  r   r   rV  r   rW  r   r   r:   r\   rZ  r   r   )r2   r    r    r!   r     s    
zPyShell._closec             C   s   dS )z8Override EditorWindow method: never remove the colorizerTr    )r2   r   r    r    r!   ispythonsource	  s    zPyShell.ispythonsourcec             C   s   | j S )N)shell_title)r2   r    r    r!   short_title  s    zPyShell.short_titlezHType "help", "copyright", "credits" or "license()" for more information.c             C   s   | j jdd | j  tr:d}| jj }|sF| j  dS nd}tjt	_| j
d	t	jt	j| j|f  | j j  | j  d
d l}d |_dS )Nr   r`   rQ   Fz==== No Subprocess ====

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

zPython %s on %s
%s
%sr   TzR==== 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.

)r6   r   r   r  r]   r   r   r   displayhookr   r   versionplatform	COPYRIGHTZfocus_forcer   tkinterZ_default_root)r2   ZnosubZclientrk  r    r    r!   r     s$    
 
zPyShell.beginc             C   s   | j s
d S d| _| jj  d S )NT)reading_stop_readline_flagr   quit)r2   r    r    r!   r   +  s    zPyShell.stop_readlinec             C   s   | j }zd| _ | jj  W d || _ X | jr4d| _dS | jjdd}t|dkrRd}| j  | jrnd| _t	snt
| jr~d| _d}|S )Nr   FrQ   r   zend-1cr   rk   )rl  r   mainlooprm  r6   getr}   r   r1  r  r   	endoffile)r2   r-   r   r    r    r!   readline1  s(    zPyShell.readlinec             C   s   dS )NTr    )r2   r    r    r!   isattyH  s    zPyShell.isattyc          
   C   s   y| j jdddrd S W n   Y nX | jp0| jsR| j  | jjd | j  dS d| _d| _	| jr| jj
r| jj r| jj  n
| jj  | jr| jj  dS )Nz	sel.firstz!=zsel.lastzKeyboardInterrupt
rP   r   r   )r6   r   r   rl  r   r]   r   r   rq  r1  r   r   r   r   r   rn  )r2   rd   r    r    r!   rO  K  s&    


zPyShell.cancel_callbackc             C   sh   | j r| j rd S | jjdddo0| jjddds6d S | j sN| j  | j  nd| _d| _| jj	  dS )Nr   z==r`   zend-1cr   r   rP   )
r   rl  r6   r   r   r   r1  rq  r   rn  )r2   rd   r    r    r!   rP  a  s    

zPyShell.eof_callbackc             C   s0   | j r"| jjdd | jjd n
| j| dS )Nr`   rk   rP   )rl  r6   r`   seenewline_and_indent_event)r2   rd   r    r    r!   rN  p  s
    
zPyShell.linefeed_callbackc             C   s<  | j r| j rd S y6| jjdd}|rF| jjdddrF| j|| dS W n   Y nX | jjdddrX| jjd	d}|r| jjdd|d
 r| j| jj|d |d
 | dS | jjd	d}|r| jjdd|d r| j| jj|d |d
 | dS | jjdd}|r>| jj|d ddr>| j| jj|d
 d| n| j| jjdd| dS | jjdddrx| jjdd | jjdd}|r|j	  r| jj
dd | jjdddr| j| dS | jjdd | jr| jjdd | jjd n
| j| | jjd	dd | jj  | jr0| jj  n| j  dS )Nz	sel.firstzsel.lastz<=r   rP   r`   r   ziomark linestartr   r   r   zinsert lineendz>=r   zinsert linestartzend-1czend-1c linestartrk   )r   rl  r6   rp  r   recallZtag_prevrangeZtag_nextranger   stripr   ru  r`   rt  rX   Zupdate_idletasksr   rn  runit)r2   rd   selprevnextindicesr   r    r    r!   rM  y  sX    


zPyShell.enter_callbackc             C   s<  t jdd|}t jdd|}|jd}| jj  z| jjddd | jjdd	 | jjd
d}|j j	dr| j
| | jjd
d}| jjd|d j  t|dkrt jd|d jd}t jd|jd}xJ|dd  D ]:}|j|r||t|d   }| jjdd|j   qW W d | jjd | jj  X d S )Nz^\s*\nrQ   z\n\s*$rk   ry  z1.0r   r`   zend-1czinsert linestart:r   r   z	^([ \t]*))resubr   r6   Zundo_block_startrf   r   rp  rstripendswithru  r`   rw  r}   searchgrouprp   rt  Zundo_block_stop)r2   r   rd   rx   prefixZorig_base_indentZnew_base_indentr   r    r    r!   rv    s*    


zPyShell.recallc             C   s   | j 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j| d S )Nr   zend-1cr   r   z 	rk   )r6   rp  r}   r]   r  )r2   r   r   r    r    r!   rx    s    zPyShell.runitc             C   sX   | j jr| j 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)r]   r   r   r   last_tracebackru   rv   r6   Zidlelib.stackviewerr  rt   r:   )r2   rd   r  r    r    r!   r*    s    


zPyShell.open_stack_viewerc             C   s   | j jd | j jd d S )Nr   r   )r6   rt  )r2   rd   r    r    r!   rS    s    zPyShell.view_restart_markc             C   s   | j jdd dS )z&Callback for Run/Restart Shell Cntl-F6T)r   N)r]   r   )r2   rd   r    r    r!   rT    s    zPyShell.restart_shellc             C   s:   | j   | jj| j | jjdd | j  | jj  d S )Nr`   zend-1c)	r   r   r   rL  r6   r   set_line_and_columnr@   Z
reset_undo)r2   r    r    r!   r     s
    zPyShell.showpromptc             C   sP   | j jj}t|ddd}dj|j|}|jds:|d7 }| jjj	d|d d S )NrA  T)r   tabsizeZexpand_tabsrk   ziomark linestartr   )
r]   r   r   r	   r>   rD  r  ZperZbottomr`   )r2   r"  r   wrapperZwrapped_msgr    r    r!   show_warning  s    

zPyShell.show_warningc             C   sX   | j jdd}| jr | jj| | j jddkr>| j jdd | j jdd | j  d S )Nr   zend-1czend-2crk   )r6   rp  rZ  Zstorer`   r   r  )r2   r  r    r    r!   r     s    zPyShell.resetoutputc             C   s   t |trRt|rRt|dkrRxt|D ]\}}|dkr(P q(W td|||d dy0| jjdd tj	| ||d}| jjdd W n    Y nX | j
rd| _
tst|S )	Nu   ￿zUCS-2r   z%Non-BMP character not supported in Tkr   rightr   r   )r  rr   r}   max	enumerateUnicodeEncodeErrorr6   r   r   r   r1  r  r   )r2   r   r   r   rC  countr    r    r!   r     s"    zPyShell.writec                s8   y| j jdddrdS W n tk
r,   dS X t j S )Nz	sel.firstr   r   disabled)r6   r   r   superrE   )r2   )	__class__r    r!   rE   &  s    zPyShell.rmenu_check_cutc                s   | j jdddrdS t j S )Nr`   r   r   r  )r6   r   r  rK   )r2   )r  r    r!   rK   .  s    zPyShell.rmenu_check_paste)r   r2  )r3  r4  )r^   r5  )r6  r7  )r8  r9  )r:  r;  )r<  r=  )N)N)N)N)N)N)N)8r   r   r   r   re  r   r
   r   r   rG  r   r   Zidlelib.historyr>  r5   r[  rl  r   r1  rq  r   rm  r]  r^  rQ  r_  rR  r`  ra  r/  r   r   r   rd  rf  rj  r   r   rr  rs  rO  rP  rN  rM  rv  rx  r*  rS  rT  r   r  r   r   rE   rK   __classcell__r    r    )r  r!   r   J  sj   
<


	?


	r   c             C   s6   | j dkr2x&dD ]}| j|dd| j|d  qW dS )	z6Make paste replace selection on x11.  See issue #5124.Zx11TextEntrySpinboxz	<<Paste>>z%catch {%W delete sel.first sel.last}
N)r  r  r  )Z_windowingsystemZ
bind_class)rt   clsr    r    r!   fix_x11_paste4  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                 s\  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| j tj	dd  d\}
}W nD | j
k
r } z&td	|tf tjd
 tjd W Y d d }~X nX x|
D ]\}}|dkr|}d}|dkrd}d}|dkrd}|dkrtjjt tj  |dkrd}|dkr6tdtjd
 da|dkrj|}tjj|rTntd| tj  d}|dkr|d}	d}|dkr|t_d}qW |r|d dkrtjj }d}x0tttjD ]}tjjtj| tj|< qW |r|d dkrdg|dd   t_	n|r$dg| t_	n|r8|g| t_	n|rd}g }x |D ]}|jtjj| qLW xX|D ],}tjj|}|tjkrntjjd| qnW n"tj }|tjkrtjjd| tj ddddd}|p|}|p| }tr| rt!  t"dda#t#j$  dd l%m&} |t# tjj'tjjt(d!| d"krbtjj'd#}t#j)|d$ nBt*d%krpd&nd'  fd(d)d1D }d-d) |D }t#j+d2|  t,t# t-t# t.t#a/|j0t#t/ |r|p|sx0|d d  D ] }t/j1|d kr|j2| qW |st/j3  |rPt/j4 }|s2d S |j5 rVt/j6rV|j7j8  nt/j9}|rd|j:  |	rtj;j<d.ptj;j<d/}|rtjj|r|j=j>| |s|r|j=j?d0tj	f  |r|j=j@| n|r0|j=jA| |j=j>| n8|r0|jBt#}|r|jC| |jD }|r0|jC| xt/jErFt#jF  q2W t#jG  td d S )3Nr   )system)testing)macosxTFr   zc:deihnr:st:zError: %s
%s)r   r   z-cz-dz-ez-hz-iz-nz: Warning: running IDLE without a subprocess is deprecated.z-rzNo script file: z-sz-t-rQ   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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
PhotoImagert   )r   iconfiler    r    r!   r     s   ZIDLESTARTUPZPYTHONSTARTUPzbif 1:
            import sys as _sys
            _sys.argv = %r
            del _sys
            
)r  r  r  )T)Hgetoptri  r  r  r  r  r&   r  r   argvr  r   	usage_msgr   exitr   r   r<   r=   r{   r   re  r   r  r   r}   r  r[   dirnamer`   getcwdr   r   ZNoDefaultRootrH  rt   rI  idlelib.runr   r>   __file__Zwm_iconbitmap	TkVersionZwm_iconphotor   r  r   r:   ZsetupApprn   re   newr;   ZisAquaTkdictr   lowerr\   ra  environrp  r]   r  r   r  r!  ZtkVersionWarningr  ZpreferTabsPreferenceWarningZinversedictro  Zdestroy)r  r  r  r  Zenable_shellZenable_editr^   cmdZscriptZstartupZoptsrB   r"  oar   Zpathxr   dirZ
edit_startr   r  Z	iconfilesZiconsr?  ZtkversionwarningZprefer_tabs_preference_warningr    )r  r  r!   r   u  s   
















r   r   r\   F)NN)Or   rk  ImportErrorr   r   r0  ri  ZctypesZPROCESS_SYSTEM_DPI_AWAREZOleDLLZSetProcessDpiAwarenessr   r   Ztkinter.messageboxZ
messageboxru   r  rH  rt   rI  r  r   rv   r  r   r(   r<   Zos.pathr   r~  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&   
checkcacher/   r0   r   r   r   Z	RPCClientr   r   r   r  r  r   r   r   r    r    r    r!   <module>   s   



 >   H   m? 1
