
ŕZc           @   s  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 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 d d d e d  Z d   Z d d d  Z d d e e d  Z d d d  Z d   Z d   Z d e f d     YZ e Z  d e f d     YZ! d d d  Z" d   Z# d   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 S(&   iN(   t   builtins(   t
   exceptions(   t   libutils(   t   pynames(   t
   pynamesdef(   t	   pyobjects(   t   pyobjectsdef(   t   pyscopes(   t   worder(   t	   fixsyntax(   t   functionutilsi   c      
   C   sP   | d k	 r% t j d t d d n  t |  | | d | d | d | } |   S(   so  Return python code completions as a list of `CodeAssistProposal`\s

    `resource` is a `rope.base.resources.Resource` object.  If
    provided, relative imports are handled.

    `maxfixes` is the maximum number of errors to fix if the code has
    errors in it.

    If `later_locals` is `False` names defined in this scope and after
    this line is ignored.

    s'   Codeassist no longer supports templatest
   stackleveli   t   resourcet   maxfixest   later_localsN(   t   Nonet   warningst   warnt   DeprecationWarningt   _PythonCodeAssist(   t   projectt   source_codet   offsetR   t	   templatesR   R   t   assist(    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyt   code_assist   s    	c         C   s.   t  j |  t  } | j |  \ } } } | S(   sN  Return the offset in which the completion should be inserted

    Usually code assist proposals should be inserted like::

        completion = proposal.name
        result = (source_code[:starting_offset] +
                  completion + source_code[offset:])

    Where starting_offset is the offset returned by this function.

    (   R   t   Wordert   Truet   get_splitted_primary_before(   R   R   t   word_findert
   expressiont   startingt   starting_offset(    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR    +   s    c         C   sS   t  j |  | | |  } | j |  } | d k r7 d S| j   } t   j |  S(   s   Get the pydocN(   R	   t	   FixSyntaxt	   pyname_atR   t
   get_objectt   PyDocExtractort   get_doc(   R   R   R   R   R   t   fixert   pynamet   pyobject(    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR%   =   s    c   
      C   sY   t  j |  | | |  } | j |  } | d k r7 d S| j   }	 t   j |	 | |  S(   sy  Get the calltip of a function

    The format of the returned string is
    ``module_name.holding_scope_names.function_name(arguments)``.  For
    classes `__init__()` and for normal objects `__call__()` function
    is used.

    Note that the offset is on the function itself *not* after the its
    open parenthesis.  (Actually it used to be the other way but it
    was easily confused when string literals were involved.  So I
    decided it is better for it not to try to be too clever when it
    cannot be clever enough).  You can use a simple search like::

        offset = source_code.rindex('(', 0, offset) - 1

    to handle simple situations.

    If `ignore_unknown` is `True`, `None` is returned for functions
    without source-code like builtins and extensions.

    If `remove_self` is `True`, the first parameter whose name is self
    will be removed for methods.
    N(   R	   R!   R"   R   R#   R$   t   get_calltip(
   R   R   R   R   R   t   ignore_unknownt   remove_selfR&   R'   R(   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR)   G   s    c   	      C   sn   t  j |  | | |  } | j |  } | d k	 rj | j   \ } } | d k	 rj | j   j   | f Sn  d S(   sS  Return the definition location of the python name at `offset`

    Return a (`rope.base.resources.Resource`, lineno) tuple.  If no
    `resource` is given and the definition is inside the same module,
    the first element of the returned tuple would be `None`.  If the
    location cannot be determined ``(None, None)`` is returned.

    N(   NN(   R	   R!   R"   R   t   get_definition_locationt
   get_modulet   get_resource(	   R   R   R   R   R   R&   R'   t   modulet   lineno(    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR,   h   s    
c          O   s8   d d  l  } t j d t d d | j j j |  |   S(   Nis4   Use `rope.contrib.findit.find_occurrences()` insteadR   i   (   t   rope.contrib.finditR   R   R   t   contribt   finditt   find_occurrences(   t   argst   kwdst   rope(    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR4   {   s    	c   
      C   se  |  j  |  } t j j j | |  } | j   \ } } | sC d S| j   j |  } g  } t	 | t
 j  r t j | j   |  d f g } n6 t	 | t
 j  r t j | j   |  d f g } n  xn | j r:t	 | t j  r d }	 n! t	 | t j  rd }	 n d }	 | j | j j   |	 f  | j } q W| j | j   j d f  | j   | S(   s  Get the canonical path to an object.

    Given the offset of the object, this returns a list of
    (name, name_type) tuples representing the canonical path to the
    object. For example, the 'x' in the following code:

        class Foo(object):
            def bar(self):
                class Qux(object):
                    def mux(self, x):
                        pass

    we will return:

        [('Foo', 'CLASS'), ('bar', 'FUNCTION'), ('Qux', 'CLASS'),
         ('mux', 'FUNCTION'), ('x', 'PARAMETER')]

    `resource` is a `rope.base.resources.Resource` object.

    `offset` is the offset of the pyname you want the path to.

    t	   PARAMETERt   VARIABLEt   FUNCTIONt   CLASSt   MODULEN(   t   get_pymoduleR7   t   baset   evaluatet   eval_locationR,   R   t	   get_scopet   get_inner_scope_for_linet
   isinstanceR   t   ParameterNameR   t   get_name_atR.   t   AssignedNamet   parentR   t   FunctionScopet
   ClassScopet   appendR(   t   get_namet	   real_patht   reverse(
   R   R   R   t   pymodR'   t   defmodR0   t   scopet   namest
   scope_type(    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyt   get_canonical_path   s0    		
t   CompletionProposalc           B   sk   e  Z d  Z d	 d  Z d   Z d   Z e d    Z e d    Z	 d   Z
 d   Z e d    Z RS(
   s  A completion proposal

    The `scope` instance variable shows where proposed name came from
    and can be 'global', 'local', 'builtin', 'attribute', 'keyword',
    'imported', 'parameter_keyword'.

    The `type` instance variable shows the approximate type of the
    proposed object and can be 'instance', 'class', 'function', 'module',
    and `None`.

    All possible relations between proposal's `scope` and `type` are shown
    in the table below (different scopes in rows and types in columns):

                      | instance | class | function | module | None
                local |    +     |   +   |    +     |   +    |
               global |    +     |   +   |    +     |   +    |
              builtin |    +     |   +   |    +     |        |
            attribute |    +     |   +   |    +     |   +    |
             imported |    +     |   +   |    +     |   +    |
              keyword |          |       |          |        |  +
    parameter_keyword |          |       |          |        |  +

    c         C   s(   | |  _  | |  _ |  j |  |  _ d  S(   N(   t   nameR'   t
   _get_scopeRP   (   t   selfRU   RP   R'   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyt   __init__   s    		c         C   s   d |  j  |  j |  j f S(   Ns   %s (%s, %s)(   RU   RP   t   type(   RW   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyt   __str__   s    c         C   s
   t  |   S(   N(   t   str(   RW   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyt   __repr__   s    c         C   sk   |  j  } t | t j  r* | j   } n  t | t j  rg | j   } t | t j  rg | j	   Sn  d S(   st   The names of the parameters the function takes.

        Returns None if this completion is not a function.
        N(
   R'   RC   R   t   ImportedNamet   _get_imported_pynamet   DefinedNameR#   R   t   AbstractFunctiont   get_param_names(   RW   R'   R(   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyt
   parameters   s    	c         C   s   |  j  } t | t j  r~ | j   } t | t j  r= d St | t j  rS d St | t j  sw t | t j  r d Snu t | t j	  r d St | t j
  s t | t j  r | j   } t | t j  r d St | t j  r d Sn  d S(   Nt   functiont   classt   instanceR/   (   R'   RC   R    t   BuiltinNameR#   t   BuiltinFunctiont   BuiltinClasst   BuiltinObjectR   t   ImportedModuleR]   R_   R   R`   t   AbstractClass(   RW   R'   R(   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyRY      s(    	c         C   sK   t  |  j t j  r d St  |  j t j  sC t  |  j t j  rG d S| S(   Nt   builtint   imported(   RC   R'   R    Rf   R   Rj   R]   (   RW   RP   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyRV     s    c         C   sB   |  j  s d S|  j  j   } t | d  s/ d S|  j  j   j   S(   sY   Get the proposed object's docstring.

        Returns None if it can not be get.
        R%   N(   R'   R   R#   t   hasattrR%   (   RW   R(   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR%     s    	c         C   s   t  j d  |  j S(   NsA   the proposal's `kind` property is deprecated, use `scope` instead(   R   R   RP   (   RW   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyt   kind  s    N(   t   __name__t
   __module__t   __doc__R   RX   RZ   R\   t   propertyRb   RY   RV   R%   Ro   (    (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyRT      s   				t   NamedParamProposalc           B   s    e  Z d  Z d   Z d   Z RS(   s   A parameter keyword completion proposal

    Holds reference to ``_function`` -- the function which
    parameter ``name`` belongs to. This allows to determine
    default value for this parameter.
    c         C   s9   | |  _  d | } t t |   j | d  | |  _ d  S(   Ns   %s=t   parameter_keyword(   t   argnamet   superRt   RX   t	   _function(   RW   RU   Rc   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyRX   +  s    	
c         C   sF   t  j j |  j  } x* | j D] \ } } |  j | k r | Sq Wd S(   s   Get a string representation of a param's default value.

        Returns None if there is no default value for this param.
        N(   R
   t   DefinitionInfot   readRx   t   args_with_defaultsRv   R   (   RW   t   definfot   argt   default(    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyt   get_default1  s
    (   Rp   Rq   Rr   RX   R   (    (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyRt   $  s   	c         C   s   t  |  | |  } | j   S(   s  Sort a list of proposals

    Return a sorted list of the given `CodeAssistProposal`\s.

    `scopepref` can be a list of proposal scopes.  Defaults to
    ``['parameter_keyword', 'local', 'global', 'imported',
    'attribute', 'builtin', 'keyword']``.

    `typepref` can be a list of proposal types.  Defaults to
    ``['class', 'function', 'instance', 'module', None]``.
    (`None` stands for completions with no type like keywords.)
    (   t   _ProposalSortert   get_sorted_proposal_list(   t	   proposalst	   scopepreft   typepreft   sorter(    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyt   sorted_proposals=  s    c         C   s@   t  j |  t  } | j |  \ } } } | r< | d | S| S(   s!   Return the expression to completet   .(   R   R   R   R   (   R   R   R   R   R   R    (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyt   starting_expressionN  s
    c           C   s   t  j d t d d i  S(   Ns"   default_templates() is deprecated.R   i   (   R   R   R   (    (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyt   default_templatesX  s    	R   c           B   s   e  Z d d  e d  Z e j Z d   Z d   Z	 d   Z
 d   Z d d  Z d   Z d   Z d	   Z d
   Z d   Z RS(   i   c         C   sj   | |  _  | |  _ | |  _ | |  _ | |  _ t j | t  |  _ |  j j	 |  \ |  _
 |  _ |  _ d  S(   N(   R   t   codeR   R   R   R   R   R   R   R   R   R   R   (   RW   R   R   R   R   R   R   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyRX   `  s    					c         C   sO   | d } x: | d k rF | | j    s9 | | d k rF | d 8} q W| d S(   Ni   i    t   _(   t   isalnum(   RW   R   R   t   current_offset(    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyt   _find_starting_offsetm  s
    
c         C   sF   g  } x9 |  j  D]. } | j |  r | j t | d   q q W| S(   Nt   keyword(   t   keywordst
   startswithRJ   RT   (   RW   R   t   resultt   kw(    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyt   _matching_keywordst  s
    c         C   s~   |  j  t |  j  k r g  St |  j   j    } |  j j   d k rz |  j j   d k rz | j	 |  j
 |  j   n  | S(   Nt    (   R   t   lenR   t   listt   _code_completionst   valuesR   t   stripR   t   extendR   (   RW   t   completions(    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyt   __call__{  s    *c   	      C   s   i  } t  j j j | |  j  } | d  k	 r | j   } d } t | t j	 t j
 f  rc d } n  xN | j   j   D]7 \ } } | j |  j  rv t | | |  | | <qv qv Wn  | S(   Nt	   attributeRm   (   R7   R>   R?   t   eval_strR   R   R#   RC   R   t   PyModulet	   PyPackaget   get_attributest   itemsR   R   RT   (	   RW   t   module_scopet   holding_scopeR   t   found_pynamet   elementt   compl_scopeRU   R'   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyt   _dotted_completions  s    		c         C   s   | j  d  k	 r% |  j | j  |  n  | d  k r@ | j   } n | j   } x | j   D] \ } } | j |  j  rY d } | j   d k r d } n  | d  k s |  j	 s |  j
 | | |  r t | | |  | | <q qY qY Wd  S(   Nt   localt   Modulet   global(   RG   R   t   _undotted_completionst   get_propagated_namest	   get_namesR   R   R   t   get_kindR   t   _is_defined_afterRT   (   RW   RP   R   R0   RQ   RU   R'   R   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR     s    		c         C   s   |  j  j |  j  } | d  k r% i  S|  j | |  } i  } xC | D]; } | j |  j  rD t | d d d | | | | <qD qD W| S(   NRP   R   R'   (   R   t   get_from_moduleR   R   t   _find_moduleR   R   RT   (   RW   t   pymodulet   module_nameR   RU   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyt   _from_import_completions  s    c         C   sJ   d } x | | d k r& | d 7} q	 Wt  j | | | |  } | j   S(   Ni    R   i   (   R   Rj   R#   (   RW   R   R   t   dotsR'   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR     s    	c         C   sr   | j    } | d  k	 rn | d d  k	 rn | d | j j   k rn | | d k ob | j   k n rn t Sn  d  S(   Ni   i    (   R,   R   R(   R-   t   get_endR   (   RW   RP   R'   R0   t   location(    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR     s
    &c         C   s=  |  j  j d d |  j  d } t j |  j |  j  |  j |  j  } | j   } | j	   } | j
 } | j d  } i  } t j | |  } t j | | d  }	 | j | |	  }
 |  j j |  j  r |  j |  S|  j j   d k r| j |  j | |
   n2 | j |  j | j |
   |  j |
 | d | | S(   Ns   
i    i   R   R0   (   R   t   countR   R	   R!   R   R   R   R=   RA   R   t   splitt   _logical_startt   _get_line_indentsRB   R   t   is_a_name_after_from_importR   R   R   t   updateR   t   _keyword_parametersR(   R   (   RW   R0   R&   R   R   R   t   linesR   t   startt   indentst   inner_scope(    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR     s&    	
c         C   s  |  j  } | d k r i  St j |  j t  } | j | d  r| j | d  } | j | d  } y t j	 j
 j | |  } Wn t j k
 r i  SX| d  k	 r| j   } t | t j  r nP t | t j  r d | k r | d j   } n d | k r| d j   } n  t | t j  rg  }	 |	 j | j d t   i  }
 x: |	 D]2 } | j |  j  rVt | |  |
 | d <qVqVW|
 Sqn  i  S(   Ni    i   RX   R   t   special_argst   =(   R   R   R   R   R   t   is_on_function_call_keywordt   find_parens_start_from_insidet   get_primary_atR7   R>   R?   R   R   t   BadIdentifierErrorR   R#   RC   R   R`   Rk   R   Ra   t   FalseR   R   Rt   (   RW   R   RP   R   R   t   function_parenst   primaryt   function_pynameR(   t   param_namesR   RU   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR     sB    	
N(   Rp   Rq   R   R   RX   R   t   kwlistR   R   R   R   R   R   R   R   R   R   R   (    (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR   ^  s   
									R   c           B   s/   e  Z d  Z d d d  Z d   Z d   Z RS(   s$   Sort a list of code assist proposalsc         C   s   | |  _  | d  k r3 d d d d d d d g } n  | |  _ | d  k r` d d	 d
 d d  g } n  t d   t |  D  |  _ d  S(   NRu   R   R   Rm   R   Rl   R   Rd   Rc   Re   R/   c         s   s!   |  ] \ } } | | f Vq d  S(   N(    (   t   .0t   indexRY   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pys	   <genexpr>  s   (   R   R   R   t   dictt	   enumeratet   typerank(   RW   t   code_assist_proposalsR   R   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyRX     s    			c         C   s   i  } x- |  j  D]" } | j | j g   j |  q Wg  } xn |  j D]c } | j | g   } g  | D] } | j |  j k re | ^ qe } | j d |  j	  | j
 |  qF W| S(   s%   Return a list of `CodeAssistProposal`t   key(   R   t
   setdefaultRP   RJ   R   t   getRY   R   t   sortt   _proposal_keyR   (   RW   R   t   proposalR   RP   t   scope_proposals(    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR     s     c         C   s4   d   } |  j  j | j d  | | j  | j f S(   Nc         S   s   t  d   |  D  S(   Nc         s   s!   |  ] } | d  k r d Vq d S(   R   i   N(    (   R   t   c(    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pys	   <genexpr>  s    (   t   sum(   RU   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyt   _underline_count  s    id   (   R   R   RY   RU   (   RW   t	   proposal1R   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR     s    	N(   Rp   Rq   Rr   R   RX   R   R   (    (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR     s   	R$   c           B   sz   e  Z d    Z e e d  Z d   Z d   Z d   Z d   Z d   Z	 e d  Z
 e d  Z d	   Z d
 d  Z RS(   c         C   sg   t  | t j  r |  j |  St  | t j  r> |  j |  St  | t j  rc |  j | j    Sd  S(   N(
   RC   R   R`   t   _get_function_docstringRk   t   _get_class_docstringt   AbstractModulet   _trim_docstringR%   R   (   RW   R(   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR%   %  s    c         C   s   yN t  | t j  r( | d j   } n  t  | t j  sM | d j   } n  Wn t j k
 re d  SX| r t  | t j  r d  St  | t j  r |  j	 | d t
 } | r |  j |  r | j d d  j d d  S| Sd  S(   NRX   R   t
   add_modules   (self)s   ()s   (self, t   ((   RC   R   Rk   R#   R`   R   t   AttributeNotFoundErrorR   t
   PyFunctiont   _get_function_signatureR   t
   _is_methodt   replace(   RW   R(   R*   R+   R   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR)   .  s    c         C   s   |  j  | j   d  } g  | j   D] } | j   ^ q% } d | j   d j |  f | } d | k r | d j   } t | t j  r | d |  j	 |  7} q n  | S(   Ni   s   class %s(%s):

s   , RX   s   

(
   R   R%   t   get_superclassesRK   t   joinR#   RC   R   R`   t   _get_single_function_docstring(   RW   t   pyclasst   contentsRw   t   superst   doct   init(    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR   >  s    %c         C   sf   | g } |  j  |  r= | j |  j | j | j     n  d j g  | D] } |  j |  ^ qJ  S(   Ns   

(   R   R   t   _get_super_methodsRG   RK   R   R   (   RW   t
   pyfunctiont	   functionsRc   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR   J  s    		c         C   s%   t  | t j  o$ t  | j t j  S(   N(   RC   R   R   RG   t   PyClass(   RW   R   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR   R  s    c         C   s6   |  j  |  } |  j | j   d d } | d | S(   NR   i   s   :

(   R   R   R%   (   RW   R   t	   signaturet   docs(    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR   V  s    c         C   s{   g  } xn | j    D]` } | | k rZ | | j   } t | t j  rZ | j |  qZ n  | j |  j | |   q W| S(   N(   R   R#   RC   R   R`   RJ   R   R   (   RW   R   RU   R   t   super_classRc   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR   [  s    c         C   so   |  j  | |  } t | t j  rD t j j |  } | | j   Sd | | j   d j	 | j
    f Sd  S(   Ns   %s(%s)s   , (   t	   _locationRC   R   R   R
   Ry   Rz   t	   to_stringRK   R   Ra   (   RW   R   R   R   t   info(    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR   e  s    c         C   s   g  } | j  } xF | rW t | t j  rW | j | j    | j d  | j  } q W| r t | t j  r | j d |  j |   n  t | t	 j
  r | j d | j   d  q n  d j |  S(   NR   i    R   (   RG   RC   R   R   RJ   RK   R   t   insertt   _get_moduleR    t   BuiltinModuleR   (   RW   R(   R   R   RG   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR   n  s    	 c         C   sH   | j    } | d  k	 rD | j   } | d  k	 rD t j |  d Sn  d S(   NR   R   (   R-   R   R.   R   t   modname(   RW   R   R/   R   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR   |  s    i    c            s#  | s
 d S| j    j   } t j } xF | d D]: } | j   } | r0 t | t |  t |   } q0 q0 W| d j   g } | t j k  r x, | d D] } | j | | j	    q Wn  x | r | d r | j
   q Wx" | r| d r| j
 d  q Wd j   f d   | D  S(   s   The sample code from :PEP:`257`R   i   i    is   
c         3   s   |  ] } d    | Vq d S(   t    N(    (   R   t   line(   R   (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pys	   <genexpr>  s    (   t
   expandtabst
   splitlinest   syst   maxsizet   lstript   minR   R   RJ   t   rstript   popR   (   RW   t	   docstringR   R   t   indentR  t   strippedt   trimmed(    (   R   s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR     s"    	&(   Rp   Rq   R%   R   R)   R   R   R   R   R   R   R   R   R   (    (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR$   #  s   							
		t   TemplateProposalc           B   s   e  Z d    Z RS(   c         C   s<   t  j d t d d t t |   j | d  | |  _ d  S(   Ns   TemplateProposal is deprecated.R   i   t   template(   R   R   R   Rw   R  RX   R  (   RW   RU   R  (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyRX     s    	(   Rp   Rq   RX   (    (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR    s   t   Templatec           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   s#   | |  _  t j d t d d d  S(   Ns   Template is deprecated.R   i   (   R  R   R   R   (   RW   R  (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyRX     s    		c         C   s   g  S(   N(    (   RW   (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyt	   variables  s    c         C   s   |  j  S(   N(   R  (   RW   t   mapping(    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyt
   substitute  s    c         C   s   t  |  j  S(   N(   R   R  (   RW   R  (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyt   get_cursor_location  s    (   Rp   Rq   RX   R  R  R  (    (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyR    s   			(*   R   R  R   t   rope.base.codeanalyzeR7   t   rope.base.evaluatet	   rope.baseR    R   R   R   R   R   R   R   R   t   rope.contribR	   t   rope.refactorR
   R   R   R   R    R%   R   R)   R,   R4   RS   t   objectRT   t   CodeAssistProposalRt   R   R   R   R   R   R$   R  R  (    (    (    s6   lib/python2.7/site-packages/rope/contrib/codeassist.pyt   <module>   sF   	
!		:e	
	)~