ó
†Å•Zc           @   s   d  d l  m Z m Z m Z m Z d  d l m Z m Z d e f d „  ƒ  YZ	 d e f d „  ƒ  YZ
 d e f d „  ƒ  YZ d	 „  Z d
 e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   astt   evaluatet   builtinst	   pyobjects(   t
   patchedastt   occurrencest   Wildcardc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   d S(   s    Return the name of this wildcardN(    (   t   self(    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyt   get_name   t    c         C   s   d S(   s0   Return `True` if `suspect` matches this wildcardN(    (   R   t   suspectt   arg(    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyt   matches
   R	   (   t   __name__t
   __module__R   R   (    (    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyR      s   	t   Suspectc           B   s   e  Z d  „  Z RS(   c         C   s   | |  _  | |  _ | |  _ d  S(   N(   t   namet   pymodulet   node(   R   R   R   R   (    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyt   __init__   s    		(   R   R   R   (    (    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyR      s   t   DefaultWildcardc           B   s>   e  Z d  Z d „  Z d „  Z d d „ Z d „  Z d „  Z RS(   sË  The default restructuring wildcard

    The argument passed to this wildcard is in the
    ``key1=value1,key2=value2,...`` format.  Possible keys are:

    * name - for checking the reference
    * type - for checking the type
    * object - for checking the object
    * instance - for checking types but similar to builtin isinstance
    * exact - matching only occurrences with the same name as the wildcard
    * unsure - matching unsure occurrences

    c         C   s   | |  _  d  S(   N(   t   project(   R   R   (    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyR   %   s    c         C   s   d S(   Nt   default(    (   R   (    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyR   (   s    R	   c         C   s<   t  | ƒ } |  j | | ƒ s" t S|  j | | ƒ s8 t St S(   N(   t	   parse_argt   _check_exactt   Falset   _check_objectt   True(   R   R
   R   t   args(    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyR   +   s    c         C   s˜   d  } d  } | j d t ƒ } xs d d d d g D]_ } | | k rV | } | | } n  | d  k	 r1 t |  j | | d | ƒ} | | j | j ƒ Sq1 Wt S(   Nt   unsureR   t   objectt   typet   instance(   t   Nonet   getR   t   _CheckObjectR   R   R   R   (   R   R   R
   t   kindt   expectedR   t   checkt   checker(    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyR   4   s    c         C   s_   | j  } | j d ƒ rE t | t j ƒ s> | j | j k r[ t Sn t | t j ƒ s[ t St	 S(   Nt   exact(
   R   R"   t
   isinstanceR    t   Namet   idR   R   t   exprR   (   R   R   R
   R   (    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyR   B   s    	&(   R   R   t   __doc__R   R   R   R   R   (    (    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyR      s   				c         C   sŒ   t  |  t ƒ r |  Si  } |  j d ƒ } x] | D]U } d | k rt | j d d ƒ } | d j ƒ  | | d j ƒ  <q/ t | | j ƒ  <q/ W| S(   Nt   ,t   =i   i    (   R)   t   dictt   splitt   stripR   (   R   t   resultt   tokenst   tokent   parts(    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyR   M   s    !R#   c           B   sb   e  Z d  e d „ Z d „  Z d „  Z d „  Z d „  Z e d „ Z	 d „  Z
 d „  Z d	 „  Z RS(
   R   c         C   s1   | |  _  | |  _ | |  _ |  j | ƒ |  _ d  S(   N(   R   R$   R   t	   _evaluateR%   (   R   R   R%   R$   R   (    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyR   ]   s    			c         C   sE  |  j  | | ƒ } | d  k s- |  j d  k r4 |  j S|  j | d |  j d k ƒrV t S|  j d k rx |  j |  j | ƒ S| j ƒ  } |  j d k rŸ | g } n  |  j d k rÀ | j	 ƒ  g } n  |  j d k r| g } | j
 |  j | ƒ ƒ | j
 |  j | j	 ƒ  ƒ ƒ n  x- | D]% } |  j |  j j ƒ  | ƒ rt SqWt Sd  S(   Nt   unboundR   R   R   R    (   t   _evaluate_nodeR!   R%   R   t   _unsure_pynameR$   R   t   _same_pynamet
   get_objectt   get_typet   extendt   _get_super_classest   _same_pyobjectR   (   R   R   R   t   pynamet   pyobjectt   objects(    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyt   __call__c   s(    	c         C   sY   g  } t  | t j ƒ rU x: | j ƒ  D]) } | j | ƒ | j |  j | ƒ ƒ q% Wn  | S(   N(   R)   R   t   AbstractClasst   get_superclassest   appendR>   R?   (   R   RB   R3   t
   superclass(    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyR?   z   s    c         C   s
   | | k S(   N(    (   R   R%   RB   (    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyR@   ‚   s    c         C   s   t  j | | ƒ S(   N(   R   t   same_pyname(   R   R%   RA   (    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyR;   …   s    c         C   s   |  j  o t j | | ƒ S(   N(   R   R   t   unsure_pyname(   R   RA   R8   (    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyR:   ˆ   s    c         C   sI   | j  d ƒ } | d | d } } t | ƒ d k r? d } n  | | f S(   Nt   .i    iÿÿÿÿi   R   (   R1   t   len(   R   R   R6   t
   expressionR$   (    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyt   _split_name‹   s
    	c         C   sŽ   | j  ƒ  j | j ƒ } | } t | t j ƒ rz t | j t j ƒ rz t j	 | ƒ \ } } | j
 | | !} t j | | ƒ St j | | ƒ Sd  S(   N(   t	   get_scopet   get_inner_scope_for_linet   linenoR)   R    R*   t   ctxt   StoreR   t   node_regiont   source_codeR   t   eval_strt	   eval_node(   R   R   R   t   scopeRM   t   startt   endt   text(    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyR9   ’   s    c         C   sœ   | j  d ƒ } d  } | d d k rG d t f d „  ƒ  Y} | ƒ  } n |  j j | d ƒ } x8 | d D], } | | } | d  k rˆ d  S| j ƒ  } qh W| S(	   NRK   i    t   __builtin__t   __builtins__t   _BuiltinsStubc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         S   s   t  j  | S(   N(   R   (   R   R   (    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyt   get_attribute¢   s    c         S   s   t  j  | S(   N(   R   (   R   R   (    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyt   __getitem__¥   s    c         S   s   | t  j  k S(   N(   R   (   R   R   (    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyt   __contains__¨   s    (   R   R   R_   R`   Ra   (    (    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyR^   ¡   s   		i   (   R\   R]   (   R1   R!   R   R   t
   get_moduleR<   (   R   t   codet
   attributesRA   R^   RB   t	   attribute(    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyR7      s    	
(   R   R   R   R   RD   R?   R@   R;   R   R:   RN   R9   R7   (    (    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyR#   [   s   						N(   t	   rope.baseR    R   R   R   t   rope.refactorR   R   R   R   R   R   R   R#   (    (    (    s6   lib/python2.7/site-packages/rope/refactor/wildcards.pyt   <module>   s   "	7	