ó
†Å•Zc           @   sk   d  d l  m Z d  d l m Z d „  Z d „  Z d „  Z d e f d „  ƒ  YZ d e f d	 „  ƒ  YZ	 d
 S(   iÿÿÿÿ(   t   ast(   t   pycompatc         C   s   t  |  ƒ } t | | ƒ S(   s1   Return the line which is visible from all `lines`(   t   ast_suite_treet   find_visible_for_suite(   t   nodet   linest   root(    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyt   find_visible   s    c         C   s—  t  | ƒ d k r | d S| d } t |  | d ƒ } |  j | ƒ } |  j | ƒ } d „  } | | ƒ r{ | | ƒ r{ | S| | ƒ r˜ | | ƒ r˜ | S| | ƒ r¶ | | ƒ r¶ d  Sx¬ | | k rd| j | j k rd| j ƒ  | j ƒ  k  r| j ƒ  } | j } q¹ | j ƒ  | j ƒ  k r7| j ƒ  } | j } q¹ | j ƒ  } | j ƒ  } | j } | j } q¹ W| | k r~t | | ƒ St | j ƒ  | j ƒ  ƒ S(   Ni   i    c         S   s   |  d  k	 o |  j S(   N(   t   Nonet   ignored(   t   suite(    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyt   valid   s    (   t   lenR   t
   find_suiteR   t   parentt
   _get_levelt	   get_startt   min(   R   R   t   line1t   line2t   suite1t   suite2R   (    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyR      s6    
	!	c         C   s1   t  |  d ƒ r |  j } n d } t |  j | ƒ S(   Nt   linenoi   (   t   hasattrR   t   Suitet   body(   R   R   (    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyR   ,   s    R   c           B   sM   e  Z d e d  „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(   c         C   s1   | |  _  | |  _ | |  _ d  |  _ | |  _ d  S(   N(   R   R   t   child_nodesR   t	   _childrenR	   (   t   selfR   R   R   R	   (    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyt   __init__6   s
    				c         C   s0   |  j  d  k r) |  j r" |  j ƒ  Sd Sn  |  j S(   Ni   (   R   R   R   t   local_startR   (   R   (    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyR   =   s
    	
c         C   sU   |  j  d  k rN t |  ƒ } x! |  j D] } t j | | ƒ q% W| j |  _  n  |  j  S(   N(   R   R   t   _SuiteWalkerR   R    t   walkt   suites(   R   t   walkert   child(    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyt   get_childrenE   s    c         C   s   |  j  d j S(   Ni    (   R   R   (   R   (    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyR   M   s    c         C   sB   |  j  d j } |  j ƒ  r> t | |  j ƒ  d j ƒ  ƒ } n  | S(   Niÿÿÿÿ(   R   R   R$   t   maxt	   local_end(   R   t   end(    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyR&   P   s    "c         C   s`   | d  k r d  SxI |  j ƒ  D]; } | j ƒ  | k oF | j ƒ  k n r | j | ƒ Sq W|  S(   N(   R   R$   R   R&   R   (   R   t   lineR#   (    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyR   V   s    (c         C   s$   |  j  d  k r d S|  j  j ƒ  d S(   Ni    i   (   R   R   R   (   R   (    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyR   ^   s    N(   t   __name__t
   __module__R   t   FalseR   R   R$   R   R&   R   R   (    (    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyR   4   s   					R   c           B   sk   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z RS(   c         C   s   | |  _  g  |  _ d  S(   N(   R
   R!   (   R   R
   (    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyR   f   s    	c         C   s   |  j  | ƒ d  S(   N(   t   _add_if_like_node(   R   R   (    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyt   _Ifj   s    c         C   s   |  j  | ƒ d  S(   N(   R,   (   R   R   (    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyt   _Form   s    c         C   s   |  j  | ƒ d  S(   N(   R,   (   R   R   (    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyt   _Whilep   s    c         C   s)   |  j  j t | j | j |  j ƒ ƒ d  S(   N(   R!   t   appendR   R   R   R
   (   R   R   (    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyt   _Withs   s    c         C   sú   t  } t | j ƒ d k r€ t j r@ t | j d t j ƒ } q€ t j	 r€ y t | j
 d t j ƒ } Wq} t k
 ry q} Xq€ n  | r¬ |  j t j	 r› | n
 | j d ƒ n% |  j j t | j | j |  j ƒ ƒ |  j j t | j | j |  j ƒ ƒ d  S(   Ni   i    (   R+   R   t	   finalbodyR   t   PY2t
   isinstanceR   R    t	   TryExceptt   PY3t   handlerst   ExceptHandlert
   IndexErrort
   _TryExceptR!   R0   R   R   R
   (   R   R   t   proceed_to_except_handler(    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyt   _TryFinallyv   s    		
&%c         C   s6   t  | j ƒ d k r% |  j | ƒ n |  j | ƒ d  S(   Ni   (   R   R2   R<   R:   (   R   R   (    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyt   _Try†   s    c         C   s“   |  j  j t | j | j |  j ƒ ƒ x6 | j D]+ } |  j  j t | j | j |  j ƒ ƒ q/ W| j r |  j  j t | j | j |  j ƒ ƒ n  d  S(   N(   R!   R0   R   R   R   R
   R7   t   orelse(   R   R   t   handler(    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyR:   Œ   s
    %)	c         C   sZ   |  j  j t | j | j |  j ƒ ƒ | j rV |  j  j t | j | j |  j ƒ ƒ n  d  S(   N(   R!   R0   R   R   R   R
   R>   (   R   R   (    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyR,   “   s    %	c         C   s/   |  j  j t | j | j |  j d t ƒƒ d  S(   NR	   (   R!   R0   R   R   R   R
   t   True(   R   R   (    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyt   _FunctionDef˜   s    c         C   s/   |  j  j t | j | j |  j d t ƒƒ d  S(   NR	   (   R!   R0   R   R   R   R
   R@   (   R   R   (    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyt	   _ClassDefœ   s    (   R)   R*   R   R-   R.   R/   R1   R<   R=   R:   R,   RA   RB   (    (    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyR   d   s   										N(
   t	   rope.baseR    t   rope.base.utilsR   R   R   R   t   objectR   R   (    (    (    s3   lib/python2.7/site-packages/rope/refactor/suites.pyt   <module>   s   		!	0