Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/pylint/pyreverse/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/pylint/pyreverse/__pycache__/inspector.cpython-311.pyc

�

�܋f�:����dZddlmZddlZddlZddlZddlZddlmZm	Z	ddl
mZddlm
Z
mZmZddlZddlmZmZddlmZdd	lmZeeegejfegeejfZd,d�Zd-d�ZGd�d��ZGd�d��ZGd�deej��ZGd�de��Z Gd�de ��Z!Gd�d e!��Z"Gd!�d"e!��Z#ed#ej$fd.d+�Z%dS)/z|Visitor doing some post-processing on the astroid tree.

Try to resolve definitions (namespace) dictionary, relationship...
�)�annotationsN)�ABC�abstractmethod)�	Generator)�Any�Callable�Optional)�nodes�util)�	constants)�utils�func�Callable[[str], nodes.Module]�modname�str�return�nodes.Module | Nonec���td|�d���	||��S#tjj$r}t|��Yd}~n&d}~wt$rtj��YnwxYwdS)Nzparsing z...)�print�astroid�
exceptions�AstroidBuildingException�	Exception�	traceback�	print_exc)rr�excs   �k/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/pylint/pyreverse/inspector.py�_astroid_wrapperrs���
�
!�W�
!�
!�
!�"�"�"���t�G�}�}�����6����
�c�
�
�
�
�
�
�
�
���������������������4s�
 �A+�A� A+�*A+�node�nodes.ClassDef�Generator[Any, None, None]c#��K�	tj�|���d��d}n#tjj$rYdSwxYw|�d���|urdSt��}d}tj	|��D]<}t|tj��rd}�||vr|�
|��|V��=|rtj����dS)zEReturn an iterator on interfaces implemented by the given class node.�__implements__rNT��futureF)r�bases�Instance�getattrr�
NotFoundError�frame�setr
�unpack_infer�
isinstancer�UninferableBase�add�InferenceError)r�
implements�found�missing�ifaces     r�
interfacesr5*s������]�+�+�D�1�1�9�9�:J�K�K�A�N�
�
����+��������������t��$�$�D�0�0����E�E�E��G��#�J�/�/�����e�T�1�2�2�	��G�������I�I�e�����K�K�K���2�� �/�/�1�1�1�2�2s�8=�A�Ac�.�eZdZdZddd�Zddd�Zd
d	�Zd
S)�IdGeneratorMixInz1Mixin adding the ability to generate integer uid.r�start_value�intr�Nonec��||_dS�N��id_count��selfr8s  r�__init__zIdGeneratorMixIn.__init__Bs
��#��
�
�
�c��||_dS)zInit the id counter.Nr=r?s  r�init_counterzIdGeneratorMixIn.init_counterEs
��#��
�
�
rBc�0�|xjdz
c_|jS)zGenerate a new identifier.�r=�r@s r�generate_idzIdGeneratorMixIn.generate_idIs���
�
���
�
��}�rBN)r)r8r9rr:)rr9)�__name__�
__module__�__qualname__�__doc__rArDrH�rBrr7r7?s`������;�;�$�$�$�$�$�$�$�$�$�$������rBr7c�<�eZdZdZddd�Zdd
�Zdd�Zdd
�Zdd�ZdS)�Projectz-A project handle a set of modules / packages.��namerc��||_d|_d|_g|_i|_|jj|_|jj|_|jj|_|jj|_|jj	|_	dS)NrP)
rQ�uid�path�modules�locals�__getitem__�__iter__�values�keys�items�r@rQs  rrAzProject.__init__Rsf����	�#�����	�+-���/1����;�2�����,��
��k�(����K�$��	��[�&��
�
�
rBr�nodes.Modulerr:c�X�||j|j<|j�|��dSr<)rVrQrU�append�r@rs  r�
add_modulezProject.add_module^s,��!%���D�I������D�!�!�!�!�!rBc��|j|Sr<)rVr\s  r�
get_modulezProject.get_modulebs���{�4� � rB�list[nodes.Module]c��|jSr<)rUrGs r�get_childrenzProject.get_childrenes
���|�rBc�b�d|j�dt|���dt|j���d�S)Nz	<Project z at z (z
 modules)>)rQ�id�lenrUrGs r�__repr__zProject.__repr__hs5��U�4�9�U�U�B�t�H�H�U�U��D�L�8I�8I�U�U�U�UrBN)rP)rQr�rr]rr:)rQrrr])rrd)rr)	rIrJrKrLrArarcrfrjrMrBrrOrOOs�������7�7�
'�
'�
'�
'�
'�"�"�"�"�!�!�!�!�����V�V�V�V�V�VrBrOc�|�eZdZdZd#d$d	�Zd%d�Zd&d
�Zd'd�Zd(d�Zd)d�Z	e
d*d���Zd+d�Zd,d�Z
d-d�Zd.d!�Zd"S)/�Linkera�Walk on the project tree and resolve relationships.

    According to options the following attributes may be
    added to visited nodes:

    * uid,
      a unique identifier for the node (on astroid.Project, astroid.Module,
      astroid.Class and astroid.locals_type). Only if the linker
      has been instantiated with tag=True parameter (False by default).

    * Function
      a mapping from locals names to their bounded value, which may be a
      constant like a string or an integer, or an astroid node
      (on astroid.Module, astroid.Class and astroid.Function).

    * instance_attrs_type
      as locals_type but for klass member attributes (only on astroid.Class)

    * associations_type
      as instance_attrs_type but for association relationships

    * aggregations_type
      as instance_attrs_type but for aggregations relationships

    * implements,
      list of implemented interface _objects_ (only on astroid.Class nodes)
    F�projectrO�tag�boolrr:c��t�|��tj�|��||_||_t
��|_|j�t����dSr<)
r7rAr
�
LocalsVisitorrorn�AggregationsHandler�associations_handler�set_next�OtherAssociationsHandler)r@rnros   rrAzLinker.__init__�sm���!�!�$�'�'�'�
��$�$�T�*�*�*�������$7�$9�$9��!��!�*�*�+C�+E�+E�F�F�F�F�FrBrc��|jr|���|_|jD]}|�|���dS)zbVisit a pyreverse.utils.Project node.

        * optionally tag the node with a unique id
        N)rorHrSrU�visit)r@r�modules   r�
visit_projectzLinker.visit_project�sQ��
�8�	*��'�'�)�)�D�H��l�	�	�F��J�J�v�����	�	rBr]c��t|d��rdStjt��|_g|_|jr|���|_dSdS)z�Visit an astroid.Module node.

        * set the locals_type mapping
        * set the depends mapping
        * optionally tag the node with a unique id
        �locals_typeN)	�hasattr�collections�defaultdict�listr|�dependsrorHrSr`s  r�visit_modulezLinker.visit_module�s`���4��'�'�	��F�&�2�4�8�8�������8�	*��'�'�)�)�D�H�H�H�	*�	*rBr c��t|d��rdStjt��|_|jr|���|_|�d���D]/}t|dg��}|�
|��||_�0tjt��|_tjt��|_
tjt��|_t|j�����D]R}|D]M}t%|t&j��s1|j�||��|�||���N�S	t1|��}|�9t|��|_|jrt5jdt8��dSdSg|_dS#t:j$rg|_YdSwxYw)z�Visit an astroid.Class node.

        * set the locals_type and instance_attrs_type mappings
        * set the implements list and build it
        * optionally tag the node with a unique id
        r|NF)�recurs�specializationsz�pyreverse will drop support for resolving and displaying implemented interfaces in pylint 3.0. The implementation relies on the '__implements__'  attribute proposed in PEP 245, which was rejected in 2006.)r}r~rr�r|rorHrS�	ancestorsr(r_r��instance_attrs_type�aggregations_type�associations_type�tuple�instance_attrsrYr-r
�Unknownrt�handle�handle_assignattr_typer5r1�warnings�warn�DeprecationWarningrr0)r@r�baseobjr��assignattrs�
assignattr�ifacess       r�visit_classdefzLinker.visit_classdef�s����4��'�'�	��F�&�2�4�8�8����8�	*��'�'�)�)�D�H��~�~�U�~�3�3�	6�	6�G�%�g�/@�"�E�E�O��"�"�4�(�(�(�&5�G�#�#�#.�#:�4�#@�#@�� �!,�!8��!>�!>���!,�!8��!>�!>��� ��!4�!;�!;�!=�!=�>�>�	B�	B�K�)�
B�
B�
�!�*�e�m�<�<�B��-�4�4�Z��F�F�F��/�/�
�D�A�A�A��
B�
	!���%�%�F��!�"&�v�,�,����?���M�8�+��������#%�������%�	!�	!�	!� �D�O�O�O�O�	!���s�+AF>�5F>�>G�G�nodes.FunctionDefc��t|d��rdStjt��|_|jr|���|_dSdS)z�Visit an astroid.Function node.

        * set the locals_type mapping
        * optionally tag the node with a unique id
        r|N)r}r~rr�r|rorHrSr`s  r�visit_functiondefzLinker.visit_functiondef�sY���4��'�'�	��F�&�2�4�8�8����8�	*��'�'�)�)�D�H�H�H�	*�	*rB�nodes.AssignNamec�r�t|d��rdSd|_|j|�d���vr|�d���}n|���}t|d��sut|tj��r|�|��nEt|tj	��r|�
|��n|�|��|j|j}tt|��tj|��z��|j|j<dS)zFVisit an astroid.AssignName node.

        handle locals_type
        �_handledNTr$r|)r}r�rQr*�rootr-r
�ClassDefr��FunctionDefr�r�r|r�r+r
�
infer_node)r@rr*�currents    r�visit_assignnamezLinker.visit_assignname�s"���4��$�$�	��F���
��9��
�
�$�
�/�/�/�/��J�J�d�J�+�+�E�E��I�I�K�K�E��u�m�,�,�		)��%���0�0�
)��#�#�E�*�*�*�*��E�5�#4�5�5�
)��&�&�u�-�-�-�-��!�!�%�(�(�(��#�D�I�.��'+�C��L�L�5�;K�D�;Q�;Q�,Q�'R�'R���$�)�$�$�$rB�nodes.AssignAttr�parentc��t|j|j��}t|t	j|��z��|j|j<dS)zOHandle an astroid.assignattr node.

        handle instance_attrs_type
        N)r+r��attrnamer�r
r�)rr�r�s   rr�zLinker.handle_assignattr_typesM���f�0���?�@�@��48��e�&�t�,�,�,�5
�5
��"�4�=�1�1�1rB�nodes.Importc���|���j}|jD]E}tj�|d|��}|�||d|���FdS)zKVisit an astroid.Import node.

        resolve module dependencies
        rN)r��file�namesr�modutils�is_relative�_imported_module)r@r�context_filerQ�relatives     r�visit_importzLinker.visit_import
sj��
�y�y�{�{�'���J�	;�	;�D��'�3�3�D��G�\�J�J�H��!�!�$��Q���:�:�:�:�	;�	;rB�nodes.ImportFromc��|j}|���j}|�!tj�||��}nd}|jD]�}|ddkr�|�d|d��}|�d��dkr2	tj�||��}n#t$rY�cwxYw||kr|�
|||����dS)zOVisit an astroid.ImportFrom node.

        resolve module dependencies
        NFr�*�.���)rr�r�rr�r�r��find�get_module_part�ImportErrorr�)r@r�basenamer�r�rQ�fullnames       r�visit_importfromzLinker.visit_importfroms��
�<���y�y�{�{�'���#��'�3�3�H�l�K�K�H�H��H��J�	@�	@�D��A�w�#�~�~��"�.�.�T�!�W�.�.�H��}�}�S�!�!�B�&�&��&�/�?�?��,�W�W�H�H��"�����H������8�#�#��%�%�d�H�h�?�?�?��	@�	@s� B$�$
B1�0B1�context_namer�mod_pathc��tj�|jj��}||krdStj�||f��S)z,Should the module be added to dependencies ?F)�osrT�dirnamernrr��module_in_path)r@r�r��package_dirs    r�compute_modulezLinker.compute_module/sG���g�o�o�d�l�&7�8�8���8�#�#��5���.�.�x�+��H�H�HrB�nodes.Import | nodes.ImportFromr�c�L�|���}|j}|r5d�|�d��dd����d|��}|�||��r9t|d��sg|_|j}||vr|�|��dSdSdS)z8Notify an imported module, used to analyze dependencies.r�Nr�r�)r�rQ�join�splitr�r}r�r_)r@rr�r�ryr��	mod_pathss       rr�zLinker._imported_module8s����������{���	N��(�(�<�#5�#5�c�#:�#:�3�B�3�#?�@�@�M�M�8�M�M�H����|�X�6�6�	+��6�9�-�-�
$�!#�����I��y�(�(�� � ��*�*�*�*�*�
	+�	+�
)�(rBN)F)rnrOrorprr:)rrOrr:rk)rr rr:)rr�rr:)rr�rr:�rr�r�r rr:)rr�rr:)rr�rr:)r�rr�rrrp)rr�r�rr�rprr:)rIrJrKrLrArzr�r�r�r��staticmethodr�r�r�r�r�rMrBrrmrmls��������8G�G�G�G�G�����*�*�*�*�+!�+!�+!�+!�Z
*�
*�
*�
*�S�S�S�S�<�
�
�
��\�
�;�;�;�;�@�@�@�@�0I�I�I�I�+�+�+�+�+�+rBrmc�>�eZdZedd���Zedd	���Zd
S)
�AssociationHandlerInterface�handlerrc��dSr<rM�r@r�s  rruz$AssociationHandlerInterface.set_nextJs	��	
�rBrr�r�r r:c��dSr<rM�r@rr�s   rr�z"AssociationHandlerInterface.handlePs���rBN�r�r�rr�r�)rIrJrKrrur�rMrBrr�r�IsR�������
�
�
��^�
�
�
�
�
��^�
�
�
rBr�c�>�eZdZUdZded<dd�Zedd���Zd
S)�AbstractAssociationHandlera�
    Chain of Responsibility for handling types of association, useful
    to expand in the future if we want to add more distinct associations.

    Every link of the chain checks if it's a certain type of association.
    If no association is found it's set as a generic association in `associations_type`.

    The default chaining behavior is implemented inside the base handler
    class.
    r��
_next_handlerr�rc��||_|Sr<)r�r�s  rruz#AbstractAssociationHandler.set_nextcs��%����rBrr�r�r r:c�N�|jr|j�||��dSdSr<)r�r�r�s   rr�z!AbstractAssociationHandler.handleis6����	4���%�%�d�F�3�3�3�3�3�	4�	4rBNr�r�)rIrJrKrL�__annotations__rurr�rMrBrr�r�Usb�������	�	�/�.�.�.������4�4�4��^�4�4�4rBr�c� ��eZdZd�fd�Z�xZS)	rsrr�r�r rr:c���t|jtjtjf��r{t|jjtjj��rRt|j
|j��}t|tj|��z��|j
|j<dSt���||��dSr<)r-r�r
�	AnnAssign�Assign�valuer�node_classes�Namer+r�r�r�r
r��superr�)r@rr�r��	__class__s    �rr�zAggregationsHandler.handleps�����d�k�E�O�U�\�#B�C�C�	)�
��K��w�3�8�I
�I
�	)��&�2�4�=�A�B�B�G�6:��%�*�4�0�0�0�7�7�F�$�T�]�3�3�3�
�G�G�N�N�4��(�(�(�(�(rBr�)rIrJrKr��
__classcell__)r�s@rrsrsos=�������	)�	)�	)�	)�	)�	)�	)�	)�	)�	)rBrsc��eZdZd	d�ZdS)
rvrr�r�r rr:c��t|j|j��}t|t	j|��z��|j|j<dSr<)r+r�r�r�r
r�)r@rr�r�s    rr�zOtherAssociationsHandler.handle}sG���f�.�t�}�=�>�>��26�w��AQ�RV�AW�AW�7W�2X�2X�� ���/�/�/rBNr�)rIrJrKr�rMrBrrvrv|s.������Y�Y�Y�Y�Y�YrBrvzno name�files�	list[str]�func_wrapper�
_WrapperFuncT�project_name�
black_list�tuple[str, ...]c�*�tj}t|��}|D�]s}tj�|��s3tj�|�d����}nBtj�	|��r!tj�
|d��}n|}||j|��}|���|jp|j|_|�
|��|j}	|jr�|�d��dkrytj�tj�|j��|��D]6}||j|��}|�|j|	kr�!|�
|���7��u|S)z1Return a Project from a list of files or modules.r�z__init__.pyNrAr�)r�MANAGERrOr�rT�existsr��file_from_modpathr��isdirr��
ast_from_filer�rarQ�packager��get_module_filesr�)
r�r�r�r��astroid_managerrn�	something�fpath�ast�	base_names
          r�project_from_filesr��sx���o�O��l�#�#�G��(�(�	��w�~�~�i�(�(�	��$�6�6�y���s�7K�7K�L�L�E�E�
�W�]�]�9�
%�
%�	��G�L�L��M�:�:�E�E��E��l�?�8�%�@�@���;���|�/�s�x������3�����H�	��;�	(�9�>�>�*�5�5��;�;� �)�:�:�������)�)�:���
(�
(��#�l�?�#@�%�H�H���;�#�(�i�"7�"7���"�"�3�'�'�'�'���NrB)rrrrrr)rr rr!)
r�r�r�r�r�rr�r�rrO)&rL�
__future__rr~r�rr��abcrr�collections.abcr�typingrrr	rr
r�pylintr�pylint.pyreverser
r�Moduler�rr5r7rOrrrmr�r�rsrv�DEFAULT_IGNORE_LISTr�rMrBr�<module>rs���
��
#�"�"�"�"�"�����	�	�	�	���������#�#�#�#�#�#�#�#�%�%�%�%�%�%�*�*�*�*�*�*�*�*�*�*�������������������"�"�"�"�"�"��(�C�5�%�,�#6�7��=�x���?U�U�V�
�
�
�
�
�2�2�2�2�*
�
�
�
�
�
�
�
� V�V�V�V�V�V�V�V�:Z+�Z+�Z+�Z+�Z+�
�u�2�Z+�Z+�Z+�z	
�	
�	
�	
�	
�#�	
�	
�	
�4�4�4�4�4�!<�4�4�4�4
)�
)�
)�
)�
)�4�
)�
)�
)�Y�Y�Y�Y�Y�9�Y�Y�Y�#3�!�"+�"?�	!�!�!�!�!�!�!rB

Hacked By AnonymousFox1.0, Coded By AnonymousFox