Your IP : 216.73.216.196


Current Path : /opt/alt/python37/lib/python3.7/site-packages/astroid/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/astroid/__pycache__/mixins.cpython-37.opt-1.pyc

B

��\��@s�dZddlZddlmZddlmZGdd�d�ZGdd�d�ZGd	d
�d
�ZGdd�de�ZGd
d�de�Z	Gdd�d�Z
Gdd�d�ZdS)z:This module contains some mixins for the different nodes.
�N)�
decorators)�
exceptionsc@s(eZdZdZejdd��Zddd�ZdS)�BlockRangeMixInzoverride block range cCs|jS)N)�lineno)�self�r�?/opt/alt/python37/lib/python3.7/site-packages/astroid/mixins.py�blockstart_tolinenosz#BlockRangeMixIn.blockstart_tolinenoNcCsR||jkr||fS|rD||djkr2||djfS||djdfS||pN|jfS)z^handle block line numbers range for try/finally, for, if and while
        statements
        r����)Z
fromlinenoZtolineno)rrZorelseZlastrrr�_elsed_block_ranges
z"BlockRangeMixIn._elsed_block_range)N)�__name__�
__module__�__qualname__�__doc__r�cachedpropertyr	rrrrrrsrc@s eZdZdZdd�Zdd�ZdS)�FilterStmtsMixinz1Mixin for statement filtering and assignment typecCs|��|kr|gdfS|dfS)z@method used in _filter_stmts to get statements and trigger breakTF)�	statement)r�_�node�_stmts�mystmtrrr�_get_filtered_stmts,s
z$FilterStmtsMixin._get_filtered_stmtscCs|S)Nr)rrrr�assign_type4szFilterStmtsMixin.assign_typeN)r
rrrrrrrrrr)src@seZdZdd�Zdd�ZdS)�AssignTypeMixincCs|S)Nr)rrrrr9szAssignTypeMixin.assign_typecCs.||kr|dfS|��|kr&|gdfS|dfS)zmethod used in filter_stmtsTF)r)rZlookup_noderrrrrrr<s

z#AssignTypeMixin._get_filtered_stmtsN)r
rrrrrrrrr8src@seZdZdd�ZdS)�ParentAssignTypeMixincCs
|j��S)N)�parentr)rrrrrHsz!ParentAssignTypeMixin.assign_typeN)r
rrrrrrrrGsrc@s*eZdZdZdd�Zd	dd�Zdd�ZdS)
�ImportFromMixinzMixIn for From and Import NodescCs|S)Nr)r�frame�namerrr�_infer_nameOszImportFromMixin._infer_nameNcCsP|��}t|dd�}|dkr"|j}|�||�|jkr8|S|j|||oJ|dkd�S)zOreturn the ast for a module whose name is <modname> imported by <self>
        �levelNr)r!Z
relative_only)�root�getattr�modnameZrelative_to_absolute_namer�
import_module)rr$Zmymoduler!rrr�do_import_moduleRsz ImportFromMixin.do_import_modulecCsXxB|jD]8\}}|dkr|S|s4|�dd�d}|}||kr|SqWtjd||d��dS)zget name from 'as' name�*�.rrz:Could not find original name for {attribute} in {target!r})�targetZ	attributeN)�names�splitrZAttributeInferenceError)rZasnamerZ_asnamerrr�	real_namegszImportFromMixin.real_name)N)r
rrrr r&r,rrrrrLs
rc@s<eZdZdZejdd��Zdd�Zdd�Zej	dd	��Z
d
S)�MultiLineBlockMixina.Mixin for nodes with multi-line blocks, e.g. For and FunctionDef.
    Note that this does not apply to every node with a `body` field.
    For instance, an If node has a multi-line body, but the body of an
    IfExpr is not multi-line, and hence cannot contain Return nodes,
    Assign nodes, etc.
    cst�fdd��jD��S)Nc3s|]}t�|�VqdS)N)r#)�.0Zfield)rrr�	<genexpr>�sz9MultiLineBlockMixin._multi_line_blocks.<locals>.<genexpr>)�tupleZ_multi_line_block_fields)rr)rr�_multi_line_blocks�sz&MultiLineBlockMixin._multi_line_blocksccs8x2|jD](}x"|D]}|jrq|��EdHqWqWdS)N)r1Zis_function� _get_return_nodes_skip_functions)r�block�
child_noderrrr2�s

z4MultiLineBlockMixin._get_return_nodes_skip_functionsccs8x2|jD](}x"|D]}|jrq|��EdHqWqWdS)N)r1Z	is_lambda�_get_yield_nodes_skip_lambdas)rr3r4rrrr5�s

z1MultiLineBlockMixin._get_yield_nodes_skip_lambdascCs dd�|jD�}ttj�|��S)Ncss |]}|D]}|��Vq
qdS)N)�_get_assign_nodes)r.r3r4rrrr/�sz8MultiLineBlockMixin._get_assign_nodes.<locals>.<genexpr>)r1�list�	itertools�chain�
from_iterable)rZchildren_assign_nodesrrrr6�s
z%MultiLineBlockMixin._get_assign_nodesN)r
rrrrrr1r2r5�cachedr6rrrrr-xs
r-c@seZdZdZdd�ZdS)�NoChildrenMixinz,Mixin for nodes with no children, e.g. Pass.ccsdEdHdS)Nrr)rrrr�get_children�szNoChildrenMixin.get_childrenN)r
rrrr=rrrrr<�sr<)rr8Zastroidrrrrrrrr-r<rrrr�<module>s,$