B
    °L'W¶h  ã               @   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 d2dd„Zdd„ Zd3dd„Zd4dd„Zd5dd„Zdd„ Zdd„ ZG dd„ deƒZeZG d d!„ d!eƒZd6d"d#„Zd$d%„ Z d&d'„ Z!G d(d)„ d)eƒZ"G d*d+„ d+eƒZ#G d,d-„ d-eƒZ$G d.d/„ d/eƒZ%G d0d1„ d1eƒZ&dS )7é    N)Úbuiltins)Ú
exceptions)Úlibutils)Úpynames)Ú
pynamesdef)Ú	pyobjects)Úpyobjectsdef)Úpyscopes)Úworder)Ú	fixsyntax)Úfunctionutilsé   Tc             C   s2   |dk	rt jdtdd t| |||||d}|ƒ S )ao  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.

    Nz'Codeassist no longer supports templatesé   )Ú
stacklevel)ÚresourceÚmaxfixesÚlater_locals)ÚwarningsÚwarnÚDeprecationWarningÚ_PythonCodeAssist)ÚprojectÚsource_codeÚoffsetr   Z	templatesr   r   Zassist© r   ú6lib/python3.7/site-packages/rope/contrib/codeassist.pyÚcode_assist   s    

r   c             C   s    t  | d¡}| |¡\}}}|S )aN  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.

    T)r
   ÚWorderÚget_splitted_primary_before)r   r   Úword_finderÚ
expressionÚstartingÚstarting_offsetr   r   r   r"   +   s    r"   c             C   s:   t  | |||¡}| |¡}|dkr&dS | ¡ }tƒ  |¡S )zGet the pydocN)r   Ú	FixSyntaxÚ	pyname_atÚ
get_objectÚPyDocExtractorÚget_doc)r   r   r   r   r   ÚfixerÚpynameÚpyobjectr   r   r   r'   =   s    
r'   Fc       
      C   s>   t  | |||¡}| |¡}|dkr&dS | ¡ }	tƒ  |	||¡S )ay  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&   Úget_calltip)
r   r   r   r   r   Úignore_unknownÚremove_selfr(   r)   r*   r   r   r   r+   G   s    
r+   c       	      C   sJ   t  | |||¡}| |¡}|dk	rF| ¡ \}}|dk	rF| ¡  ¡ |fS dS )aS  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$   Úget_definition_locationÚ
get_moduleÚget_resource)	r   r   r   r   r   r(   r)   ÚmoduleÚlinenor   r   r   r.   h   s    

r.   c              O   s(   dd l }tjdtdd |jjj| |ŽS )Nr   z4Use `rope.contrib.findit.find_occurrences()` insteadr   )r   )Zrope.contrib.finditr   r   r   ZcontribZfinditÚfind_occurrences)ÚargsÚkwdsÚroper   r   r   r3   {   s    
r3   c       
      C   sô   |   |¡}tjj ||¡}| ¡ \}}|s.dS | ¡  |¡}g }t|t	j
ƒrdt | ¡ |¡dfg}n"t|t	jƒr†t | ¡ |¡dfg}xL|jrÒt|tjƒr d}	nt|tjƒr²d}	nd}	| |j ¡ |	f¡ |j}qˆW | | ¡ jdf¡ | ¡  |S )a…  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.

    NZ	PARAMETERZVARIABLEZFUNCTIONZCLASSZMODULE)Úget_pymoduler6   ÚbaseÚevaluateZeval_locationr.   Ú	get_scopeÚget_inner_scope_for_lineÚ
isinstancer   ZParameterNamer
   Zget_name_atr0   ZAssignedNameÚparentr	   ZFunctionScopeZ
ClassScopeÚappendr*   Úget_nameZ	real_pathÚreverse)
r   r   r   Zpymodr)   Zdefmodr2   ÚscopeÚnamesZ
scope_typer   r   r   Úget_canonical_path‚   s0    


rC   c               @   s^   e Zd ZdZddd„Zdd„ Zdd„ Zed	d
„ ƒZedd„ ƒZ	dd„ Z
dd„ Zedd„ ƒZdS )ÚCompletionProposala  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 |          |       |          |        |  +

    Nc             C   s   || _ || _|  |¡| _d S )N)Únamer)   Ú
_get_scoperA   )ÚselfrE   rA   r)   r   r   r   Ú__init__Õ   s    zCompletionProposal.__init__c             C   s   d| j | j| jf S )Nz%s (%s, %s))rE   rA   Útype)rG   r   r   r   Ú__str__Ú   s    zCompletionProposal.__str__c             C   s   t | ƒS )N)Ústr)rG   r   r   r   Ú__repr__Ý   s    zCompletionProposal.__repr__c             C   sF   | j }t|tjƒr| ¡ }t|tjƒrB| ¡ }t|tjƒrB| 	¡ S dS )ztThe names of the parameters the function takes.

        Returns None if this completion is not a function.
        N)
r)   r<   r   ÚImportedNameZ_get_imported_pynameÚDefinedNamer%   r   ÚAbstractFunctionÚget_param_names)rG   r)   r*   r   r   r   Ú
parametersà   s    zCompletionProposal.parametersc             C   s¬   | j }t|tjƒrX| ¡ }t|tjƒr*dS t|tjƒr:dS t|tjƒsRt|tjƒr¨dS nPt|tj	ƒrhdS t|tj
ƒs€t|tjƒr¨| ¡ }t|tjƒr˜dS t|tjƒr¨dS dS )NÚfunctionÚclassÚinstancer1   )r)   r<   r   ÚBuiltinNamer%   ZBuiltinFunctionZBuiltinClassZBuiltinObjectr   ÚImportedModulerM   rN   r   rO   ÚAbstractClass)rG   r)   r*   r   r   r   rI   î   s(    zCompletionProposal.typec             C   s6   t | jtjƒrdS t | jtjƒs.t | jtjƒr2dS |S )NÚbuiltinÚimported)r<   r)   r   rU   r   rV   rM   )rG   rA   r   r   r   rF     s    zCompletionProposal._get_scopec             C   s0   | j s
dS | j  ¡ }t|dƒs"dS | j  ¡  ¡ S )zYGet the proposed object's docstring.

        Returns None if it can not be get.
        Nr'   )r)   r%   Úhasattrr'   )rG   r*   r   r   r   r'     s    

zCompletionProposal.get_docc             C   s   t  d¡ | jS )NzAthe proposal's `kind` property is deprecated, use `scope` instead)r   r   rA   )rG   r   r   r   Úkind  s    
zCompletionProposal.kind)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rH   rJ   rL   ÚpropertyrQ   rI   rF   r'   r[   r   r   r   r   rD   ¼   s   
rD   c                   s(   e Zd ZdZ‡ fdd„Zdd„ Z‡  ZS )ÚNamedParamProposalzÊ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                s*   || _ d| }tt| ƒ |d¡ || _d S )Nz%s=Úparameter_keyword)ÚargnameÚsuperra   rH   Ú	_function)rG   rE   rR   )Ú	__class__r   r   rH   +  s    zNamedParamProposal.__init__c             C   s4   t j | j¡}x |jD ]\}}| j|kr|S qW dS )zƒGet a string representation of a param's default value.

        Returns None if there is no default value for this param.
        N)r   ÚDefinitionInfoÚreadre   Zargs_with_defaultsrc   )rG   ZdefinfoÚargÚdefaultr   r   r   Úget_default1  s
    
zNamedParamProposal.get_default)r\   r]   r^   r_   rH   rk   Ú__classcell__r   r   )rf   r   ra   $  s   ra   c             C   s   t | ||ƒ}| ¡ S )aº  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.)
    )Ú_ProposalSorterÚget_sorted_proposal_list)Ú	proposalsÚ	scopeprefÚtypeprefZsorterr   r   r   Úsorted_proposals=  s    rr   c             C   s0   t  | d¡}| |¡\}}}|r,|d | S |S )z!Return the expression to completeTÚ.)r
   r   r   )r   r   r   r    r!   r"   r   r   r   Ústarting_expressionN  s
    rt   c               C   s   t jdtdd i S )Nz"default_templates() is deprecated.r   )r   )r   r   r   r   r   r   r   Údefault_templatesX  s    
ru   c               @   sn   e Zd Zddd„ZejZdd„ Zdd	„ Zd
d„ Z	dd„ Z
ddd„Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )r   Nr   Tc             C   sH   || _ || _|| _|| _|| _t |d¡| _| j |¡\| _	| _
| _d S )NT)r   Úcoder   r   r   r
   r   r   r   r    r!   r   )rG   r   r   r   r   r   r   r   r   r   rH   `  s    z_PythonCodeAssist.__init__c             C   s>   |d }x,|dkr4||   ¡ s*|| dkr4|d8 }q
W |d S )Nr   r   Ú_)Úisalnum)rG   r   r   Zcurrent_offsetr   r   r   Ú_find_starting_offsetm  s
    z'_PythonCodeAssist._find_starting_offsetc             C   s2   g }x(| j D ]}| |¡r| t|dƒ¡ qW |S )NÚkeyword)ÚkeywordsÚ
startswithr>   rD   )rG   r!   ÚresultÚkwr   r   r   Ú_matching_keywordst  s
    
z$_PythonCodeAssist._matching_keywordsc             C   sV   | j t| jƒkrg S t|  ¡  ¡ ƒ}| j ¡ dkrR| j ¡ dkrR| 	|  
| j¡¡ |S )NÚ )r   Úlenrv   ÚlistÚ_code_completionsÚvaluesr    Ústripr!   Úextendr   )rG   Zcompletionsr   r   r   Ú__call__{  s    z_PythonCodeAssist.__call__c       	      C   sz   i }t jj || j¡}|d k	rv| ¡ }d}t|tjtj	fƒr@d}x4| 
¡  ¡ D ]$\}}| | j¡rNt|||ƒ||< qNW |S )NÚ	attributerY   )r6   r8   r9   Úeval_strr    r%   r<   r   ZPyModuleZ	PyPackageZget_attributesÚitemsr|   r!   rD   )	rG   Úmodule_scopeZholding_scoper}   Zfound_pynameÚelementÚcompl_scoperE   r)   r   r   r   Ú_dotted_completionsƒ  s    

z%_PythonCodeAssist._dotted_completionsc             C   s˜   |j d k	r|  |j |¡ |d kr*| ¡ }n| ¡ }x`| ¡ D ]T\}}| | j¡r<d}| ¡ dkrdd}|d ks€| js€|  	|||¡s<t
|||ƒ||< q<W d S )NÚlocalZModuleÚglobal)r=   Ú_undotted_completionsZget_propagated_namesZ	get_namesrŠ   r|   r!   Zget_kindr   Ú_is_defined_afterrD   )rG   rA   r}   r2   rB   rE   r)   r   r   r   r   r‘   “  s    

z'_PythonCodeAssist._undotted_completionsc             C   s^   | j  | j¡}|d kri S |  ||¡}i }x.|D ]&}| | j¡r0t|d|| d||< q0W |S )Nr   )rA   r)   )r   Zget_from_moduler   Ú_find_moduler|   r!   rD   )rG   ÚpymoduleÚmodule_namer}   rE   r   r   r   Ú_from_import_completions¤  s    
z*_PythonCodeAssist._from_import_completionsc             C   s<   d}x|| dkr|d7 }qW t  |||d … |¡}| ¡ S )Nr   rs   r   )r   rV   r%   )rG   r”   r•   Zdotsr)   r   r   r   r“   °  s    z_PythonCodeAssist._find_modulec             C   sV   |  ¡ }|d k	rR|d d k	rR|d |j ¡ krR||d   krJ| ¡ krRn ndS d S )Nr   r   T)r.   r*   r/   Zget_end)rG   rA   r)   r2   Úlocationr   r   r   r’   ¸  s
     z#_PythonCodeAssist._is_defined_afterc             C   sÞ   | j  dd| j¡d }t | j| j | j| j¡}| ¡ }| 	¡ }|j
}| d¡}i }t ||¡}t ||d  ¡}	| ||	¡}
| j | j¡r”|  |¡S | j ¡ dkr¶| |  ||
¡¡ n$| |  |j|
¡¡ | j|
||d |S )NÚ
r   r   r€   )r2   )rv   Úcountr   r   r#   r   r   r   r7   r:   r   ÚsplitZ_logical_startZ_get_line_indentsr;   r   Zis_a_name_after_from_importr–   r    r…   ÚupdaterŽ   Ú_keyword_parametersr*   r‘   )rG   r2   r(   r”   r‹   rv   Úlinesr}   ÚstartÚindentsZinner_scoper   r   r   rƒ   ¿  s&    

z#_PythonCodeAssist._code_completionsc             C   s.  | j }|dkri S t | jd¡}| |d ¡r*| |d ¡}| |d ¡}ytjj	 
||¡}W n tjk
rv   i S X |d k	r*| ¡ }t|tjƒr˜n6t|tjƒrºd|krº|d  ¡ }nd|krÎ|d  ¡ }t|tjƒr*g }	|	 |jdd¡ i }
x.|	D ]&}| | j¡ rüt||ƒ|
|d <  qüW |
S i S )	Nr   Tr   rH   r‡   F)Zspecial_argsú=)r   r
   r   rv   Zis_on_function_call_keywordZfind_parens_start_from_insideZget_primary_atr6   r8   r9   r‰   r   ZBadIdentifierErrorr%   r<   r   rO   rW   r†   rP   r|   r!   ra   )rG   r”   rA   r   r   Zfunction_parensZprimaryZfunction_pynamer*   Zparam_namesr}   rE   r   r   r   rœ   Õ  sB    


z%_PythonCodeAssist._keyword_parameters)Nr   T)N)r\   r]   r^   rH   rz   Úkwlistr{   ry   r   r‡   rŽ   r‘   r–   r“   r’   rƒ   rœ   r   r   r   r   r   ^  s    


r   c               @   s*   e Zd ZdZd	dd„Zdd„ Zdd„ ZdS )
rm   z$Sort a list of code assist proposalsNc             C   sX   || _ |d kr dddddddg}|| _|d kr<dd	d
dd g}tdd„ t|ƒD ƒƒ| _d S )Nrb   r   r   rY   rˆ   rX   rz   rS   rR   rT   r1   c             s   s   | ]\}}||fV  qd S )Nr   )Ú.0ÚindexrI   r   r   r   ú	<genexpr>  s   z+_ProposalSorter.__init__.<locals>.<genexpr>)ro   rp   ÚdictÚ	enumerateÚtyperank)rG   Zcode_assist_proposalsrp   rq   r   r   r   rH   ý  s    
z_ProposalSorter.__init__c                sv   i }x"ˆ j D ]}| |jg ¡ |¡ qW g }xDˆ jD ]:}| |g ¡}‡ fdd„|D ƒ}|jˆ jd | |¡ q4W |S )z%Return a list of `CodeAssistProposal`c                s   g | ]}|j ˆ jkr|‘qS r   )rI   r§   )r¢   Úproposal)rG   r   r   ú
<listcomp>  s    z<_ProposalSorter.get_sorted_proposal_list.<locals>.<listcomp>)Úkey)	ro   Ú
setdefaultrA   r>   rp   ÚgetÚsortÚ_proposal_keyr†   )rG   ro   r¨   r}   rA   Zscope_proposalsr   )rG   r   rn     s    z(_ProposalSorter.get_sorted_proposal_listc             C   s&   dd„ }| j  |jd¡||jƒ|jfS )Nc             S   s   t dd„ | D ƒƒS )Nc             s   s   | ]}|d krdV  qdS )rw   r   Nr   )r¢   Úcr   r   r   r¤     s    zJ_ProposalSorter._proposal_key.<locals>._underline_count.<locals>.<genexpr>)Úsum)rE   r   r   r   Ú_underline_count  s    z7_ProposalSorter._proposal_key.<locals>._underline_countéd   )r§   r¬   rI   rE   )rG   Z	proposal1r±   r   r   r   r®     s    z_ProposalSorter._proposal_key)NN)r\   r]   r^   r_   rH   rn   r®   r   r   r   r   rm   ú  s   
rm   c                   st   e Zd Zdd„ Zddd„Z‡ fdd„Zdd	„ Zd
d„ Zdd„ Zdd„ Z	ddd„Z
ddd„Zdd„ Zddd„Z‡  ZS )r&   c             C   sJ   t |tjƒr|  |¡S t |tjƒr,|  |¡S t |tjƒrF|  | ¡ ¡S d S )N)	r<   r   rO   Ú_get_function_docstringrW   Ú_get_class_docstringÚAbstractModuleÚ_trim_docstringr'   )rG   r*   r   r   r   r'   %  s    

zPyDocExtractor.get_docFc             C   s¤   y4t |tjƒr|d  ¡ }t |tjƒs2|d  ¡ }W n tjk
rJ   d S X |r`t |tjƒs`d S t |tjƒr | j|dd}|rœ|  	|¡rœ| 
dd¡ 
dd¡S |S d S )	NrH   r‡   T)Ú
add_modulez(self)z()z(self, ú()r<   r   rW   r%   rO   r   ZAttributeNotFoundErrorÚ
PyFunctionÚ_get_function_signatureÚ
_is_methodÚreplace)rG   r*   r,   r-   r}   r   r   r   r+   .  s    zPyDocExtractor.get_calltipc                sv   |   | ¡ d¡}‡ fdd„| ¡ D ƒ}d| ¡ d |¡f | }d|krr|d  ¡ }t|tjƒrr|d|  	|¡ 7 }|S )Nr   c                s   g | ]}|  ¡ ‘qS r   )r?   )r¢   rd   )rf   r   r   r©   @  s    z7PyDocExtractor._get_class_docstring.<locals>.<listcomp>zclass %s(%s):

z, rH   z

)
r¶   r'   Úget_superclassesr?   Újoinr%   r<   r   rO   Ú_get_single_function_docstring)rG   ÚpyclassÚcontentsZsupersÚdocZinit)rf   r   r   r´   >  s    z#PyDocExtractor._get_class_docstringc                s@   |g}ˆ   |¡r(| ˆ  |j| ¡ ¡¡ d ‡ fdd„|D ƒ¡S )Nz

c                s   g | ]}ˆ   |¡‘qS r   )r¿   )r¢   rR   )rG   r   r   r©   O  s   z:PyDocExtractor._get_function_docstring.<locals>.<listcomp>)r»   r†   Ú_get_super_methodsr=   r?   r¾   )rG   Ú
pyfunctionZ	functionsr   )rG   r   r³   J  s    
z&PyDocExtractor._get_function_docstringc             C   s   t |tjƒot |jtjƒS )N)r<   r   r¹   r=   ZPyClass)rG   rÄ   r   r   r   r»   R  s    zPyDocExtractor._is_methodc             C   s(   |   |¡}| j| ¡ dd}|d | S )Nr   )rŸ   z:

)rº   r¶   r'   )rG   rÄ   Z	signatureZdocsr   r   r   r¿   V  s    
z-PyDocExtractor._get_single_function_docstringc             C   sV   g }xL|  ¡ D ]@}||kr<||  ¡ }t|tjƒr<| |¡ | |  ||¡¡ qW |S )N)r½   r%   r<   r   rO   r>   r†   rÃ   )rG   rÀ   rE   r}   Zsuper_classrR   r   r   r   rÃ   [  s    
z!PyDocExtractor._get_super_methodsc             C   sR   |   ||¡}t|tjƒr0tj |¡}|| ¡  S d|| ¡  d 	| 
¡ ¡f S d S )Nz%s(%s)z, )Ú	_locationr<   r   r¹   r   rg   rh   Z	to_stringr?   r¾   rP   )rG   rÄ   r·   r—   Úinfor   r   r   rº   e  s    z&PyDocExtractor._get_function_signaturec             C   sŠ   g }|j }x2|r<t|tjƒs<| | ¡ ¡ | d¡ |j }qW |r€t|tjƒr`| d|  |¡¡ t|t	j
ƒr€| d| ¡ d ¡ d |¡S )Nrs   r   r€   )r=   r<   r   rµ   r>   r?   r¹   ÚinsertÚ_get_moduler   ZBuiltinModuler¾   )rG   r*   r·   r—   r=   r   r   r   rÅ   n  s    

zPyDocExtractor._locationc             C   s2   |  ¡ }|d k	r.| ¡ }|d k	r.t |¡d S dS )Nrs   r€   )r/   r0   r   Úmodname)rG   rÄ   r1   r   r   r   r   rÈ   |  s    zPyDocExtractor._get_moduler   c                sä   |sdS |  ¡  ¡ }tj}x6|dd… D ]&}| ¡ }|r(t|t|ƒt|ƒ ƒ}q(W |d  ¡ g}|tjk r–x*|dd… D ]}| ||d…  	¡ ¡ qxW x|r®|d s®| 
¡  q˜W x|rÊ|d sÊ| 
d¡ q²W d ‡ fdd„|D ƒ¡S )	zThe sample code from :PEP:`257`r€   r   Nr   éÿÿÿÿr˜   c             3   s   | ]}d ˆ  | V  qdS )ú Nr   )r¢   Úline)rŸ   r   r   r¤   œ  s    z1PyDocExtractor._trim_docstring.<locals>.<genexpr>)Ú
expandtabsÚ
splitlinesÚsysÚmaxsizeÚlstripÚminr   r…   r>   ÚrstripÚpopr¾   )rG   Z	docstringrŸ   r   ÚindentrÌ   ÚstrippedZtrimmedr   )rŸ   r   r¶   „  s"    
zPyDocExtractor._trim_docstring)FF)F)F)r   )r\   r]   r^   r'   r+   r´   r³   r»   r¿   rÃ   rº   rÅ   rÈ   r¶   rl   r   r   )rf   r   r&   #  s   	


	
r&   c                   s   e Zd Z‡ fdd„Z‡  ZS )ÚTemplateProposalc                s,   t jdtdd tt| ƒ |d¡ || _d S )NzTemplateProposal is deprecated.r   )r   Útemplate)r   r   r   rd   r×   rH   rØ   )rG   rE   rØ   )rf   r   r   rH   ¢  s    
zTemplateProposal.__init__)r\   r]   r^   rH   rl   r   r   )rf   r   r×   ¡  s   r×   c               @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚTemplatec             C   s   || _ tjdtdd d S )NzTemplate is deprecated.r   )r   )rØ   r   r   r   )rG   rØ   r   r   r   rH   «  s    zTemplate.__init__c             C   s   g S )Nr   )rG   r   r   r   Ú	variables°  s    zTemplate.variablesc             C   s   | j S )N)rØ   )rG   Úmappingr   r   r   Ú
substitute³  s    zTemplate.substitutec             C   s
   t | jƒS )N)r   rØ   )rG   rÛ   r   r   r   Úget_cursor_location¶  s    zTemplate.get_cursor_locationN)r\   r]   r^   rH   rÚ   rÜ   rÝ   r   r   r   r   rÙ   ©  s   rÙ   )NNr   T)Nr   )Nr   FF)Nr   )NN)'rz   rÏ   r   Zrope.base.codeanalyzer6   Zrope.base.evaluateZ	rope.baser   r   r   r   r   r   r   r	   r
   Zrope.contribr   Zrope.refactorr   r   r"   r'   r+   r.   r3   rC   ÚobjectrD   ZCodeAssistProposalra   rr   rt   ru   r   rm   r&   r×   rÙ   r   r   r   r   Ú<module>   sH    


 
!
:e

 )~