B � f��� @s�ddlZedkr ejdejd<y ddlTWn*ek rVedejd�ed��YnXejdkr�y ddl Z dZ e � d �� e �Wnee efk r�YnXddlmZed kr�e�at��dd lmZet�ejd d etd�ed��ddlmZddlZddlZddlZddlmZddlZddl Z ddl!Z!ddl"m#Z#ddl$Z$ddl%Z%ddl&Z&ddl'Z'ddl(m)Z)ddl*m+Z+ddl,m-Z-ddl,m.Z.ddl/m0Z0m1Z1ddl2m3Z3ddl4m5Z5ddl,m6Z6ddlm7Z7m8Z8m9Z9ddl:m;Z;dZd:dd�Z?da@dd �ZAeAd!�dejBfd"d#�ZCeCe_BGd$d%�d%e0�ZDGd&d'�d'e3�ZEGd(d)�d)e)�ZFGd*d+�d+e;�ZGGd,d-�d-e6jH�ZId.d/�ZJGd0d1�d1e�ZKGd2d3�d3e5�ZLd4d5�ZMd6ZNd7d8�ZOedk�r�eO�eAd9�dS);�N�__main__zidlelib.pyshell)�*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� StdInputFile� StdOutputFile)� UndoDelegatorz 127.0.0.1c CsP|dkr t}y&|�t|||||d��|�d�Wnttfk rJYnXdS)aShow Idle-format warning (after replacing warnings.showwarning). The differences are the formatter called, the file=None replacement, which can be None, the capture of the consequence AttributeError, and the output of a hard-coded prompt. N)�linez>>> )�warning_stream�writer�AttributeError�OSError)�message�category�filename�linenorr�r!�4/opt/alt/python37/lib64/python3.7/idlelib/pyshell.py�idle_showwarningEsr#cCs0|rtdkr,tjatt_ntdk r,tt_dadS)z>Replace warning.showwarning with idle_showwarning, or reverse.N)�_warnings_showwarning�warnings� showwarningr#)Zcapturer!r!r"�capture_warningsXsr'TcCs\tj}i}x:t|�D].}|dd�|dd�dkr|�|�||<qW||�|�|�dS)aoExtend linecache.checkcache to preserve the entries Rather than repeating the linecache code, patch it to save the 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)rZorig_checkcacher*�save�keyr!r!r"�extended_linecache_checkcachegs r0c@s~eZdZdZdd�Zdddddd gZd d d �Zd d�Zd!dd�Zd"dd�Z dd�Z dd�Z dd�Z dd�Z dd�Zdd�ZdS)#�PyShellEditorWindowz6Regular text edit window in IDLE, supports breakpointscGs�g|_tj|f|��|j�d|j�|j�d|j�|j�d|jj�t j � t j d�|_|jj|fdd�}|j�|�|jjr�|��|��dS)Nz<>z<>z<>zbreakpoints.lstcSs|��|�dS)N)�restore_file_breaks)Zold_hook�selfr!r!r"�filename_changed_hook�sz;PyShellEditorWindow.__init__..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_hookrr2�color_breakpoint_text)r3�argsr4r!r!r"r6�s   zPyShellEditorWindow.__init__)ZCutz<>�rmenu_check_cut)ZCopyz<>Zrmenu_check_copy)ZPastez <>�rmenu_check_paste)NNN)zSet Breakpointz<>N)zClear Breakpointz<>NTcCsD|jdkrdS|r(t��}t�|d�}n ddd�}|j�d|�dS)z,Turn colorizing of breakpoint text on or offN�break�)� foreground� background�BREAK)rAr � CurrentTheme� GetHighlightr7Z tag_config)r3Zcolor�themeZcfgr!r!r"rB�s  z)PyShellEditorWindow.color_breakpoint_textcCs�|j}|jj}|�dd|d|d�y|j�|�Wn tk rX|j�|�YnXy|jj j j }|� ||�Wn YnXdS)NrJz%d.0r) r7rAr�tag_addr5�index� ValueError�appendr;�pyshell�interpr r9)r3r r7r�debugr!r!r"�set_breakpoint�s z"PyShellEditorWindow.set_breakpointNcCs>|j}|jj}|s|��dStt|�d���}|�|�dS)N�insert)r7rAr�bell�int�floatrOrU)r3�eventr7rr r!r!r"r9�sz'PyShellEditorWindow.set_breakpoint_herecCs�|j}|jj}|s|��dStt|�d���}y|j�|�Wn YnX|� ddd�y|j j j j }|�||�Wn YnXdS)NrVrJzinsert linestartzinsert lineend +1char)r7rArrWrXrYrOr5�remove� tag_remover;rRrSr r:)r3rZr7rr rTr!r!r"r:�s" z)PyShellEditorWindow.clear_breakpoint_herecCsd|jr`|j}|jj}|s$|��dSg|_|�ddt�y|jjj j }|� |�Wn YnXdS)NrJz1.0) r5r7rArrWr\ZENDr;rRrSr �clear_file_breaks)r3r7rrTr!r!r"r]�s z%PyShellEditorWindow.clear_file_breaksc Cs|j}|jj}y$t|jd��}|��}WdQRXWntk rJg}YnXynt|jd��X}x$|D]}|�|d�sb|�|�qbW|� �|j}|r�|�|dt |�d�WdQRXWnTtk �r}z4t |j dd�s�d|j _ tjd d t |�|jd �Wdd}~XYnXdS) z#Save breakpoints when file is saved�rN�w�=� �breakpoint_error_displayedFTz IDLE Errorz$Unable to update breakpoint list: %s)�titlerr)r5rAr�openr@� readlinesr� startswithr�update_breakpoints�str�getattr�rootrb� tkMessageBox� showerrorr7)r3Zbreaksr�fp�linesZnew_filer�errr!r!r"�store_file_breaks�s.  (z%PyShellEditorWindow.store_file_breaksc Cs�|j��|jdkrdS|jj}|dkr,dStj�|j�r�t|jd��}|� �}WdQRXxJ|D]B}|� |d�r`t |t |�dd��}x|D]}|� |�q�Wq`WdS)Nr^r`r)r7r-rArr=r>�isfiler@rdrerf�eval�lenrU)r3rrmrnrZbreakpoint_linenumbersZbreakpoint_linenumberr!r!r"r2 s    z'PyShellEditorWindow.restore_file_breakscCs$|j}|�d�}|�|�}||_dS)z3Retrieves all the breakpoints in the current windowrJN)r7Z tag_ranges�ranges_to_linenumbersr5)r3r7�rangesZlinenumber_listr!r!r"rgs  z&PyShellEditorWindow.update_breakpointscCsjg}x`tdt|�d�D]L}tt||j��}tt||dj��}x||kr`|�|�|d7}qDWqW|S)Nr�r)�rangersrXrY�stringrQ)r3rurnrOr �endr!r!r"rt%s  z)PyShellEditorWindow.ranges_to_linenumberscCs|��t�|�dS)z7Extend base method - clear breaks when module is closedN)r]r�_close)r3r!r!r"rz6szPyShellEditorWindow._close)T)N)N)�__name__� __module__� __qualname__�__doc__r6� rmenu_specsrBrUr9r:r]rpr2rgrtrzr!r!r!r"r1~s$  *r1c@s"eZdZdZeZdZddd�ZdS)�PyShellFileListz8Extend base class: IDLE supports a shell and breakpointsNcCs8|jr|jj��nt|�|_|jr2|j��s2dS|jS)N)rR�top�wakeup�PyShell�begin)r3rZr!r!r"r<Es  zPyShellFileList.open_shell)N)r{r|r}r~r1rrRr<r!r!r!r"r�<sr�c@s0eZdZdZdd�Zdd�Zdd�Zdd �Zd S) �ModifiedColorDelegatorz8Extend base class: colorizer for the shell window itselfcCst�|�|��dS)N)r r6� LoadTagDefs)r3r!r!r"r6Ss zModifiedColorDelegator.__init__cCs*|�ddd�|�ddd�t�|�dS)NZTODOz1.0�iomarkZSYNC)r\rNr �recolorize_main)r3r!r!r"r�Wsz&ModifiedColorDelegator.recolorize_mainc CsJt�|�t��}|j�ddd�t�|d�t�|d�t�|d�d��dS)N)rIrH�stdout�stderr�console)�stdinr�r�r�)r r�r rK�tagdefsr-rL)r3rMr!r!r"r�\s   z"ModifiedColorDelegator.LoadTagDefscCs"x|jD]}|�|dd�qWdS)Nr�ry)r�r\)r3�tagr!r!r"� removecolorsfs z#ModifiedColorDelegator.removecolorsN)r{r|r}r~r6r�r�r�r!r!r!r"r�Ps  r�c@s$eZdZdZddd�Zddd�ZdS) �ModifiedUndoDelegatorz;Extend base class: forbid insert/delete before the I/O markNcCsLy"|j�|dd�r |j��dSWntk r6YnXt�||||�dS)N��Z%dS)C�ModifiedInterpretercCsB||_tjdj}tj||d�d|_d|_t|_ |j j j |_ dS)Nr)�localsF)� tkconsole�sys�modules�__dict__rr6� restarting�subprocess_arglist�PORT�port�compile�compiler�flags�original_compiler_flags)r3r�r�r!r!r"r6�s zModifiedInterpreter.__init__NcCs&|jdkr|��|_t�|j�|_dS)N)r��build_subprocess_arglist� subprocess�Popen� rpcsubproc)r3r!r!r"�spawn_subprocess�s  z$ModifiedInterpreter.spawn_subprocesscCs\|jdkstd��dd�tjD�}tjddddd d �}d |f}tjg|d |t|j�gS) Nrz/Socket should have been assigned a port number.cSsg|] }d|�qS)z-Wr!)�.0�sr!r!r"� �s[email protected]_subprocess_arglist..�main�Generalzdelete-exitfuncF�bool)�default�typez&__import__('idlelib.run').run.main(%r)z-c)r��AssertionErrorr�� warnoptionsr � GetOption� executablerh)r3r_Z del_exitfZcommandr!r!r"r��s    z,ModifiedInterpreter.build_subprocess_arglistc CsZt|jf}xLtd�D]4}t�|�yt|�|_PWqtk rFYqXqW|��dS|jj � �d|_t dkr�|jj � t jt jd�|��|jj �d�y|j��Wnt jk r�|��dSX|j�d|j�|j�d|jj�|j�d|jj�|j�d|jj�|j�d |jj�|j�d t�|j�d |�|jd d �|��|jS)N�rr� r�r�r�r�r;r)rST)�with_cwd)�HOSTr�rw�timeZsleepr��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)r3Zaddr�ir!r!r"�start_subprocess�s>       z$ModifiedInterpreter.start_subprocessFrGcCs0|jr |jSd|_|��}|rYnXy|j��Wntk rbYnX|��d|j_ d|_dS)NF) �_afteridr�r7Z after_cancelr�r�r�rr�r�)r3r!r!r"�kill_subprocesss z#ModifiedInterpreter.kill_subprocesscCsLy|j��Wntk r"dSXy|j��Wntk rFdSXdS)z"Make sure subprocess is terminatedN)r��killr�wait)r3r!r!r"r�!sz(ModifiedInterpreter.terminate_subprocesscCs2|rdg}|�tj�ntj}|�d|f�dS)NrGzRif 1: import sys as _sys _sys.path = %r del _sys )�extendr�r>� runcommand)r3r�r>r!r!r"r�.s z!ModifiedInterpreter.transfer_pathc Cs6|j}|dkrdSy|j|jdd�}Wn2tttfk rX|jjrHdSd}|��YnX|�r|j� �d|_|\}}|jj }|dkr�|dk r�t t |�|d�nH|dkr�|j� d�r�|��n*|dkr�d}t ||tjd�t |||d�y|j��Wntk �rYnX|jj�s2|jj�|jj|j�|_dS) Ng�������?)r�ZOK)rZ EXCEPTIONz<>�ERRORz/pyshell.ModifiedInterpreter: Subprocess ERROR: )r�Z pollresponse� active_seqr�r�KeyboardInterruptr��closingr�� resetoutputr��print�repr�getvar�remote_stack_viewerr�� __stderr__� endexecutingrr7�after� pollintervalr�r�)r3Zclt�responseZhowZwhatr��errmsgr!r!r"r�=s@    z#ModifiedInterpreter.poll_subprocesscCs ||_dS)N)r )r3r r!r!r"� setdebuggereszModifiedInterpreter.setdebuggercCs|jS)N)r )r3r!r!r"r�hszModifiedInterpreter.getdebuggercCs|jj�d|j�dS)a�Initiate the remote stack viewer from a separate thread. This method is called from the subprocess, and by returning from this method we allow the subprocess to unblock. After a bit the shell requests the subprocess to open the remote stack viewer which returns a static object looking at the last exception. It is queried through the RPC mechanism. i,N)r�r7r�r�)r3r!r!r"�open_remote_stack_viewerks z,ModifiedInterpreter.open_remote_stack_viewerc Cs�ddlm}|j�dddi�}|dkr6|jj��dS|�|j|�}ddlm }m }t |jj�}t � �}t �|d�d}|||dd �} | jjd d d �|| jd|�} | ��dS) Nr)� debugobj_rr�Z stackviewer)r;)�ScrolledCanvas�TreeNodeZnormalrI)ZbgZhighlightthicknessrZboth)�expandZfill)�idlelibr�r�� remotequeuer�rjrWZStubObjectTreeItemZ idlelib.treer�r�ZToplevelr rKrL�frameZpackZcanvasr�) r3r�Zoid�itemr�r�r�rMrIZscZnoder!r!r"r�xs   z'ModifiedInterpreter.remote_stack_viewerrcCs|�|�}|�||�dS)z1Like runsource() but assumes complete exec sourceN)� stuffsource�execfile)r3�sourcerr!r!r"� execsource�s zModifiedInterpreter.execsourcec Cs�|dkrFt�|��.}|��}tr�abspathr�� OverflowError� SyntaxErrorr�r�r�r�r�showsyntaxerrorr��runcode)r3rrrm�coder!r!r"r�s &   zModifiedInterpreter.execfilecCs&|�|�}t|t�st�t�|||�S)zBExtend base class method: Stuff the source in the line cache first)r� isinstancerhr�r� runsource)r3rrr!r!r"r�s zModifiedInterpreter.runsourcecCs>d|j}|jd|_|�d�}t|�dd||ftj|<|S)z"Stuff source in the filename cachez rrar)�gid�splitrsr)r*)r3rrrnr!r!r"r�s    zModifiedInterpreter.stuffsourcecCs|�d|f�dS)z>Prepend sys.path with file's directory if not already includeda(if 1: _filename = %r import sys as _sys from os.path import dirname as _dirname _dir = _dirname(_filename) if not _dir in _sys.path: _sys.path.insert(0, _dir) del _filename, _sys, _dirname, _dir N)r�)r3rr!r!r"�prepend_syspath�sz#ModifiedInterpreter.prepend_syspathc Cs�|j}|j}|�ddd�t��\}}}t|dd�p:|p:d}t|dd�pJd}t|d d�pZd } | d krl|d7}|dkr�d | d} nd |d| df} |�|| �|��|�d |�|� �dS)z�Override Interactive Interpreter method: Use Colorizing Color the offending position instead of printing it and pointing at it with a caret. r�z1.0ry�msgrGzr r�offsetrziomark + %d charsz&iomark linestart + %d lines + %d charszSyntaxError: %s N) r�r7r\r��exc_inforiZcolorize_syntax_errorr�rr�) r3rr�r7r��value�tbrr r�posr!r!r"r �s" z#ModifiedInterpreter.showsyntaxerrorcCs6|j��|��t�|�|j�d�r2|j��dS)z1Extend base class method to reset output properlyz<>N)r�r��checklinecacher� showtracebackr��open_stack_viewer)r3r!r!r"r�s    z!ModifiedInterpreter.showtracebackcCsBtj}x6t|���D]&}|dd�|dd�dkr||=qWdS)Nrr(z<>)r)r*r+�keys)r3�cr/r!r!r"r�sz"ModifiedInterpreter.checklinecachecCs@|jjr|��dS|jr0|j�dd|fi�n t||j�dS)z*Run the code without invoking the debuggerrr�r r)r�r��display_executing_dialogr�r�r�r�)r3r r!r!r"r��s zModifiedInterpreter.runcommandcCsN|jjr|j��|��|j}z�yT|j��|sT|jdk rT|j�dd|fi�|_ n |rh|� ||j �n t ||j �Wn�t k r�|jjs�tjddd|jjd�r��q�|��n�Yn`tr�td|jjd �|��|j��n,|jj�r d |j_td |jjd �n|��YnXWdt�sHy|j��Wntk �rFYnXXdS) zOverride base class methodNr�r zExit?zDo you want to exit altogether?Zyes)r�rz IDLE internal error in runcode())rFr�)r�r�rSr�rr �beginexecutingr�Z asyncqueuer��runr�r�� SystemExitr�rkZaskyesnor7rrr�r�r��canceledr)r3r r r!r!r"r �sJ        zModifiedInterpreter.runcodecCs|jj�|�S)zOverride base class method)r�r�r)r3r�r!r!r"r#szModifiedInterpreter.writecCstjdd|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)rkrlr�r7)r3r!r!r"r�'sz.ModifiedInterpreter.display_port_binding_errorcCstjdd|jjd�dS)NzSubprocess Connection Errorz�IDLE's subprocess didn't make connection. See the 'Startup failure' section of the IDLE doc, online at https://docs.python.org/3/library/idle.html#startup-failure)r)rkrlr�r7)r3r!r!r"r�2sz/ModifiedInterpreter.display_no_subprocess_errorcCstjdd|jjd�dS)NzAlready executingzYThe Python Shell window is already executing a command; please wait until it is finished.)r)rkrlr�r7)r3r!r!r"r:sz,ModifiedInterpreter.display_executing_dialog)FrG)F)N)N)&r{r|r}r6r�r�r�r�r�r�r�r�r�r�r�r�r�r�r r�r�r�r�rrrrrrr rrr�r rr�r�rr!r!r!r"r��sF  + , &     . r�cs�eZdZde�dZeZeZddddddgZ e j d gZ d Z d d l mZdTdd�Zdd�Zd Zd Zd Zd Zd Zd Zdd�Zdd�ZdUdd�Zdd�ZdVdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$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�Z0dZdEdF�Z1dGdH�Z2dIdJ�Z3dKdL�Z4d[dNdO�Z5�fdPdQ�Z6�fdRdS�Z7�Z8S)\r�zPython z Shell)rZ_File)ZeditZ_Edit)rTZ_Debug)ZoptionsZ_Options)ZwindowZ_Window)�helpZ_Help)ZSqueezez<>Fr)�HistoryNcCs$tr&|j}|dddkr&|�dd�t|�|_|dkrVt�}t|�|��t|�}t � ||dd�d|_ d|_ t td�r�tjnd|_|j�d �d |_|j|_|j}|jd d �|�d |j�|�d|j�|�d|j�|�d|j�|�d|j�|�d|j�|�d|j�t�r8|�d|j�|�d|j�|� |�}|�d|j!�tj"|_#tj$|_%tj&|_'ddl(m)}t*|d|j+|j,�|_&t-|d|j+|j,�|_"t-|d|j+d�|_$t-|d|j+|j,�|_.t�s�|j"t_"|j$t_$|j&t_&yddl/}|j0|_1Wntj2t_$�YnX|�3|j�|_4d|_5dS)Nrvr�shell)r%ZShe_llT��ps1z>>> rar(�char)�wrapz<>z<>z<>z<>z<>z<>z<>z<>z<>z<>)�iomenur�r�r��backslashreplacer��2)6r� menu_specsrVr�rS�Tkr�withdrawr�rr6ZusetabsZ indentwidth�hasattrr�r'�sys_ps1rZprompt_last_line�promptr7Z configurer8�enter_callback�linefeed_callback�cancel_callback� eof_callbackr�toggle_debugger�toggle_jit_stack_viewer�view_restart_mark� restart_shellZSqueezerZsqueeze_current_text_eventr�� save_stdoutr�� save_stderrr�� save_stdinr�r*r�encoding�errorsrr��pydocZ plainpagerZpagerr�r$�historyr�)r3r;Zmsrjr7Zsqueezerr*r@r!r!r"r6^sn       zPyShell.__init__cCs tjdd�S)NT)Z shell_only)r Z GetExtensions)r3r!r!r"�get_standard_extension_names�sz$PyShell.get_standard_extension_namescCs|adS)N)r)r3�streamr!r!r"�set_warning_stream�szPyShell.set_warning_streamcCstS)N)r)r3r!r!r"�get_warning_stream�szPyShell.get_warning_streamcCsH|jr$tjdd|jd�|��dS|j��}|r<|��n|��dS)NzDon't debug nowz*You can only toggle the debugger when idle)rrF) r�rkrlr7�set_debugger_indicatorrSr��close_debugger� open_debugger)r3rZ�dbr!r!r"r7�s   zPyShell.toggle_debuggercCs|j��}|�d| �dS)Nz<>)rSr�Zsetvar)r3rIr!r!r"rF�s zPyShell.set_debugger_indicatorcCsdS)Nr!)r3rZr!r!r"r8�szPyShell.toggle_jit_stack_viewercCsh|j��}|r\|j�d�|��|jjr8t�|jj�|��|j� d�|j |_ |� �|� �dS)Nz [DEBUG OFF] )rSr�r�r�r�rZclose_remote_debuggerr�r�rr1r2r�rF)r3rIr!r!r"rG�s   zPyShell.close_debuggercCsX|jjrt�|jj|�}n t�|�}|j�|�|��d|j|_ |� �|� �dS)Nz [DEBUG ON] ) rSr�rZstart_remote_debuggerr ZDebuggerr�r�r1r2r�rF)r3Zdbg_guir!r!r"rH�s    zPyShell.open_debuggercCs|��d|_dS)zHelper for ModifiedInterpreterTN)r�r�)r3r!r!r"r�szPyShell.beginexecutingcCsd|_d|_|��dS)zHelper for ModifiedInterpreterFN)r�r"r�)r3r!r!r"r��szPyShell.endexecutingcCsD|jr&tjddd|jd�}|dkr&dS|��d|_d|_t�|�S)zExtend EditorWindow.close()zKill?z7Your program is still running! Do you want to kill it?�ok)r�rFZcancelT) r�rkZ askokcancelr7r�r"r�rr�)r3r�r!r!r"r��s z PyShell.closecCsV|��tr|j��|jt_|jt_|j t_ d|_d|_ d|j _ d|_t�|�dS)zEExtend EditorWindow._close(), shut down debugger and execution serverN)rGrrSr�r;r�r�r<r�r=r�r�r;rRrArrz)r3r!r!r"rz�s zPyShell._closecCsdS)z8Override EditorWindow method: never remove the colorizerTr!)r3rr!r!r"�ispythonsource szPyShell.ispythonsourcecCs|jS)N)� shell_title)r3r!r!r"� short_titleszPyShell.short_titlezHType "help", "copyright", "credits" or "license()" for more information.cCs�|j�dd�|��tr:d}|j��}|sF|��dSn d}tjt _|� dt j t j |j |f�|j��|��ddl}d|_dS) Nr�rVrGFz�==== No Subprocess ==== WARNING: Running IDLE without a Subprocess is deprecated and will be removed in a later version. See Help/IDLE Help for details. zPython %s on %s %s %srT)r7r�r�rrSr�r�r� displayhookr�r�version�platform� COPYRIGHTZ focus_forcer��tkinterZ _default_root)r3ZnosubZclientrRr!r!r"r�s"  z PyShell.begincCs|js dSd|_|j��dS)NT)�reading�_stop_readline_flagr��quit)r3r!r!r"r�,szPyShell.stop_readlinecCs�|j}zd|_|j��Wd||_X|jr4d|_dS|j�dd�}t|�dkrRd}|��|jrnd|_t snt �|j r~d|_ d}|S)NTFrGr�zend-1crra) rSr��mainlooprTr7�getrsr�r"rr�� endoffile)r3r.rr!r!r"�readline2s( zPyShell.readlinecCsdS)NTr!)r3r!r!r"�isattyIszPyShell.isattycCs�y|j�ddd�rdSWn YnX|jsR|jsR|��|j�d�|��dSd|_d|_ |jr�|jj r�|j� �r�|j� �n |j� �|jr�|j��dS)Nz sel.firstz!=zsel.lastzKeyboardInterrupt rFFT)r7r�r�rSr�rSrr�rXr"r�r�r�r�r�rU)r3rZr!r!r"r5Ls&      zPyShell.cancel_callbackcCsf|jr|jsdS|j�ddd�r0|j�ddd�s4dS|jsL|��|��nd|_d|_|j� �dS)Nr�z==rVzend-1cFTrF) r�rSr7r�r�r�r"rXr�rU)r3rZr!r!r"r6bs   zPyShell.eof_callbackcCs0|jr"|j�dd�|j�d�n |�|�dS)NrVrarF)rSr7rV�see�newline_and_indent_event)r3rZr!r!r"r4qs  zPyShell.linefeed_callbackcCs8|jr|jsdSy6|j�dd�}|rD|j�ddd�rD|�||�dSWn YnX|j�ddd��rV|j�d d�}|r�|j�dd|d �r�|�|j�|d |d �|�dS|j�d d�}|r�|j�d d |d �r�|�|j�|d |d �|�dS|j�dd�}|�r<|j�|d dd��r<|�|j�|d d �|�n|�|j�dd �|�dS|j�ddd��rv|j�dd�|j�dd�}|�r�|� ��s�|j� dd�|j�ddd��r�|� |�dS|j�dd�|j�r�|j� dd�|j� d�n |� |�|j�d dd�|j��|j�r,|j��n|��dS)Nz sel.firstzsel.lastz<=r�rFrVr�ziomark linestartr�rrzinsert lineendz>=r�zinsert linestartzend-1czend-1c linestartra)r�rSr7rWr��recallZ tag_prevrangeZ tag_nextranger��stripr�r\rVr[rNZupdate_idletasksr�rU�runit)r3rZ�sel�prev�next�indicesr�r!r!r"r3zsX      zPyShell.enter_callbackc Cs<t�dd|�}t�dd|�}|�d�}|j��z�|j�ddd�|j�dd �|j�d d�}|��� d �r�|� |�|j�d d�}|j� d|d � ��t |�d k�rt�d|d ��d �}t�d|��d �}xJ|d d�D]:}|�|��r||t |�d�}|j� dd|���q�WWd|j�d�|j��XdS)Nz^\s*\nrGz\n\s*$rar`z1.0ryrVzend-1czinsert linestart�:rrz ^([ \t]*))�re�subrr7Zundo_block_startr\r�rW�rstrip�endswithr\rVr^rs�search�grouprfr[Zundo_block_stop)r3r�rZrn�prefixZorig_base_indentZnew_base_indentrr!r!r"r]�s*     zPyShell.recallcCs�|j�dd�}t|�}x$|dkr:||ddkr:|d}qW|dkr\||ddkr\|d}x$|dkr�||ddkr�|d}q^W|d|�}|j�|�dS)Nr�zend-1crrz ra)r7rWrsrSr)r3rr�r!r!r"r_�s   z PyShell.runitcCsX|jjr|j��Sy tjWntjdd|jd�dSddlm }||j |j �dS)NzNo stack tracez@There is no stack trace yet. (sys.last_traceback is not defined))rr)� StackBrowser) rSr�r�r��last_tracebackrkrlr7Zidlelib.stackviewerrlrjr;)r3rZrlr!r!r"r�s    zPyShell.open_stack_viewercCs|j�d�|j�d�dS)Nr�r�)r7r[)r3rZr!r!r"r9�s zPyShell.view_restart_markcCs|jjdd�dS)z&Callback for Run/Restart Shell Cntl-F6T)r�N)rSr�)r3rZr!r!r"r:�szPyShell.restart_shellcCs:|��|j�|j�|j�dd�|��|j��dS)NrVzend-1c) r�r�rr2r7r��set_line_and_columnrAZ reset_undo)r3r!r!r"r��s zPyShell.showpromptcCsP|jjj}t|ddd�}d�|�|��}|�d�s:|d7}|jj� d|d�dS)Nr&T)r��tabsizeZ expand_tabsraziomark linestartr�) rSr�r�r r?r)rhZperZbottomrV)r3rr��wrapperZ wrapped_msgr!r!r"� show_warning�s   zPyShell.show_warningcCsb|j�dd�}|jr |j�|�|j�d�dkr>|j�dd�|j�dd�|��|j��dS)Nr�zend-1czend-2cra) r7rWrAZstorerVr�rnZctipZremove_calltip_window)r3rr!r!r"r�s zPyShell.resetoutputr!cCsXy0|j�dd�t�|||d�}|j�dd�Wn�YnX|jrTd|_tsTt�|S)Nr��rightr�F)r7r�rrr"rr�)r3r�r��countr!r!r"rsz PyShell.writecs8y|j�ddd�rdSWntk r,dSXt���S)Nz sel.firstr�r��disabled)r7r�r��superrD)r3)� __class__r!r"rDs zPyShell.rmenu_check_cutcs|j�ddd�rdSt���S)NrVr�r�rt)r7r�rurE)r3)rvr!r"rE&szPyShell.rmenu_check_paste)N)N)N)N)N)N)N)r!)9r{r|r}r rLr�r r�rr-rrZallow_line_numbersZidlelib.historyr$r6rBrSr�r"rXr�rTrDrEr7rFr8rGrHrr�r�rzrKrMrQr�r�rYrZr5r6r4r3r]r_rr9r:r�rqr�rrDrE� __classcell__r!r!)rvr"r�Bsl  C      ?     r�c Cs6|jdkr2x&dD]}|�|dd|�|d��qWdS)z6Make paste replace selection on x11. See issue #5124.Zx11)ZTextZEntryZSpinboxz <>z%catch {%W delete sel.first sel.last} N)Z_windowingsystemZ bind_class)rj�clsr!r!r"� fix_x11_paste,s  rya� 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 snddl}ddlm}ddlm}ddlm}td�dad}d}d}d}d}d} y|�tj dd�d�\} } WnD|j k r�} z$t d | t ftj d �t�d �Wdd} ~ XYnXx�| D]�\} }| d kr�|}d}| d kr�d}d}| dkr�d}| dk�r tj�t �t��| dk�rd}| dk�r6t dtj d �da| dk�rj|}tj�|��rTnt d|�t��d}| dk�r|d} d}| dkr�|t_d}q�W| �r�| ddk�r�tj��}d}x0tttj��D]}tj�tj|�tj|<�q�W| �r| ddk�rdg| dd�t_ n�|�r$d g| t_ n�|�r8|g| t_ n�| �r�d}g}x | D]}|�tj�|���qLWxX|D],}tj�|�}|tjk�rntj�d|��qnWn"t��}|tjk�r�tj�d|�tj ddddd�}|�p�|}|�p�| }t�r�|�s�t!�t"dd�a#t#�$�dd l%m&}|t#�tj�'tj�t(�d!��|�d"k�r`tj�'�d#�}t#j)|d$�nV|�*��s�t+d%k�r~d&�d'}nd(�d)}��fd*d+�|D�}d,d+�|D�}t#j,d0|��t-t#�t.t#�t/t#�a0|�1t#t0�|�r,|�s,|�s,x0| dd�D] }t0�2|�dk�r�| �3|��q�W| �s,t0�4�|�rbt0�5�}|�sDdS|�*��rht0j6�rh|j7�8�nt0j9}|�rv|�:�| �r�tj;�|�|�s�|�r |j=�?d/tj f�|�r�|j=�@|�n|�rB|j=�A|�|j=�>|�n8|�rB|�Bt#�}|�r*|�C|�|�D�}|�rB|�C|�xt0jE�rXt#�F��qDWt#�G�td�dS)1Nr)�system)�testing)�macosxTFrz c:deihnr:st:z Error: %s %s)rrvz-cz-dz-ez-hz-iz-nz: Warning: running IDLE without a subprocess is deprecated.z-rzNo script file: z-sz-t�-rGr�r�zeditor-on-startupr�)r�ZIdle)Z className)rZIconsZWindowszidle.ico)r�g333333!@z.png)�� �0�z.gif)r~rr�cs"g|]}tj��d|�f��qS)z idle_%d%s)r=r>r?)r��size)�ext�icondirr!r"r��szmain..cSsg|]}tt|d��qS))Zmasterr)Z PhotoImagerj)r��iconfiler!r!r"r��sZ IDLESTARTUPZ PYTHONSTARTUPzbif 1: import sys as _sys _sys.argv = %r del _sys )T)H�getoptrPrzr�r{r|r'rr��argv�errorr�� usage_msgr��exitr�rr=r>rqr�rLr�rrwrsrrQ�dirnamerV�getcwdr r�Z NoDefaultRootr.rjr/� idlelib.runrr?�__file__Z wm_iconbitmapZisAquaTk� TkVersionZ wm_iconphotorryr�r;ZsetupApprdr[�newr<�dictr��lowerrRrH�environrWrSrr�rrZtkVersionWarningrqZpreferTabsPreferenceWarningZ inversedictrVZdestroy)r�rzr{r|Z enable_shellZ enable_editrT�cmdZscriptZstartupZoptsrCr�o�ar�Zpathxr�dirZ edit_startrr�ZsizesZ iconfilesZiconsr%ZtkversionwarningZprefer_tabs_preference_warningr!)r�r�r"r�ms                                      r�F)NN)Pr�r{r�rR� ImportErrorr�r�r!rPZctypesZPROCESS_SYSTEM_DPI_AWAREZOleDLLZSetProcessDpiAwarenessrrZtkinter.messageboxZ messageboxrkr�r.rjr/r�rrlr rr)r=Zos.pathr rer�r��textwrapr r�r�rr%Zidlelib.colorizerr Zidlelib.configr r�r rZidlelib.editorrrZidlelib.filelistrZidlelib.outwinrrrrrZ idlelib.undorr�r�rr#r$r'� checkcacher0r1r�r�r�Z RPCClientr�r�r�r�ryr�r�r!r!r!r"�s�                  ?0m?6