;
Ðâ"Ic            
   @   s©   d  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	 Z	 Gd „  d ƒ Z
 d „  Z d „  Z d	 „  Z e d
 k o e ƒ  n d S(   u  CallTips.py - An IDLE Extension to Jog Your Memory

Call Tips are floating windows which display function, class, and method
parameter and docstring information when you type an opening parenthesis, and
which disappear when you type a closing parenthesis.

i    N(   u   CallTipWindow(   u   HyperParserc             B   s€   |  Ee  Z d  d g f g Z d d „ Z d „  Z d „  Z d d „ Z d „  Z d „  Z	 d	 „  Z
 d
 „  Z d „  Z d „  Z d S(   u   editu   Show call tipu   <<force-open-calltip>>c             C   sH   | d  k o d  |  _ n+ | |  _ | j |  _ d  |  _ |  j |  _ d  S(   N(   u   Noneu   editwinu   textu   active_calltipu   _make_tk_calltip_windowu   _calltip_window(   u   selfu   editwin(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   __init__   s    		c             C   s   d  |  _ d  S(   N(   u   Noneu   _calltip_window(   u   self(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   close#   s    c             C   s   t  j |  j ƒ S(   N(   u   CallTipWindowu   CallTipu   text(   u   self(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   _make_tk_calltip_window&   s    c             C   s(   |  j  o |  j  j ƒ  d  |  _  n d  S(   N(   u   active_calltipu   hidetipu   None(   u   selfu   event(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   _remove_calltip_window*   s    
c             C   s   |  j  d ƒ d S(   u9   The user selected the menu entry or hotkey, open the tip.NT(   u   open_calltipu   True(   u   selfu   event(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   force_open_calltip_event/   s    c             C   s   |  j  d ƒ d S(   uª   Happens when it would be nice to open a CallTip, but not really
        necessary, for example after an opening bracket, so function calls
        won't be made.
        NF(   u   open_calltipu   False(   u   selfu   event(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   try_open_calltip_event3   s    c             C   s/   |  j  o! |  j  j ƒ  o |  j d ƒ n d  S(   NF(   u   active_calltipu	   is_activeu   open_calltipu   False(   u   selfu   event(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   refresh_calltip_event:   s    c             C   sÏ   |  j  ƒ  t |  j d ƒ } | j d ƒ } | p d  S| j | d ƒ | j ƒ  } | p d  S| o | j d ƒ d k o d  S|  j | ƒ } | p d  S|  j ƒ  |  _	 |  j	 j
 | | d | d ƒ d  S(   Nu   insertu   (i    iÿÿÿÿi   (   u   _remove_calltip_windowu   HyperParseru   editwinu   get_surrounding_bracketsu	   set_indexu   get_expressionu   findu	   fetch_tipu   _calltip_windowu   active_calltipu   showtip(   u   selfu	   evalfuncsu   hpu	   sur_parenu   nameu   argspec(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   open_calltip>   s     
c             C   sh   y |  j  j j j j } Wn d } Yn X| o | j d d | f i  ƒ S|  j | ƒ } t | ƒ Sd S(   uD  Return the argument list and docstring of a function or class.

        If there is a Python subprocess, get the calltip there.  Otherwise,
        either this fetch_tip() is running in the subprocess or it was
        called in an IDLE running without the subprocess.

        The subprocess environment is that of the most recently run script.  If
        two unrelated modules are being edited some calltips in the current
        module may be inoperative if the module was not the last to run.

        To find methods, fetch_tip must be fed a fully qualified name.

        u   execu   get_the_calltipN(	   u   editwinu   flistu   pyshellu   interpu   rpccltu   Noneu
   remotecallu
   get_entityu   get_argspec(   u   selfu   nameu   rpccltu   entity(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu	   fetch_tipQ   s    c          	   C   s`   | oU t  j j ƒ  } | j t j ƒ y t | | ƒ SWq\ t t f k
 o d SYq\ Xn d S(   uB   Lookup name in a namespace spanning sys.modules and __main.dict__.N(
   u   sysu   modulesu   copyu   updateu   __main__u   __dict__u   evalu	   NameErroru   AttributeErroru   None(   u   selfu   nameu	   namespace(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu
   get_entityj   s    N(   u   Show call tipu   <<force-open-calltip>>(   u   __name__u
   __module__u   menudefsu   Noneu   __init__u   closeu   _make_tk_calltip_windowu   _remove_calltip_windowu   force_open_calltip_eventu   try_open_calltip_eventu   refresh_calltip_eventu   open_calltipu	   fetch_tipu
   get_entity(   u
   __locals__(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   CallTips   s   
								u   CallTipsc             C   sY   y |  j  j SWnD t k
 o8 x) |  j D] } t | ƒ } | o | Sq) Wd SYn Xd S(   u.   Find the nearest __init__() in the class tree.N(   u   __init__u   __func__u   AttributeErroru	   __bases__u   _find_constructoru   None(   u   class_obu   baseu   init(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   _find_constructort   s    
 	c             C   sY  d } |  d k	 oBt |  t ƒ o* t |  ƒ } | d k o d „  } qs n' t |  t j ƒ o |  j } n |  } t | t j t j f ƒ o= t	 j
 t	 j | ƒ Œ  } t j d ƒ } | j d | ƒ } n t |  d d ƒ } | ol | j ƒ  } | j d ƒ } | d k  p | d k o
 d } n | o | d 7} n | | d | … 7} qUn | S(	   u;   Get a string describing the arguments for the given object.u    c               S   s   d  S(   N(   u   None(    (    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   <lambda>†   s    u
   self\,?\s*u   __doc__u   
i    iF   N(   u   Noneu
   isinstanceu   typeu   _find_constructoru   typesu
   MethodTypeu   __func__u   FunctionTypeu
   LambdaTypeu   inspectu   formatargspecu   getfullargspecu   reu   compileu   subu   getattru   lstripu   find(   u   obu   argspecu   fobu   patu   docu   pos(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   get_argspec   s.    
c        
      C   sÁ   d „  }  d  d „ } d „  } d „  } d „  } d  d „ } Gd „  d t ƒ } t j j t ƒ  ƒ d	 „  } | ƒ  } |  | | | | | | | j | j | j | j	 | j
 | j f }	 | |	 ƒ d  S(
   Nc               S   s   d S(   u   ()N(    (    (    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   t1Ÿ   s    c             S   s   d S(   u   (a, b=None)N(    (   u   au   b(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   t2    s    c             W   s   d S(   u
   (a, *args)N(    (   u   au   args(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   t3¡   s    c              W   s   d S(   u   (*args)N(    (   u   args(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   t4¢   s    c             W   s   d S(   u
   (a, *args)N(    (   u   au   args(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   t5£   s    c             _   s   d S(   u   (a, b=None, *args, **kw)N(    (   u   au   bu   argsu   kw(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   t6¤   s    c             B   s\   |  Ee  Z d  Z d d „ Z d „  Z d d „ Z d „  Z d „  Z d „  Z	 d d „ Z
 d S(	   u   (ai=None, *b)c             W   s   d S(   u   (ai=None, *b)N(    (   u   selfu   aiu   b(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   __init__¨   s    c             S   s   d S(   u   ()N(    (   u   self(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   t1©   s    c             S   s   d S(   u   (ai, b=None)N(    (   u   selfu   aiu   b(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   t2ª   s    c             W   s   d S(   u   (ai, *args)N(    (   u   selfu   aiu   args(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   t3«   s    c             W   s   d S(   u   (*args)N(    (   u   selfu   args(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   t4¬   s    c             W   s   d S(   u   (ai, *args)N(    (   u   selfu   aiu   args(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   t5­   s    c             _   s   d S(   u   (ai, b=None, *args, **kw)N(    (   u   selfu   aiu   bu   argsu   kw(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   t6®   s    N(   u   __name__u
   __module__u   __doc__u   Noneu   __init__u   t1u   t2u   t3u   t4u   t5u   t6(   u
   __locals__(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   TC¦   s   
				u   TCc       	      S   sî   t  ƒ  } g  } x¸ |  D]° } | j d | j } | j } y d | j j j | f } Wn t k
 o | } Yn X| j | ƒ } | | k o7 | j | ƒ d } t | | j | t	 | ƒ f ƒ q q Wt d t
 | ƒ t
 |  ƒ f ƒ d  S(   Nu   
u   %s.%su   %s - expected %s, but got %su   %d of %d tests failed(   u   CallTipsu   __doc__u   __name__u   __self__u	   __class__u   AttributeErroru	   fetch_tipu   appendu   printu   get_argspecu   len(	   u   testsu   ctu   failedu   tu   expectedu   nameu   qualified_nameu   argspecu   fmt(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   test²   s     	 	((   u   Noneu   objectu   __main__u   __dict__u   updateu   localsu   t1u   t2u   t3u   t4u   t5u   t6(
   u   t1u   t2u   t3u   t4u   t5u   t6u   TCu   testu   tcu   tests(    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   mainž   s    				
		-u   __main__(   u   __doc__u   reu   sysu   typesu   inspectu   idlelibu   CallTipWindowu   idlelib.HyperParseru   HyperParseru   __main__u   CallTipsu   _find_constructoru   get_argspecu   mainu   __name__(    (    (    u-   /mit/python/lib/python3.0/idlelib/CallTips.pyu   <module>   s   b			,