
|Nc           @   sQ  d  d l  Z  d  d l Z  d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l	 Z	 d  d l
 Z
 d  d l Z d  d l m Z y d  d l TWn+ e k
 r e j d IJe j d  n Xd  d l Z d  d l m Z m 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 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% e j& e j' d Z( d Z) d Z* y d  d l+ m, Z, Wn e k
 rd Z, n Xe j a- y d  d l. Z. Wn e k
 rn. Xe/ e/ d  Z0 e0 e. _1 e/ d  Z2 e2 e. _3 e/ e j4 d  Z5 e5 e _4 d e f d     YZ6 d e f d     YZ7 d e f d     YZ8 d e f d      YZ9 d! e" j: f d"     YZ; d# e f d$     YZ< d% e f d&     YZ= d' e> f d(     YZ? d) Z@ d*   ZA eB d+ k rMe jC d+ e jC d% <eA   n  d S(,   iN(   t   InteractiveInterpreter(   t   *sK   ** IDLE can't import Tkinter.  Your Python may not be configured for Tk. **i   (   t   EditorWindowt   fixwordbreaks(   t   FileList(   t   ColorDelegator(   t   UndoDelegator(   t   OutputWindow(   t   idleConf(   t   idlever(   t   rpc(   t   Debugger(   t   RemoteDebugger(   t   macosxSupportt   _s	   127.0.0.1i    (   t   SIGTERMi   c      
   C   s\   | d  k r t } n  y/ | j t j |  | | | d | d |  Wn t k
 rW n Xd  S(   Nt   filet   line(   t   Nonet   warning_streamt   writet   warningst   formatwarningt   IOError(   t   messaget   categoryt   filenamet   linenoR   R   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   idle_showwarning:   s    	c         C   sy   d } | d | | f 7} | d k r; t j | |  } n  | j   } | r^ | d | 7} n  | d | j |  f 7} | S(   s   Format warnings the IDLE ways!   
Warning (from warnings module):
s     File "%s", line %s
s       %s
s   %s: %s
>>> N(   R   t	   linecachet   getlinet   stript   __name__(   R   R   R   R   R   t   s(    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   idle_formatwarningD   s    c         C   so   t  j } i  } xB t |  D]4 } | d  | d d k r | j |  | | <q q W| |   | j |  d S(   so  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.
    i   is   <>N(   R   t   cachet   listt   popt   update(   R   t   orig_checkcacheR#   t   savet   key(    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   extended_linecache_checkcacheQ   s    	
t   PyShellEditorWindowc           B   sz   e  Z d  Z d   Z d d g Z d   Z d d  Z d d  Z d	   Z	 d
   Z
 d   Z d   Z d   Z d   Z RS(   s6   Regular text edit window in IDLE, supports breakpointsc         G   s   g  |  _  t j |  |  |  j j d |  j  |  j j d |  j  |  j j d |  j j  t	 j
 j t j   d  |  _ |  j j r |  j   n  |  j j |  d  } |  j j |  d  S(   Ns   <<set-breakpoint-here>>s   <<clear-breakpoint-here>>s   <<open-python-shell>>s   breakpoints.lstc         S   s   | j    |    d  S(   N(   t   restore_file_breaks(   t   old_hookt   self(    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   filename_changed_hookv   s    
(   t   breakpointsR   t   __init__t   textt   bindt   set_breakpoint_heret   clear_breakpoint_heret   flistt
   open_shellt   ost   patht   joinR   t   GetUserCfgDirt   breakpointPatht   ioR   R,   t   filename_change_hookt   set_filename_change_hook(   R.   t   argsR/   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR1   k   s    	 	s   Set Breakpoints   <<set-breakpoint-here>>s   Clear Breakpoints   <<clear-breakpoint-here>>c         C   s   |  j  } |  j j } | j d d | d | d  y |  j j |  } Wn! t k
 rm |  j j |  n Xy& |  j j	 j
 j } | j | |  Wn n Xd  S(   Nt   BREAKs   %d.0i   (   R2   R=   R   t   tag_addR0   t   indext
   ValueErrort   appendR6   t   pyshellt   interpt   debuggerR4   (   R.   R   R2   R   t   it   debug(    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   set_breakpoint   s    	c         C   sU   |  j  } |  j j } | s) | j   d  St t | j d    } |  j |  d  S(   Nt   insert(   R2   R=   R   t   bellt   intt   floatRC   RK   (   R.   t   eventR2   R   R   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR4      s    	
c         C   s   |  j  } |  j j } | s) | j   d  St t | j d    } y |  j j |  Wn n X| j	 d d d  y& |  j
 j j j } | j | |  Wn n Xd  S(   NRL   RA   s   insert linestarts   insert lineend +1char(   R2   R=   R   RM   RN   RO   RC   R0   t   removet
   tag_removeR6   RF   RG   RH   R5   (   R.   RP   R2   R   R   RJ   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR5      s"    	
c         C   s   |  j  r~ |  j } |  j j } | s2 | j   d  Sg  |  _  | j d d t  y# |  j j j	 j
 } | j |  Wq~ q~ Xn  d  S(   NRA   s   1.0(   R0   R2   R=   R   RM   RR   t   ENDR6   RF   RG   RH   t   clear_file_breaks(   R.   R2   R   RJ   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRT      s    		
	c         C   s   |  j  } |  j j } y t |  j d  j   } Wn t k
 rJ g  } n Xt |  j d  } x1 | D]) } | j | d  sd | j |  qd qd W|  j	   |  j  } | r | j | d t
 |  d  n  | j   d S(   s#   Save breakpoints when file is savedt   rt   wt   =s   
N(   R0   R=   R   t   openR<   t	   readlinesR   t
   startswithR   t   update_breakpointst   strt   close(   R.   t   breaksR   t   linest   new_fileR   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   store_file_breaks   s    	

	"c         C   s   |  j  j   |  j j } | d  k r) d  St j j |  j  r t	 |  j d  j
   } x_ | D]T } | j | d  r] t | t |  d  } x | D] } |  j |  q Wq] q] Wn  d  S(   NRU   RW   i   (   R2   R&   R=   R   R   R8   R9   t   isfileR<   RX   RY   RZ   t   evalt   lenRK   (   R.   R   R_   R   t   breakpoint_linenumberst   breakpoint_linenumber(    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR,      s    c         C   s4   |  j  } | j d  } |  j |  } | |  _ d S(   s3   Retrieves all the breakpoints in the current windowRA   N(   R2   t
   tag_rangest   ranges_to_linenumbersR0   (   R.   R2   t   rangest   linenumber_list(    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR[      s    	c         C   s   g  } xz t  d t |  d  D]` } t t | |   } t t | | d   } x' | | k  r~ | j |  | d 7} qX Wq W| S(   Ni    i   i   (   t   rangeRd   RN   RO   RE   (   R.   Ri   R_   RC   R   t   end(    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRh      s    c         C   s   |  j    t j |   d S(   s7   Extend base method - clear breaks when module is closedN(   RT   R   t   _close(   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRm     s    
(   s   Set Breakpoints   <<set-breakpoint-here>>(   s   Clear Breakpoints   <<clear-breakpoint-here>>N(   R    t
   __module__t   __doc__R1   t   rmenu_specsRK   R   R4   R5   RT   Ra   R,   R[   Rh   Rm   (    (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR+   h   s   						'			t   PyShellFileListc           B   s&   e  Z d  Z e Z d Z d d  Z RS(   s8   Extend base class: IDLE supports a shell and breakpointsc         C   sQ   |  j  r |  j  j j   n. t |   |  _  |  j  rJ |  j  j   sJ d  Sn  |  j  S(   N(   RF   t   topt   wakeupt   PyShellt   beginR   (   R.   RP   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR7     s    		N(   R    Rn   Ro   R+   R   R   RF   R7   (    (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRq   
  s   t   ModifiedColorDelegatorc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s8   Extend base class: colorizer for the shell window itselfc         C   s   t  j |   |  j   d  S(   N(   R   R1   t   LoadTagDefs(   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR1   !  s    c         C   s7   |  j  d d d  |  j d d d  t j |   d  S(   Nt   TODOs   1.0t   iomarkt   SYNC(   RR   RB   R   t   recolorize_main(   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR{   %  s    c         C   s   t  j |   t j d d d  } |  j j i i d  d 6d  d 6d 6t j | d  d 6t j | d  d 6t j | d	  d	 6 d  S(
   Nt   maint   Themet   namet
   backgroundt
   foregroundt   stdint   stdoutt   stderrt   console(   R   Rw   R   t	   GetOptiont   tagdefsR&   R   t   GetHighlight(   R.   t   theme(    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRw   *  s    (   R    Rn   Ro   R1   R{   Rw   (    (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRv     s   		t   ModifiedUndoDelegatorc           B   s&   e  Z d  Z d d  Z d d  Z RS(   s;   Extend base class: forbid insert/delete before the I/O markc         C   s[   y- |  j  j | d d  r, |  j  j   d  SWn t k
 r@ n Xt j |  | | |  d  S(   Nt   <Ry   (   t   delegatet   compareRM   t   TclErrorR   RL   (   R.   RC   t   charst   tags(    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRL   7  s    c         C   sX   y- |  j  j | d d  r, |  j  j   d  SWn t k
 r@ n Xt j |  | |  d  S(   NR   Ry   (   R   R   RM   R   R   t   delete(   R.   t   index1t   index2(    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR   @  s    N(   R    Rn   Ro   R   RL   R   (    (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR   4  s   	t   MyRPCClientc           B   s   e  Z d    Z RS(   c         C   s
   t   d S(   s0   Override the base class - just re-raise EOFErrorN(   t   EOFError(   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt
   handle_EOFL  s    (   R    Rn   R   (    (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR   J  s   t   ModifiedInterpreterc           B   s:  e  Z d    Z d Z d Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d   Z d	   Z d Z d
   Z d Z d   Z d   Z d   Z d   Z d Z d   Z d d  Z d   Z d   Z d   Z d d  Z d   Z d   Z d   Z d   Z  d   Z! d   Z" d   Z# d   Z$ d   Z% RS(    c         C   sT   | |  _  t j d j } t j |  d | d  |  _ t |  _	 d  |  _
 t |  _ d  S(   Nt   __main__t   locals(   t	   tkconsolet   syst   modulest   __dict__R    R1   R   t   save_warnings_filterst   Falset
   restartingt   subprocess_arglistt   PORTt   port(   R.   R   R   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR1   S  s    				c         C   sL   |  j  d  k r! |  j   |  _  n  |  j  } t j t j t j |  |  _ d  S(   N(	   R   R   t   build_subprocess_arglistR8   t   spawnvt   P_NOWAITR   t
   executablet   rpcpid(   R.   R@   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   spawn_subprocess_  s    	c         C   s   |  j  d k s t d  g  t j D] } d | ^ q" } d d d k rX | j d  n  t j d d d	 d
 t d d } t d k r d | f } n d | f } t j	 d  d k r d t j
 k r d t j
 } n	 t j
 } | g | d | t |  j   g S(   Ni    s/   Socket should have been assigned a port number.s   -Wi   i   s   -QnewR|   t   Generals   delete-exitfunct   defaultt   typet   bools   idlelib.PyShells&   __import__('idlelib.run').run.main(%r)s   __import__('run').main(%r)i   t   wint    s   "%s"s   -c(   R   t   AssertionErrorR   t   warnoptionsRE   R   R   R   R    t   platformR   R\   (   R.   R!   RV   t	   del_exitft   commandt   decorated_exec(    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR   e  s     "	c         C   s  t  |  j f } x\ t d  D]@ } t j |  y t |  |  _ PWq t j k
 r[ } q Xq W|  j	   d  S|  j j j   d |  _ t d k r |  j j j t j t j d  n  |  j   |  j j j d  y |  j j   Wn! t j k
 r} |  j   d  SX|  j j d |  j  |  j j d |  j j  |  j j d |  j j  |  j j d |  j j  |  j j d	 t  |  j j d
 |   |  j   |  j   |  j S(   Ni   i   i    i
   R   R   R   R6   R   RG   (   t   HOSTR   Rk   t   timet   sleepR   t   rpccltt   sockett   errort   display_port_binding_errorR   t   listening_sockt   getsocknameR   t
   setsockoptt
   SOL_SOCKETt   SO_REUSEADDRR   t
   settimeoutt   acceptt   timeoutt   display_no_subprocess_errort   registerR   R   R   R6   R   t   transfer_patht   poll_subprocess(   R.   t   addrRI   t   err(    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   start_subprocess{  s<    




c         C   s  |  j  r |  j St |  _  |  j   } | rL y t j |  j  WqL qL Xn  |  j j   |  j   |  j } | j	 } t
 | _	 |  j   y |  j j   Wn! t j k
 r } |  j   d  SX|  j   | j j d d  | r | j d  | j   n  t | j  d d d } | j | d |  | j j d d  | j j d d	  | j   | rt j |  j  } | j   n  t
 |  _  |  j S(
   NRy   s   end-1cs   
i   i   RW   s	    RESTART t   restartt   left(   R   R   t   Truet   getdebuggerR   t   close_subprocess_debuggerR]   t   unix_terminateR   t	   executingR   R   R   R   R   R   R   R   R2   R   R   t
   showpromptRN   t   widtht   mark_sett   mark_gravityt   restart_subprocess_debuggert   load_breakpoints(   R.   RJ   R   t   was_executingR   t   halfbart   gui(    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   restart_subprocess  sF    		
			



	c         C   s   |  j  j d d d i   d  S(   Nt   exect   interrupt_the_server(    (   R   t
   remotecall(   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   __request_interrupt  s    c         C   s   t  j d |  j  j   d  S(   Nt   target(   t	   threadingt   Threadt'   _ModifiedInterpreter__request_interruptt   start(   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   interrupt_subprocess  s    c         C   sH   y |  j  j   Wn t k
 r$ n X|  j   t |  j _ d  |  _  d  S(   N(   R   R]   t   AttributeErrorR   R   R   R   R   (   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   kill_subprocess  s    
c         C   sn   t  t d  rj y t j |  j t  Wn t k
 r: d SXy t j |  j d  Wqj t k
 rf d SXn  d S(   s;   UNIX: make sure subprocess is terminated and collect statust   killNi    (   t   hasattrR8   R   R   R   t   OSErrort   waitpid(   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR     s    c         C   s   |  j  d t j f  d  S(   NsR   if 1:
        import sys as _sys
        _sys.path = %r
        del _sys
        
(   t
   runcommandR   R9   (   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR     s    c         C   s  |  j  } | d  k r d  Sy | j |  j d d } Wn: t t t f k
 rq |  j j r^ d  Sd  } |  j	   n X| rb|  j j
   d  |  _ | \ } } |  j j } | d k r | d  k	 r:| t |  IJq:nf | d k r|  j j d  r:|  j   q:n8 | d k r:d } t j | I| IJ| | I| IJn  y |  j j   Wqbt k
 r^qbXn  |  j j s|  j j j |  j j |  j  n  d  S(   Nt   waitg?t   OKt	   EXCEPTIONs   <<toggle-jit-stack-viewer>>t   ERRORs/   PyShell.ModifiedInterpreter: Subprocess ERROR:
(   R   R   t   pollresponset
   active_seqR   R   t   KeyboardInterruptR   t   closingR   t   resetoutputR   t   reprt   getvart   remote_stack_viewerR   t
   __stderr__t   endexecutingR   R2   t   aftert   pollintervalR   (   R.   t   cltt   responset   howt   whatR   t   errmsg(    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR     s@    		c         C   s   | |  _  d  S(   N(   RH   (   R.   RH   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   setdebugger  s    c         C   s   |  j  S(   N(   RH   (   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR   "  s    c         C   s   |  j  j j d |  j  d S(   s  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   R2   R   R   (   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   open_remote_stack_viewer%  s    
c         C   s  d d l  m } |  j j d d d i   } | d  k rK |  j j j   d  S| j |  j |  } d d l	 m
 } m } t |  j j  } t j d d d	  } t j | d
  d } | | d | d d }	 |	 j j d d d d  | |	 j d  |  }
 |
 j   d  S(   Ni(   t   RemoteObjectBrowserR   t   stackviewerR6   (   t   ScrolledCanvast   TreeNodeR|   R}   R~   t   normalR   t   bgt   highlightthicknessi    t   expandi   t   fillt   both(   s   flist(   t   idlelibR  R   t   remotequeueR   R   t   rootRM   t   StubObjectTreeItemt   idlelib.TreeWidgetR  R  t   ToplevelR   R   R   t   framet   packt   canvasR  (   R.   R  t   oidt   itemR  R  Rr   R   R   t   sct   node(    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR   2  s    i    c         C   s#   |  j  |  } |  j | |  d S(   s1   Like runsource() but assumes complete exec sourceN(   t   stuffsourcet   execfile(   R.   t   sourceR   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt
   execsourceE  s    c         C   s   | d k r$ t | d  j   } n  y t | | d  } Wna t t f k
 r |  j j   |  j j } | d IJ| d IJt	 j
 |  |  |  j j   n X|  j |  d S(   s   Execute an existing fileRU   R   s    *** Error in script or command!
s"   Traceback (most recent call last):N(   R   RX   t   readt   compilet   OverflowErrort   SyntaxErrorR   R   R   R    t   showsyntaxerrorR   t   runcode(   R.   R   R  t   codet   tkerr(    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR  J  s    

c         C   s   |  j  |  } d |  _ t j |  _ t j d d d t  t | t j	  r d d l
 m } y | j | j  } Wq t k
 r |  j j   |  j d  d SXn  z t j |  | |  SWd |  j d k	 r |  j t j (d |  _ n  Xd S(	   sB   Extend base class method: Stuff the source in the line cache firsti    t   actionR   R   i(   t	   IOBindings    Unsupported characters in input
N(   R  t   moreR   t   filtersR   t   filterwarningst   SyntaxWarningt
   isinstancet   typest   UnicodeTypeR  R(  t   encodet   encodingt   UnicodeErrorR   R   R   R    t	   runsourceR   (   R.   R  R   R(  (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR3  Z  s"    	c         C   sS   d |  j  } |  j  d |  _  | j d  } t |  d d | | f t j | <| S(   s"   Stuff source in the filename caches   <pyshell#%d>i   s   
i    (   t   gidt   splitRd   R   R#   (   R.   R  R   R_   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR  q  s
    #c         C   s   |  j  d | f  d S(   s>   Prepend sys.path with file's directory if not already includeds(  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   (   R.   R   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   prepend_syspathy  s    c   
      C   s  |  j  j } |  j   } | r | \ } } } } | d k rM d | d } n d | d | d f } | j d |  | j |  | j |  }	 |	 r |	 t k r | j d | d |  n  |  j  j   |  j d t	 |   n |  j  j   t
 j |  |  |  j  j   d S(   s   Extend base class method: Add Colorizing

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

        i   s   iomark + %d charss&   iomark linestart + %d lines + %d charsR   s
    wordstarts   SyntaxError: %s
N(   R   R2   t   unpackerrorRB   t   seet   gett
   IDENTCHARSR   R   R\   R    R#  R   (
   R.   R   R2   t   stufft   msgR   t   offsetR   t   post   char(    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR#    s$    c   
      C   s   t  j   \ } } } | t k } | re y+ | \ } \ } } } }	 | sQ d } n  Wqe d } qe Xn  | r{ | | | |	 f Sd  Sd  S(   Ni    (   R   t   exc_infoR"  R   (
   R.   R   t   valuet   tbt   okR<  t   dummy_filenameR   R=  R   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR7    s    c         C   sJ   |  j  j   |  j   t j |   |  j  j d  rF |  j  j   n  d S(   s1   Extend base class method to reset output properlys   <<toggle-jit-stack-viewer>>N(   R   R   t   checklinecacheR    t   showtracebackR   t   open_stack_viewer(   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRF    s
    
c         C   sF   t  j } x6 | j   D]( } | d  | d d k r | | =q q Wd  S(   Ni   is   <>(   R   R#   t   keys(   R.   t   cR)   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRE    s    	c         B   sQ   |  j  j r |  j   d S|  j rB |  j j d d | f i   n | |  j Ud S(   s*   Run the code without invoking the debuggeri    R   R$  i   (   R   R   t   display_executing_dialogR   R  R   (   R.   R%  (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR     s    
	c         B   s  |  j  j r |  j j   n  |  j   |  j d
 k	 rN |  j e j (d
 |  _ n  |  j	 } z;yr |  j  j
   | r |  j d
 k	 r |  j j d d | f i   |  _ n' | r | j | |  j  n | |  j UWn e k
 r%|  j  j se j d d d d d |  j  j r  q"|  j   q  nl e rX|  j  j d IJ|  j   |  j  j   q|  j  j re |  j  _ |  j  j d	 IJq|  j   n XWd
 e sy |  j  j   Wqe k
 rqXn  Xd
 S(   s   Override base class methodR   R$  s   Exit?s   Do you want to exit altogether?R   t   yest   masters    IDLE internal error in runcode()R   N(   R   R   RG   R   RE  R   R   R   R*  RH   t   beginexecutingR   t
   asyncqueueR   t   runR   t
   SystemExitR   t   tkMessageBoxt   askyesnoR2   RF  t   use_subprocessR   R   t   canceledR   R   (   R.   R%  RH   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR$    sR    
	 

c         C   s   |  j  j j |  d S(   s   Override base class methodN(   R   R   R   (   R.   R!   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR     s    c         C   s    t  j d d d |  j j d  S(   Ns   Port Binding ErrorsA  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.RL  (   RQ  t	   showerrorR   R2   (   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR     s    c         C   s    t  j d d d |  j j d  S(   Ns   Subprocess Startup Errors   IDLE's subprocess didn't make connection.  Either IDLE can't start a subprocess or personal firewall software is blocking the connection.RL  (   RQ  RU  R   R2   (   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR   
  s    c         C   s    t  j d d d |  j j d  S(   Ns   Already executingsY   The Python Shell window is already executing a command; please wait until it is finished.RL  (   RQ  RU  R   R2   (   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRJ    s    N(&   R    Rn   R1   R   R   R   R   R   R   R   R   R   R   R   R   R   R   RH   R  R   R  R   R4  R  R  R3  R  R6  R#  R7  RF  RE  R   R$  R   R   R   RJ  (    (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR   Q  sF   					*	,							&													1			Rt   c           B   s  e  Z d  Z e Z e Z d2 d3 d4 d5 d6 d7 g Z e j	   rP e d =d8 e d <n  d d l
 m Z d9 d  Z d   Z e Z e Z e Z e Z e Z d   Z d   Z d9 d  Z d   Z d9 d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z  d    Z! d!   Z" d" Z# d#   Z$ d$   Z% d%   Z& d9 d&  Z' d'   Z( d(   Z) d)   Z* d*   Z+ d+   Z, d9 d,  Z- d9 d-  Z. d9 d.  Z/ d/   Z0 d0   Z1 d: d1  Z2 RS(;   s   Python ShellR   t   _Filet   editt   _EditRJ   t   _Debugt   optionst   _Optionst   windowst   _Windowst   helpt   _Helpit   _Windowii(   t   Historyc         C   sF  t  r9 |  j } | d d d k r9 | j d d  q9 n  t |   |  _ | d  k r t   } t |  | j   t	 |  } n  t
 j |  | d  d   t |  _ d |  _ t |  _ |  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  r~| j d |  j  | j d |  j  n  t j |  _ t j |  _  t j! |  _" d d l# m$ } t% |  d | j&  |  _ t% |  d | j&  |  _ t% |  d | j&  |  _' t  s$|  j t _ |  j t _ |  t _! n  |  j( |  j  |  _) d |  _* d  S(   Ni   i    t   shellt   She_lli   t   wrapR?  s   <<newline-and-indent>>s   <<plain-newline-and-indent>>s   <<interrupt-execution>>s   <<end-of-file>>s   <<open-stack-viewer>>s   <<toggle-debugger>>s   <<toggle-jit-stack-viewer>>s   <<view-restart>>s   <<restart-shell>>i(   R(  R   R   R   i2   (   s   shellRc  (+   RS  t
   menu_specsRL   R   RG   R   t   TkR   t   withdrawRq   R   R1   R   t   usetabst   indentwidtht   context_use_ps1R2   t	   configureR3   t   enter_callbackt   linefeed_callbackt   cancel_callbackt   eof_callbackRG  t   toggle_debuggert   toggle_jit_stack_viewert   view_restart_markt   restart_shellR   R   t   save_stdoutR   t   save_stderrR   t
   save_stdinR  R(  t
   PseudoFileR1  R   Ra  t   historyR   (   R.   R6   t   msR  R2   R(  (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR1   4  sN    		

				c         C   s   t  j d t  S(   Nt
   shell_only(   R   t   GetExtensionsR   (   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   get_standard_extension_namese  s    c         C   s
   | a  d  S(   N(   R   (   R.   t   stream(    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   set_warning_streamn  s    c         C   s   t  S(   N(   R   (   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   get_warning_streamr  s    c         C   s`   |  j  r0 t j d d d |  j |  j   d S|  j j   } | rR |  j   n
 |  j   d  S(   Ns   Don't debug nows*   You can only toggle the debugger when idleRL  t   break(	   R   RQ  RU  R2   t   set_debugger_indicatorRG   R   t   close_debuggert   open_debugger(   R.   RP   t   db(    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRp  u  s    		

c         C   s%   |  j  j   } |  j d |  d  S(   Ns   <<toggle-debugger>>(   RG   R   t   setvar(   R.   R  (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR    s    c         C   s   d  S(   N(    (   R.   RP   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRq    s    c         C   s   |  j  j   } | r |  j  j d   | j   |  j  j rQ t j |  j  j  n  |  j   |  j	 j
 d  d t _ |  j   n  |  j   d  S(   Ns   [DEBUG OFF]
s   >>> (   RG   R   R  R   R]   R   R   t   close_remote_debuggerR   R   R   R   t   ps1R   R  (   R.   R  (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR    s    

	c         C   sq   |  j  j r' t j |  j  j |   } n t j |   } |  j  j |  | j   d t _ |  j	   |  j
   d  S(   Ns   [DEBUG ON]
>>> (   RG   R   R   t   start_remote_debuggerR   R  R   R   R  R   R  (   R.   t   dbg_gui(    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR    s    
	
c         C   s   |  j    d |  _ d S(   s   Helper for ModifiedInterpreteri   N(   R   R   (   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRM    s    
c         C   s    d |  _  d |  _ |  j   d S(   s   Helper for ModifiedInterpreteri    N(   R   RT  R   (   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR     s    		c         C   s   |  j  r= t j d d d d d |  j } | t k r= d Sn  |  j rV |  j j   n  t |  _	 t |  _
 |  j j d |  j |  j  d S(	   s   Extend EditorWindow.close()s   Kill?s6   The program is still running!
 Do you want to kill it?R   RC  t   parentt   canceli   N(   R   RQ  t   askokcancelR2   R   t   readingRr   t   quitR   RT  R   R   R   t   close2(   R.   R   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR]     s    				c         C   s   t  j |   S(   N(   R   R]   (   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR    s    c         C   s|   |  j    t r  |  j j   n  |  j t _ |  j t _ |  j	 t _
 d |  _ d |  _ d |  j _ d |  _ t j |   d S(   sE   Extend EditorWindow._close(), shut down debugger and execution serverN(   R  RS  RG   R   Rt  R   R   Ru  R   Rv  R   R   R   R6   RF   Rx  R   Rm   (   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRm     s    
			c         C   s   t  S(   s8   Override EditorWindow method: never remove the colorizer(   R   (   R.   R   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   ispythonsource  s    c         C   s   |  j  S(   N(   t   shell_title(   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   short_title  s    s@   Type "copyright", "credits" or "license()" for more information.c         C   s   |  j    t r< d } |  j j   } | sB |  j   t Sn d } |  j d d t j t j	 |  j
 | f  |  j   d d  l } d  | _ t S(   Nt    s   ==== No Subprocess ====s1   ActivePython 2.7.2.5 (ActiveState Software Inc.) s   based on
Python %s on %s
%s
%si(   R   RS  RG   R   R]   R   R   R   t   versionR   t	   COPYRIGHTR   t   TkinterR   t   _default_rootR   (   R.   t   nosubt   clientR  (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRu     s     


	c         C   s   |  j  } z d |  _  |  j j   Wd  | |  _  X|  j j d d  } t |  d k r` d } n  t | t  r d d l m	 } y | j
 | j  } Wq t k
 r q Xn  |  j   |  j r d |  _ t s t  q n  |  j r d |  _ d } n  | S(	   Ni   Ry   s   end-1ci    s   
i(   R(  R  (   R  Rr   t   mainloopR2   R9  Rd   R-  t   unicodeR  R(  R0  R1  R2  R   RT  RS  R   t	   endoffile(   R.   R(   R   R(  (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   readline  s.    		
	
					c         C   s   t  S(   N(   R   (   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   isatty	  s    c         C   s   y  |  j  j d d d  r d  SWn n X|  j p9 |  j sd |  j   |  j j d  |  j   d Sd |  _ d |  _	 |  j r |  j j
 r |  j j   r |  j j   q |  j j   n  |  j r |  j j   n  d S(   Ns	   sel.firsts   !=s   sel.lasts   KeyboardInterrupt
R  i    i   (   R2   R   R   R  R   RG   R   R   R  RT  R   R   R   R   Rr   R  (   R.   RP   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRn    s&    

			c         C   s   |  j  r |  j r d  S|  j j d d d  oD |  j j d d d  sK d  S|  j  sk |  j   |  j   n d |  _ d |  _ |  j j	   d S(   NRy   s   ==RL   s   end-1ci    i   R  (
   R   R  R2   R   R   R]   RT  R  Rr   R  (   R.   RP   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRo  "  s    	
		c         C   s@   |  j  r/ |  j j d d  |  j j d  n |  j |  d S(   NRL   s   
R  (   R  R2   RL   R8  t   newline_and_indent_event(   R.   RP   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRm  1  s
    	c      	   C   s  |  j  r |  j r d  SyN |  j j d d  } | rd |  j j d d d  rd |  j | |  d Sn  Wn n X|  j j d d d  r|  j j d	 d  } | r |  j j d d | d
  r |  j |  j j | d | d
  |  d S|  j j d	 d  } | rK|  j j d d | d  rK|  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  r|  j j d d  n  |  j j d d  } | r7| j	   r7|  j j
 d d  n  |  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 r|  j j   n
 |  j   d S(   Ns	   sel.firsts   sel.lasts   <=Ry   R  RL   R   s   iomark linestartR   i   i    s   insert lineends   >=R   s   insert linestarts   end-1cs   end-1c linestarts   
(   R   R  R2   R9  R   t   recallt   tag_prevranget   tag_nextrangeR   R   R   R  RL   R8  RB   t   update_idletasksRr   R  t   runit(   R.   RP   t   selt   prevt   nextt   indicesR!   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRl  :  sX    "'"'&		
c         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  } n  |  j j d | d j    t |  d k rt  j d | d  j d  } t  j d |  j d  } xX | d D]I } | j |  ra| | t |  } n  |  j j d d | j    q5Wn  Wd  |  j j d  |  j j   Xd  S(   Ns   ^\s*\nR  s   \n\s*$s   
R  s   1.0Rl   RL   s   end-1cs   insert linestartt   :i    i   s	   ^([ \t]*)(   t   ret   subR5  R2   t   undo_block_startRR   R   R9  t   rstript   endswithR  RL   R   Rd   t   searcht   groupRZ   R8  t   undo_block_stop(   R.   R!   RP   R_   t   prefixt   orig_base_indentt   new_base_indentR   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR  y  s*    (c         C   s   |  j  j d d  } t |  } x. | d k rQ | | d d k rQ | d } q$ W| d k r | | d d k r | d } n  x. | d k r | | d d k r | d } q W| |  } |  j j |  } d  S(   NRy   s   end-1ci    i   s    	s   
(   R2   R9  Rd   RG   R3  (   R.   R   RI   R)  (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR    s    # #
c         C   sq   |  j  j r |  j  j   Sy t j Wn! t j d d d |  j d  SXd d l m	 } | |  j
 |  j  } d  S(   Ns   No stack traces@   There is no stack trace yet.
(sys.last_traceback is not defined)RL  i(   t   StackBrowser(   RG   R   R   R   t   last_tracebackRQ  RU  R2   t   idlelib.StackViewerR  R  R6   (   R.   RP   R  t   sv(    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRG    s    	
c         C   s$   |  j  j d  |  j  j d  d  S(   NRy   R   (   R2   R8  (   R.   RP   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRr    s    c         C   s   |  j  j   d  S(   N(   RG   R   (   R.   RP   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRs    s    c         C   sk   |  j    y t t j  } Wn d } n X|  j j |  |  j j d d  |  j   |  j	 j
   d  S(   NR  RL   s   end-1c(   R   R\   R   R  R   R   R2   R   t   set_line_and_columnR=   t
   reset_undo(   R.   R!   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR     s    


c         C   s   |  j  j d d  } |  j r1 |  j j |  n  |  j  j d  d k r_ |  j  j d d  n  |  j  j d d  |  j   d t j _	 d  S(   NRy   s   end-1cs   end-2cs   
i    (
   R2   R9  Rx  t   history_storeRL   R   R  R   R   t	   softspace(   R.   R  (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR     s    	
c         C   sr   y@ |  j  j d d  t j |  | | d  |  j  j d d  Wn n X|  j rn d |  _ t sn t  qn n  d  S(   NRy   t   rightR   i    (   R2   R   R   R   RT  RS  R   (   R.   R!   R   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR     s    		(   s   fileRV  (   RW  RX  (   s   debugRY  (   RZ  R[  (   R\  R]  (   s   helpR_  (   R\  R`  N(    (3   R    Rn   R  Rv   R   R   R   Re  R   t   runningAsOSXAppt   idlelib.IdleHistoryRa  R   R1   R|  R   R  R   RT  R  R   R~  R  Rp  R  Rq  R  R  RM  R   R]   R  Rm   R  R  R  Ru   R  R  Rn  Ro  Rm  Rl  R  R  RG  Rr  Rs  R   R   R   (    (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRt     sd   	1																				?				
Rw  c           B   s8   e  Z d d   Z d   Z d   Z d   Z d   Z RS(   c         C   s(   | |  _  | |  _ d |  _ | |  _ d  S(   Ni    (   Rb  R   R  R1  (   R.   Rb  R   R1  (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR1     s    			c         C   s   |  j  j | |  j  d  S(   N(   Rb  R   R   (   R.   R!   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR     s    c         C   s"   x | D] } |  j  |  q Wd  S(   N(   R   (   R.   R_   R   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt
   writelines  s    c         C   s   d  S(   N(    (   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   flush  s    c         C   s   t  S(   N(   R   (   R.   (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR    s    N(   R    Rn   R   R1   R   R  R  R  (    (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyRw    s
   			s  
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 (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          C   s  t  a t  }  t } t } d  } d  } t } y# t j t j d d  \ } } WnM t j k
 r } t j j	 d t
 |   t j j	 t  t j d  n Xx4| D],\ }	 }
 |	 d k r |
 } t  }  n  |	 d k r t  } t  }  n  |	 d k rt  } t }  n  |	 d k r*t j j	 t  t j   n  |	 d	 k r?t  }  n  |	 d
 k rTt a n  |	 d k r|
 } t j j |  r{n d G| GHt j   t  }  n  |	 d k rt  } t  }  n  |	 d k r |
 t _ t  }  q q W| r| d d k rt j j   } t  }  n  x= t t t j   D]& } t j j t j |  t j | <qW| ro| d d k rod g | d t _ n | rd g | t _ n | r| g | t _ n | r(t  } g  } x' | D] } | j t j j |   qWxy | D]= } t j j |  } | t j k rt j j d |  qqWn1 t j   } | t j k rYt j j d |  n  t j d d d d d } | p}| } t d d  a t  t  t j!   t" t  a# t$ j% t t#  | r| p| sx | D] } t# j& |  qW| st# j'   qqn  |  rLt# j(   } | s$d  St$ j)   rLt# j* rL| j+ j,   qLn  t# j- } | rh| j.   n  | rt j/ j0 d  pt j/ j0 d  } | rt j j |  r| j1 j2 |  qn  | r| s| r1| j1 j3 d t j f  | r| j1 j4 |  q1| r1| j1 j5 |  | j1 j2 |  q1n  t$ j6 t  } | rk| j1 j3 d j7 d | d f   n  t j8   t j9   d  S(   Ni   s   c:deihnr:st:s
   Error: %s
i   s   -cs   -ds   -es   -hs   -is   -ns   -rs   No script file: s   -ss   -ti    t   -R  R|   R   s   editor-on-startupR   R   t	   classNamet   Idlet   IDLESTARTUPt   PYTHONSTARTUPsb   if 1:
            import sys as _sys
            _sys.argv = %r
            del _sys
            
s   print('s   ')(:   R   RS  R   R   t   getoptR   t   argvR   R   R   R\   t	   usage_msgt   exitR   R8   R9   Rb   Rt   R  R   R  Rk   Rd   t   abspathRE   t   dirnameRL   t   getcwdR   R   Rf  R  R   Rg  Rq   R6   R   t   setupAppRX   t   newR7   R  t   dictRr   t   lowerRF   R  t   environR9  RG   R  R   R  R6  t   tkVersionWarningR:   R  t   destroy(   t   enable_shellt   enable_editRJ   t   cmdt   scriptt   startupt   optsR@   R<  t   ot   aRI   t   pathxR   t   dirt
   edit_startRb  t   tkversionwarning(    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyR|   "  s    #						
				$

		%
R   (D   R8   t   os.pathR   t   stringR  R  R   R   R   t	   tracebackR.  R   R%  R    R  t   ImportErrorR   R  RQ  t   idlelib.EditorWindowR   R   t   idlelib.FileListR   t   idlelib.ColorDelegatorR   t   idlelib.UndoDelegatorR   t   idlelib.OutputWindowR   t   idlelib.configHandlerR   R  R	   R
   R   R   R   t   ascii_letterst   digitsR:  R   R   t   signalR   R   R   R   R   t   showwarningR"   R   t
   checkcacheR*   R+   Rq   Rv   R   t	   RPCClientR   R   Rt   t   objectRw  R  R|   R    R   (    (    (    s$   C:\RCS\Python\lib\idlelib\PyShell.pyt   <module>   s~   
				  I	