ok

Mini Shell

Direktori : /opt/alt/python36/lib64/python3.6/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/idlelib/__pycache__/_pyclbr.cpython-36.pyc

3

*j�a_;�@s�dZddlZddlZddlZddlZddlmZmZm	Z	ddddgZ
iZGdd	�d	�ZGd
d�de�Z
Gdd�de�Zdd
�Zddd�Zddd�Zddd�Zd dd�Zdd�Zdd�Zdd�Zdd�Zedkr�e�dS)!aParse a Python module and describe its classes and functions.

Parse enough of a Python file to recognize imports and class and
function definitions, and to find out the superclasses of a class.

The interface consists of a single function:
    readmodule_ex(module, path=None)
where module is the name of a Python module, and path is an optional
list of directories where the module is to be searched.  If present,
path is prepended to the system search path sys.path.  The return value
is a dictionary.  The keys of the dictionary are the names of the
classes and functions defined in the module (including classes that are
defined via the from XXX import YYY construct).  The values are
instances of classes Class and Function.  One special key/value pair is
present for packages: the key '__path__' has a list as its value which
contains the package search path.

Classes and Functions have a common superclass: _Object.  Every instance
has the following attributes:
    module  -- name of the module;
    name    -- name of the object;
    file    -- file in which the object is defined;
    lineno  -- line in the file where the object's definition starts;
    parent  -- parent of this object, if any;
    children -- nested objects contained in this object.
The 'children' attribute is a dictionary mapping names to objects.

Instances of Function describe functions with the attributes from _Object.

Instances of Class describe classes with the attributes from _Object,
plus the following:
    super   -- list of super classes (Class instances if possible);
    methods -- mapping of method names to beginning line numbers.
If the name of a super class is not recognized, the corresponding
entry in the list of super classes is not a class instance but a
string giving the name of the super class.  Since import statements
are recognized and imported modules are scanned as well, this
shouldn't happen often.
�N)�NAME�DEDENT�OP�
readmodule�
readmodule_ex�Class�Functionc@s eZdZdZdd�Zdd�ZdS)�_Objectz*Informaton about Python class or function.cCs(||_||_||_||_||_i|_dS)N)�module�name�file�lineno�parent�children)�selfr
rrr
r�r�4/opt/alt/python36/lib64/python3.6/idlelib/_pyclbr.py�__init__7sz_Object.__init__cCs||j|<dS)N)r)rr�objrrr�	_addchild?sz_Object._addchildN)�__name__�
__module__�__qualname__�__doc__rrrrrrr	5sr	c@seZdZdZddd�ZdS)rz7Information about a Python function, including methods.NcCstj||||||�dS)N)r	r)rr
rrr
rrrrrEszFunction.__init__)N)rrrrrrrrrrCscs*eZdZdZd�fdd�	Zdd�Z�ZS)rz!Information about a Python class.Ncs0tj||||||�|dkr gn||_i|_dS)N)r	r�super�methods)rr
rrrr
r)�	__class__rrrKszClass.__init__cCs||j|<dS)N)r)rrr
rrr�
_addmethodPszClass._addmethod)N)rrrrrr�
__classcell__rr)rrrIscCs:t|j||j||�}|j||�t|t�r6|j||�|S)z*Return a Function after nesting within ob.)rr
rr�
isinstancerr)�ob�	func_namer
Znewfuncrrr�_nest_functionTs

r"cCs&t|j|||j||�}|j||�|S)z'Return a Class after nesting within ob.)rr
rr)r �
class_namer
rZnewclassrrr�_nest_class\sr$cCs:i}x0t||pg�j�D]\}}t|t�r|||<qW|S)z�Return Class objects for the top-level classes in module.

    This is the original interface, before Functions were added.
    )�_readmodule�itemsrr)r
�path�res�key�valuerrrrbs

cCst||p
g�S)z�Return a dictionary with all functions and classes in module.

    Search for module in PATH + sys.path.
    If possible, include imported superclasses.
    Do this by reading source, without importing (and executing) it.
    )r%)r
r'rrrrnscCs`|dk	rd||f}n|}|tkr*t|Si}|tjkrL|dkrL|t|<|S|jd�}|dkr�|d|�}||dd�}t|||�}|dk	r�d||f}d|kr�tdj|���t||d|�Sd}	|dk	r�|}
n
|tj}
tj	j
||
�}|t|<|jdk	�r|j|d<y|jj
|�}|dk�r$|SWnttfk
�r@|SX|jj|�}
t|||
|||�S)a.Do the hard work for readmodule[_ex].

    If inpackage is given, it must be the dotted name of the package in
    which we are searching for a submodule, and then PATH must be the
    package search path; otherwise, we are searching for a top-level
    module, and path is combined with sys.path.
    Nz%s.%s�.r��__path__zNo package named {})�_modules�sys�builtin_module_names�rfindr%�ImportError�formatr'�	importlib�util�_find_spec_from_path�submodule_search_locations�loader�
get_source�AttributeError�get_filename�_create_tree)r
r'�	inpackage�
fullmodule�tree�i�packageZ	submoduler�fZsearch_path�spec�source�fnamerrrr%wsF	



r%c!Csltj|�}g}tj|j�}�y,�x$|D�]\}	}
}}}
|	tkrh|\}}x|rd|dd|krd|d=qHWq&|
dk�r|\}}x|r�|dd|kr�|d=q|Wt|�dd�\}	}}|	tkr�q&d}|r�|dd}t|||�}nt	||||�}|||<|j
||f�q&|
dk�r�|\}}x$|�r8|dd|k�r8|d=�qWt|�dd�\}	}}|	tk�r\q&t|�dd�\}	}
}d}|
dk�r�g}d}g}�xt|�dd�\}	}
}|
dk�r2|dk�r2d
j|�}||k�r�||}nL|jd�}t
|�dk�r$|d}|d}|tk�r$t|}||k�r$||}|j
|�g}|
dk�rF|d7}nX|
dk�rf|d8}|dk�r�Pn8|
d	k�r||dk�r|n"|	ttfk�r�|dk�r�|j
|
��q�W|}|�r�|dd}t||||�}nt|||||�}|||<|j
||f�q&|
d
k�r�|ddk�r�t|�}xl|D]d\}}yL|dk�r8t||�n2yt|||�Wn tk
�rht|g�YnXWnYnX�qWq&|
dkr&|ddkr&t|�\}}
|s&|
d
k�r�q&t|�}yt|||�}Wnw&YnXxd|D]\\}} ||k�r|||| �p|<n4|dk�r�x(|D] }|ddk�r||||<�qW�q�Wq&WWntk
�r^YnX|j�|S)a�Return the tree for a particular module.

    fullmodule (full module name), inpackage+module, becomes o.module.
    path is passed to recursive calls of _readmodule.
    fname becomes o.file.
    source is tokenized.  Imports cause recursive calls to _readmodule.
    tree is {} or {'__path__': <submodule search locations>}.
    inpackage, None or string, is passed to recursive calls of _readmodule.

    The effect of recursive calls is mutation of global _modules.
    r,�defr�N�class�(�)�,�r+��import�from�*�_���rRrRrRrRrRrR)rJrK���rRrR)�io�StringIO�tokenize�generate_tokens�readliner�nextrr"r�append�join�split�lenr.rr$r�_getnamelistr%r2�_getname�
StopIteration�close)!r>r'rErDr?r=rB�stack�g�	tokentype�token�startZ_end�_liner
Z
thisindentr!Zcur_funcZcur_objr#Zinherit�names�levelr�n�c�m�dZ	cur_class�modules�modZ_mod2Zn2rrrr<�s�




















 r<cCstg}xjt|�\}}|sP|dkr.t|�\}}nd}|j||f�x |dkr`d|kr`t|�d}qBW|dkrPqW|S)z�Return list of (dotted-name, as-name or None) tuples for token source g.

    An as-name is the name that follows 'as' in an as clause.
    �asNrK�
r,)r_rZrY)rcrhrreZname2rrrr^Csr^cCs�g}t|�dd�\}}|tkr0|dkr0d|fS|j|�xJt|�dd�\}}|dkrZPt|�dd�\}}|tkrxP|j|�q<Wdj|�|fS)zBReturn (dotted-name or None, next-token) tuple for token source g.rrMrPNr+)rYrrZr[)rc�partsrdrerrrr_Ys
r_c
Csbddl}ytjd}Wnt}YnX|jj|�rj|jj|�g}|jj|�}|j�j	d�rn|dd�}ng}t
||�}dd�}t|j�|dd	�}d
}x�|�r\|j
�}t|t�r�q�t|d�s�d|_t|t��rt|jj�|dd	�}x|D]}	|j||	_q�W|j|�t|t��r4tdjd
|j|j|j|j��q�t|t�r�tdjd
|j|j|j��q�WdS)z?Print module output (default this file) for quick visual check.rNr,z.pyrGcSst|dd�S)Nr
r)�getattr)�arrr�<lambda>zsz_main.<locals>.<lambda>T)r)�reverserM�indentz{}class {} {} {}� z{}def {} {}���)�osr/�argv�__file__r'�exists�dirname�basename�lower�endswithr�sorted�values�popr�list�hasattrrwr	r�extendr�printr3rrr
r)
rzror'r?Z
lineno_keyZobjsZindent_levelrZnew_objsr rrr�_mainks@








r��__main__)N)N)N)N)rrTr/�importlib.utilr4rVrerrr�__all__r.r	rrr"r$rrr%r<r^r_r�rrrrr�<module>(s,


	
=&

Zerion Mini Shell 1.0