Your IP : 18.118.186.156


Current Path : /opt/alt/python310/lib64/python3.10/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/__pycache__/pyclbr.cpython-310.opt-1.pyc

o

6��f�,�@s�dZddlZddlZddlZgd�ZiZGdd�d�ZGdd�de�ZGdd	�d	e�Z	ddd�Z
dd
d�Zddd�Zddd�Z
ddd�ZGdd�dej�Zdd�Zdd�Zedkr^e�dSdS)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;
    end_lineno -- line in the file where the object's definition ends;
    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,
plus the following:
    is_async -- if a function is defined with an 'async' prefix

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)�
readmodule�
readmodule_ex�Class�Functionc@seZdZdZdd�ZdS)�_Objectz+Information about Python class or function.cCsD||_||_||_||_||_||_i|_|dur ||j|<dSdS�N)�module�name�file�lineno�
end_lineno�parent�children)�selfrr	r
rrr
�r�-/opt/alt/python310/lib64/python3.10/pyclbr.py�__init__7s�z_Object.__init__N)�__name__�
__module__�__qualname__�__doc__rrrrrr5srcs*eZdZdZ	ddd��fdd�Z�ZS)rz7Information about a Python function, including methods.NF�rcs8t��||||||�||_t|t�r||j|<dSdSr)�superr�is_async�
isinstancer�methods)rrr	r
rr
rr��	__class__rrrFs

�zFunction.__init__)NF�rrrrr�
__classcell__rrrrrD���rcs*eZdZdZ	ddd��fdd�Z�ZS)rz!Information about a Python class.Nrcs*t��||||||�|pg|_i|_dSr)rrr)rrr	Zsuper_r
rr
rrrrrPs

zClass.__init__rrrrrrrNr rFc	Cst|j||j||||d�S)z*Return a Function after nesting within ob.)r
rr)rrr
)�obZ	func_namerrrrrr�_nest_functionYs�r"c	Cst|j|||j|||d�S)z'Return a Class after nesting within ob.�r
r)rrr
)r!�
class_namerrrrrr�_nest_class^s�r%cCs6i}t||pg���D]
\}}t|t�r|||<q|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�valuerrrrds
�rcCst||pg�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&)rr(rrrrpsrc	Csv|durd||f}n|}|tvrt|Si}|tjvr&|dur&|t|<|S|�d�}|dkr`|d|�}||dd�}t|||�}|durMd||f}d|vrXtd�|���t||d|�Sd}	|duri|}
n|tj}
tj	�
||
�}|dur�td|��|d	��|t|<|jdur�|j|d<z|j
�|�}Wn
ttfy�|YSw|dur�|S|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 {}zno module named )r	)�_modules�sys�builtin_module_names�rfindr&�ImportError�formatr(�	importlib�util�_find_spec_from_path�ModuleNotFoundError�submodule_search_locations�loader�
get_source�AttributeError�get_filename�_create_tree)rr(�	inpackage�
fullmodule�tree�i�packageZ	submoduler
�fZsearch_path�spec�source�fnamerrrr&zsL	



�r&c@sBeZdZdd�Zdd�Zdd�dd�Zd	d
�Zdd�Zd
d�ZdS)�_ModuleBrowsercCs(||_||_||_||_||_g|_dSr)r(rAr
rr?�stack)rrr(r
rAr?rrrr�s
z_ModuleBrowser.__init__c
	Cs�g}|jD];}t�|�}||jvr|�|j|�qt|�d�}�dkr;|�^}}}|tvr:|�t|�||��q|�|�q|j	rI|j	dnd}	t
|j|j||j
|j|	|jd�}|	dure||j|j<|j	�|�|�|�|j	��dS)Nr,r-���r#)�bases�astZunparserA�append�len�splitr/�getrIrrr	r
rr�
generic_visit�pop)
r�noderK�baser	�names�_rZclass_r
rrr�visit_ClassDef�s(


��
z_ModuleBrowser.visit_ClassDefF�rc	Csl|jr|jdnd}t|j|j|j|j|||jd�}|dur$||j|j<|j�|�|�	|�|j�
�dS)NrJr)rIrrr	r
rrrArMrQrR)rrSrr
Zfunctionrrr�visit_FunctionDef�s�
z _ModuleBrowser.visit_FunctionDefcCs|j|dd�dS)NTrX)rY)rrSrrr�visit_AsyncFunctionDef�sz%_ModuleBrowser.visit_AsyncFunctionDefc
Csn|jdkrdS|jD]*}zzt|j|j|j�Wnty't|jg�YnwWq
ttfy4Yq
wdS)Nr)�
col_offsetrUr&r	r(r?r3�SyntaxError)rrSrrrr�visit_Import�s

����z_ModuleBrowser.visit_Importc	Cs�|jdkrdSzd|j}|jr||j7}t||j|j�}Wnttfy*YdSw|jD]-}|j	|vrB||j	|j
|jp@|j	<q.|j	dkr[|��D]\}}|�
d�rUqK||j
|<qKq.dS)Nrr,�*rV)r[�levelrr&r(r?r3r\rUr	rA�asnamer'�
startswith)rrSrr	Zimport_nameZimport_valuerrr�visit_ImportFrom�s(


�



��z_ModuleBrowser.visit_ImportFromN)	rrrrrWrYrZr]rbrrrrrH�s
rHcCs&t|||||�}|�t�|��|jSr)rHZvisitrL�parserA)r@r(rGrFrAr?Zmbrowserrrrr>
sr>c
CsVddl}ztjd}Wnt}Y|j�|�r3|j�|�g}|j�|�}|���	d�r2|dd�}ng}t
||�}dd�}t|��|dd	�}d
}|r�|�
�}t|t�rUqIt|d�s]d|_t|t�r|t|j��|dd	�}|D]}	|j||	_qn|�|�t|t�r�td�d
|j|j|j|j��nt|t�r�td�d
|j|j|j��|sKdSdS)z?Print module output (default this file) for quick visual check.rNr-z.py���cSst|dd�S)Nrr)�getattr)�arrr�<lambda>"sz_main.<locals>.<lambda>T)r*�reverse��indentz{}class {} {} {}� z{}def {} {})�osr0�argv�__file__r(�exists�dirname�basename�lower�endswithr�sorted�valuesrRr�list�hasattrrjrr�extendr�printr4r	rrr)
rl�modr(rAZ
lineno_keyZobjsZindent_level�objZnew_objsr!rrr�_mainsH�




�

�
�r|�__main__)Fr)rrLr0�importlib.utilr5�__all__r/rrrr"r%rrr&ZNodeVisitorrHr>r|rrrrr�<module>s(+






@S&
�

?>