ó
†Å•Zc           @   sÈ   d  d l  Z d  d l Z d  d l Z d  d l m Z m Z m Z d e f d „  ƒ  YZ	 d e	 f d „  ƒ  YZ
 d e	 f d „  ƒ  YZ d	 e	 f d
 „  ƒ  YZ d e f d „  ƒ  YZ d e	 f d „  ƒ  YZ d S(   iÿÿÿÿN(   t   astt
   exceptionst   utilst   Scopec           B   s×   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e j	 d „  ƒ Z
 d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z e j	 d „  ƒ Z e e ƒ Z e e ƒ Z e e ƒ Z d „  Z RS(   c         C   s   | |  _  | |  _ | |  _ d  S(   N(   t   pycoret   pyobjectt   parent(   t   selfR   R   t   parent_scope(    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   __init__	   s    		c         C   s   |  j  j ƒ  S(   s2   Return the names defined or imported in this scope(   R   t   get_attributes(   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt	   get_names   s    c         C   s   |  j  j ƒ  S(   s&   Return the names defined in this scope(   R   t   _get_structural_attributes(   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   get_defined_names   s    c         C   s6   | |  j  ƒ  k r( t j d | ƒ ‚ n  |  j  ƒ  | S(   s*   Return name `PyName` defined in this scopes   name %s not found(   R   R   t   NameNotFoundError(   R   t   name(    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   get_name   s    c         C   s   |  j  | ƒ S(   s   The same as ``get_name(key)``(   R   (   R   t   key(    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   __getitem__   s    c         C   s   | |  j  ƒ  k S(   s'   The same as ``key in self.get_names()``(   R   (   R   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   __contains__    s    c         C   s
   |  j  ƒ  S(   ss   Return the subscopes of this scope

        The returned scopes should be sorted by the order they appear.
        (   t   _create_scopes(   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt
   get_scopes$   s    c         C   sC   | |  j  ƒ  k r  |  j  ƒ  | S|  j d  k	 r? |  j j | ƒ Sd  S(   N(   R   R   t   Nonet   _propagated_lookup(   R   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   lookup,   s
    c         C   s
   |  j  ƒ  S(   s#  Return the visible names of this scope

        Return the names defined in this scope that are visible from
        scopes containing this scope.  This method returns the same
        dictionary returned by `get_names()` except for `ClassScope`
        which returns an empty dict.
        (   R   (   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   get_propagated_names3   s    c         C   sC   | |  j  ƒ  k r  |  j  ƒ  | S|  j d  k	 r? |  j j | ƒ Sd  S(   N(   R   R   R   R   (   R   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR   =   s
    c         C   s&   g  |  j  j ƒ  D] } | j ƒ  ^ q S(   N(   R   t   _get_defined_objectst	   get_scope(   R   t	   pydefined(    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR   D   s    c         C   s)   |  } x | j  d  k	 r$ | j  } q	 W| S(   N(   R   R   (   R   t   current(    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   _get_global_scopeH   s    c         C   s   |  j  j ƒ  j S(   N(   R   t   get_astt   lineno(   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt	   get_startN   s    c         C   s-   |  j  j ƒ  j } | r# | d j S|  j ƒ  S(   Ni    (   R   R   t   bodyR    R!   (   R   R"   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   get_body_startQ   s    c         C   s&   |  j  ƒ  j } | j j |  j ƒ d S(   Ni   (   R   R   t   logical_linest   logical_line_int   logical_end(   R   t   pymodule(    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   get_endW   s    c         C   s   |  j  ƒ  } | j j |  ƒ S(   N(   R   t   _scope_findert   find_scope_end(   R   t   global_scope(    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   get_logical_end[   s    c         C   s   d  S(   N(    (   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   get_kindd   s    (   t   __name__t
   __module__R	   R   R   R   R   R   R   t   saveitR   R   R   R   R   R   R!   R#   R(   R,   t   propertyt   startt   endR&   R-   (    (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR      s(   								
						t   GlobalScopec           B   sq   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d	 d „ Z d „  Z	 e
 e j d „  ƒ ƒ Z e
 d „  ƒ Z RS(
   c         C   s/   t  t |  ƒ j | | d  ƒ | j ƒ  |  _ d  S(   N(   t   superR4   R	   R   t   _get_concluded_datat   names(   R   R   t   module(    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR	   j   s    c         C   s   d S(   Ni   (    (   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR!   n   s    c         C   s   d S(   Nt   Module(    (   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR-   q   s    c         C   sW   y |  j  | SWnA t j k
 rR | |  j k r< |  j | St j d | ƒ ‚ n Xd  S(   Ns   name %s not found(   R   R   t   AttributeNotFoundErrort   builtin_namesR   (   R   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR   t   s    c         C   s`   |  j  j ƒ  d  k rS t |  j ƒ } | j t t |  ƒ j ƒ  ƒ |  j  j	 | ƒ n  |  j  j ƒ  S(   N(
   R7   t   getR   t   dictR;   t   updateR5   R4   R   t   set(   R   t   result(    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR   |   s
    c         C   s   |  j  j |  | | ƒ S(   N(   R)   t   get_holding_scope(   R   R    t   indents(    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   get_inner_scope_for_lineƒ   s    c         C   s   |  j  j |  | ƒ S(   N(   R)   t   get_holding_scope_for_offset(   R   t   offset(    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   get_inner_scope_for_offset†   s    c         C   s   t  |  j ƒ S(   N(   t   _HoldingScopeFinderR   (   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR)   ‰   s    c         C   s   t  j j j j ƒ  S(   N(   t   ropet   baset   builtinsR
   (   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR;   Ž   s    N(   R.   R/   R	   R!   R-   R   R   R   RC   RF   R1   R   R0   R)   R;   (    (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR4   h   s   						t   FunctionScopec           B   sY   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   c         C   sV   t  t |  ƒ j | | | j j ƒ  ƒ d  |  _ d  |  _ d  |  _ d  |  _	 | |  _
 d  S(   N(   R5   RK   R	   R   R   R   R7   t   returned_astst   is_generatort   definedst   visitor(   R   R   R   RO   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR	   •   s    				c         C   s#   |  j  d  k r |  j ƒ  n  |  j  S(   N(   R7   R   t   _visit_function(   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt
   _get_namesž   s    c         C   sª   |  j  d  k r¦ |  j |  j |  j ƒ } x0 t j |  j j ƒ  ƒ D] } t j | | ƒ q@ W| j  |  _  |  j  j	 |  j j
 ƒ  ƒ | j |  _ | j |  _ | j |  _ n  d  S(   N(   R7   R   RO   R   R   R    t   get_child_nodesR   t   walkR>   t   get_parametersRL   t	   generatorRM   RN   (   R   t   new_visitort   n(    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyRP   £   s    c         C   s#   |  j  d  k r |  j ƒ  n  |  j S(   N(   R7   R   RP   RL   (   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   _get_returned_asts®   s    c         C   s#   |  j  d  k r |  j ƒ  n  |  j  S(   N(   RM   R   RX   (   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   _is_generator³   s    c         C   s
   |  j  ƒ  S(   N(   RQ   (   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR   ¸   s    c         C   s<   |  j  d  k r |  j ƒ  n  g  |  j  D] } | j ƒ  ^ q& S(   N(   RN   R   RP   R   (   R   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR   »   s    c         C   s   d S(   Nt   Function(    (   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR-   À   s    c         C   sU   xN |  j  ƒ  j ƒ  D]: } t | t j j j t j j j f ƒ r | j ƒ  q q Wd  S(   N(	   R   t   valuest
   isinstanceRH   RI   t   pynamest   AssignedNamet   EvaluatedNamet
   invalidate(   R   t   pyname(    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   invalidate_dataÃ   s    (   R.   R/   R	   RQ   RP   RX   RY   R   R   R-   Rb   (    (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyRK   “   s   									t
   ClassScopec           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   s)   t  t |  ƒ j | | | j j ƒ  ƒ d  S(   N(   R5   Rc   R	   R   R   (   R   R   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR	   Ì   s    c         C   s   d S(   Nt   Class(    (   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR-   Ð   s    c         C   s   i  S(   N(    (   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR   Ó   s    (   R.   R/   R	   R-   R   (    (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyRc   Ê   s   		RG   c           B   s€   e  Z d  „  Z d „  Z d „  Z d d „ Z d „  Z d „  Z d „  Z	 d „  Z
 e d „  ƒ Z e d	 „  ƒ Z e d
 „  ƒ Z RS(   c         C   s   | |  _  d  S(   N(   R'   (   R   R'   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR	   Ù   s    c         C   s   t  j j j |  j j | ƒ ƒ S(   N(   RH   RI   t   codeanalyzet   count_line_indentst   linest   get_line(   R   R    (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   get_indentsÜ   s    c         C   s   |  j  | j ƒ  ƒ S(   N(   Ri   R!   (   R   t   scope(    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   _get_scope_indentsà   s    c         C   så   | d  k r |  j | ƒ } n  | } | } x´ | d  k	 rà | j ƒ  d k s` |  j | ƒ | k rà | } | j ƒ  | k rŽ | j ƒ  d k rŽ | Sd  } xF | j ƒ  D]8 } | j ƒ  | k rØ | | j ƒ  k rÙ | } PqÙ q¡ Pq¡ Wq- W| S(   NR9   (   R   Ri   R-   Rk   R!   R   R(   (   R   t   module_scopeR    t   line_indentst   current_scopet	   new_scopeRj   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyRA   ã   s&    	c         C   s7   |  j  j | ƒ } | j ƒ  d k p6 | j ƒ  j d ƒ S(   Nt    t   #(   Rg   Rh   t   stript   lstript
   startswith(   R   R    t   line(    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   _is_empty_lineù   s    c         C   s   |  j  | j ƒ  ƒ S(   N(   Ri   R#   (   R   Rj   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   _get_body_indentsý   s    c         C   s   |  j  | |  j j | ƒ ƒ S(   N(   RA   Rg   t   get_line_number(   R   Rj   RE   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyRD      s    c         C   sô   | j  s |  j j ƒ  S| j j ƒ  j d j } |  j j j	 | j
 ƒ } | d | k rm |  j | ƒ d } n |  j | ƒ } xq |  j j t | d |  j j ƒ  ƒ |  j j ƒ  d ƒ D]7 } |  j | ƒ sµ |  j | ƒ | k  rã | S| } qµ qµ W| S(   Niÿÿÿÿi   i   (   R   Rg   t   lengthR   R   R"   R    R'   R$   R%   R2   Rk   Rw   t   generate_startst   minRv   Ri   (   R   Rj   R3   t   scope_startt   body_indentst   l(    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR*     s    	3c         C   s
   |  j  j S(   N(   R'   Rg   (   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyRg     s    c         C   s
   |  j  j S(   N(   R'   t   source_code(   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   code  s    c         C   s
   |  j  j S(   N(   R'   R$   (   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR$     s    N(   R.   R/   R	   Ri   Rk   R   RA   Rv   Rw   RD   R*   R1   Rg   R€   R$   (    (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyRG   ×   s   							t   TemporaryScopec           B   s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sž   Currently used for list comprehensions and generator expressions

    These scopes do not appear in the `get_scopes()` method of their
    parent scopes.
    c         C   s,   t  t |  ƒ j | | j | ƒ | |  _ d  S(   N(   R5   R   R	   R   R7   (   R   R   R   R7   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR	   +  s    c         C   s   |  j  S(   N(   R7   (   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR   0  s    c         C   s   |  j  S(   N(   R7   (   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR   3  s    c         C   s   g  S(   N(    (   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR   6  s    c         C   s   d S(   Nt	   Temporary(    (   R   (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR-   9  s    (   R.   R/   t   __doc__R	   R   R   R   R-   (    (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyR   $  s   				(   t   rope.base.builtinsRH   t   rope.base.codeanalyzet   rope.base.pynamest	   rope.baseR    R   R   t   objectR   R4   RK   Rc   RG   R   (    (    (    s1   lib/python2.7/site-packages/rope/base/pyscopes.pyt   <module>   s   a+7M