Your IP : 216.73.216.196
B
��\�h � @ s� d Z ddlZddlZddlZddlZddlmZmZ ddlm Z ddlm
Z ddlmZ ddlm
Z ddlmZ dd lmZ dd
lmZ ddlmZ ddlmZ dd
lmZ ejZdZdd� Zdd� Zdd� Ze�� Zdd� ZG dd� dejej �Z!G dd� de!�Z"G dd� de!�Z#G dd� de#�Z$G dd � d e#�Z%G d!d"� d"e#�Z&G d#d$� d$ej �Z'G d%d&� d&e'e#�Z(d'd(� Z)G d)d*� d*ej*e!�Z+G d+d,� d,ej,ej-e+�Z.G d-d.� d.e.�Z/d9d/d0�Z0d:d1d2�Z1d;d3d4�Z2d5d6� Z3G d7d8� d8ej*e!ej-�Z4dS )<z�
This module contains the classes for "scoped" node, i.e. which are opening a
new local scope in the language definition : Module, ClassDef, FunctionDef (and
Lambda, GeneratorExp, DictComp and SetComp to some extent).
� N)�Optional�List)�bases)�context)�
exceptions)�
decorators)�objectmodel)�
dunder_lookup)�manager)�mixins)�node_classes)�util)�__iter__�__getitem__c C s� g }x�dd� | D �} | s|S x:| D ]2}|d }x$| D ]}||dd� kr4d}P q4W P q"W |snt jd| ||d��|�|� x| D ]}|d |kr~|d= q~W qW dS )z�Merges MROs in *sequences* to a single MRO using the C3 algorithm.
Adapted from http://www.python.org/download/releases/2.3/mro/.
c S s g | ]}|r|�qS � r )�.0�sr r �E/opt/alt/python37/lib/python3.7/site-packages/astroid/scoped_nodes.py�
<listcomp>= s z_c3_merge.<locals>.<listcomp>r � NzTCannot create a consistent method resolution order for MROs {mros} of class {cls!r}.)�message�mros�clsr )r ZInconsistentMroError�append)� sequencesr r �result�s1� candidate�s2�seqr r r � _c3_merge5 s.
r c C sF x@| D ]8}dd� |D �}t |�t t|��krtjd| ||d��qW d S )Nc S s g | ]}|j r|j|�� f�qS r )�name�lineno�qname)r �noder r r r ] s z*_verify_duplicates_mro.<locals>.<listcomp>z,Duplicates found in MROs {mros} for {cls!r}.)r r r r )�len�setr ZDuplicateBasesError)r r r �sequence�namesr r r �_verify_duplicates_mro[ s
r) c C s8 t | t�r4| jdkr t�| |�S | jdkr4t�| �S | S )N�classmethod�staticmethod)�
isinstance�FunctionDef�typer �BoundMethodZ
UnboundMethod)�n�klassr r r �function_to_methodg s
r2 c C sJ t �t�}| dkr|dfS y|j| }W n tk
r@ d}Y nX ||fS )z�lookup a name into the builtin module
return the list of matching statements and the astroid for the builtin
module
�__dict__r )�MANAGERZast_from_module�builtins�locals�KeyError)r! Zbuiltin_astroid�stmtsr r r �builtin_lookups s
r9 c @ s� e Zd ZdZi Zdd� Zdd� Zdd� Zdd d
�Zdd� Z e Z
d
d� Zddd�Zdd� Z
dd� Zdd� Zdd� Zdd� Zdd� ZdS ) �LocalsDictNodeNGz� this class provides locals handling common to Module, FunctionDef
and ClassDef nodes, including a dict like interface for direct access
to locals information
c C s( | j dkr| jS d| j �� �� | jf S )z�Get the 'qualified' name of the node.
For example: module.name, module.class.name ...
:returns: The qualified name.
:rtype: str
Nz%s.%s)�parentr! �framer# )�selfr r r r# � s
zLocalsDictNodeNG.qnamec C s | S )z�The first parent frame node.
A frame node is a :class:`Module`, :class:`FunctionDef`,
or :class:`ClassDef`.
:returns: The first parent frame node.
:rtype: Module or FunctionDef or ClassDef
r )r= r r r r<