ok

Mini Shell

Direktori : /opt/cloudlinux/venv/lib/python3.11/site-packages/astroid/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/astroid/__pycache__/manager.cpython-311.pyc

�

�܋f(F��,�dZddlmZddlZddlZddlZddlZddlmZm	Z	m
Z
ddlmZm
Z
ddlmZmZddlmZddlmZdd	lmZdd
lmZmZddlmZmZddlmZmZdd
l m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)ddl*m+Z+ddl,m-Z-m.Z.dZ/dd�Z0Gd�d��Z1dS)z�astroid manager: avoid multiple astroid build of a same module when
possible by providing a class responsible to get astroid representation
from various source and using a cache of built modules)
�)�annotationsN)�Callable�Iterator�Sequence)�	find_spec�module_from_spec)�Any�ClassVar)�nodes)�
CACHE_MANAGER)�BRAIN_MODULES_DIRECTORY)�InferenceContext�_invalidate_cache)�AstroidBuildingError�AstroidImportError)�spec�util)	�NoSourceFile�_cache_normalize_path_�file_info_from_modpath�get_source_file�2is_module_name_part_of_extension_package_whitelist�is_python_source�is_stdlib_module�load_module_from_name�modpath_from_file)�TransformVisitor)�AstroidManagerBrain�InferenceResult)z.zipz.eggz.whlz.pyzz.pyzw�objr	�return�strc�D�	t|��S#t$rYdSwxYw)Nz???)�repr�	Exception)r s �`/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/astroid/manager.py�	safe_reprr'+s5����C�y�y��������u�u����s��
�c��eZdZUdZdZiigdde��e��d�Zded<dZ	ded	<dGd�Z
edHd���Zej
dId���ZedHd���Zej
dId���Zed���Zed���ZedJd���ZdKd�Z			dLdMd#�Z	dNdOd&�ZdPd'�ZdQd*�ZdRd+�Z		dSdTd.�ZdUd0�ZdVd3�Z	dWdXd6�ZdWdYd:�Z	dWdZd@�Zd[dC�Zd\dD�ZdGdE�Z dGdF�Z!dS)]�AstroidManagerz_Responsible to build astroid from files or modules.

    Use the Borg (singleton) pattern.
    zastroid loaderF)�
astroid_cache�_mod_file_cache�_failed_import_hooks�always_load_extensions�optimize_ast�extension_package_whitelist�
_transformr�brain�dz
ClassVar[int]�max_inferable_valuesr!�Nonec���tjd|_tjd|_tjd|_tjd|_tjd|_dS)Nr*r+r,r/r0)r)r1r*r+r,r/r0��selfs r&�__init__zAstroidManager.__init__Ds\��+�1�/�B���-�3�4E�F���$2�$8�9O�$P��!�+9�+?�)�,
��(�)�.�|�<������boolc�&�tjdS�Nr-�r)r1r6s r&r-z%AstroidManager.always_load_extensionsNs���#�$<�=�=r9�valuec�$�|tjd<dSr<r=�r7r>s  r&r-z%AstroidManager.always_load_extensionsRs��9>���5�6�6�6r9c�&�tjdS�Nr.r=r6s r&r.zAstroidManager.optimize_astVs���#�N�3�3r9c�$�|tjd<dSrBr=r@s  r&r.zAstroidManager.optimize_astZs��/4���^�,�,�,r9c��|jjS�N)r0�register_transformr6s r&rFz!AstroidManager.register_transform^s����1�1r9c��|jjSrE)r0�unregister_transformr6s r&rHz#AstroidManager.unregister_transformcs
����3�3r9�nodes.Modulec��|jdS)N�builtins)r*r6s r&�builtins_modulezAstroidManager.builtins_modulegs���!�*�-�-r9�node�nodes.NodeNGrc�6�|j�|��S)z8Visit the transforms and apply them to the given *node*.)r0�visit)r7rMs  r&�visit_transformszAstroidManager.visit_transformsks����$�$�T�*�*�*r9NT�filepathr"�modname�
str | None�fallback�sourcec��	t|d���}d}n#t$rYnwxYw|�6	d�t|����}n#t$r|}YnwxYw||jvr#|j|j|kr
|j|S|r%ddlm}||���	||��S|r|r|�
|��Std|����)	�/Given a module name, return the astroid object.T)�include_no_extN�.r��AstroidBuilderz"Unable to build an AST for {path}.)�path)rr�joinr�ImportErrorr*�file�astroid.builderr\�
file_build�ast_from_module_namer)r7rRrSrUrVr\s      r&�
ast_from_filezAstroidManager.ast_from_fileos0��	�&�x��E�E�E�H��F�F���	�	�	��D�	�����?�
#��(�(�#4�X�#>�#>�?�?�����
#�
#�
#�"����
#����
�t�)�)�)��"�7�+�0�H�<�<��%�g�.�.��	F�6�6�6�6�6�6�!�>�$�'�'�2�2�8�W�E�E�E��	6��	6��,�,�W�5�5�5�"�#G�h�W�W�W�Ws��
#�#�"A�A�A��datac�N�ddlm}||���|||��S)z]Given some source code as a string, return its corresponding astroid
        object.
        rr[�rar\�string_build)r7rfrSrRr\s     r&�ast_from_stringzAstroidManager.ast_from_string�s8��	3�2�2�2�2�2��~�d�#�#�0�0��w��I�I�Ir9c�L�ddlm}||���d|��S)Nrr[rerh)r7rSr\s   r&�_build_stub_modulez!AstroidManager._build_stub_module�s4��2�2�2�2�2�2��~�d�#�#�0�0��W�=�=�=r9r]�
Sequence[str]c�&�ddlm}|||��S)Nr)�build_namespace_package_module)raro)r7rSr]ros    r&�_build_namespace_modulez&AstroidManager._build_namespace_module�s*��	C�B�B�B�B�B�-�-�g�t�<�<�<r9c�`�|jrdSt|��rdSt||j��S�NT)r-rrr/)r7rSs  r&�_can_load_extensionz"AstroidManager._can_load_extension�sA���&�	��4��G�$�$�	��4�A��T�5�
�
�	
r9�context_file�	use_cachec�<�|�td���||jvr|r
|j|S|dkr|�|��S|rDtj��}tjtj�|����	|�||��}|j	tjjkr7|�
|j��}|�||rtj|��SS�n�|j	tjjtjjfvr�|j	tjjkrA|�|��s,|�|��|rtj|��SS	t%|��}n*#t&$r}t)d||j���|�d}~wwxYw|�||��|rtj|��SS|j	tjjkrt)d||j����|j	tjjkr4|�||jpg��|rtj|��SS|j	tjjkrg|j�,|�|��|rtj|��SS|�|j|d���|rtj|��SS|j�t)d	|�
���|�|j|d���|rtj|��SS#t$rJ}|jD];}		|	|��ccYd}~|rtj|��SS#t$rY�8wxYw|�d}~wwxYw#|rtj|��wwxYw)rXNzNo module name given.�__main__z&Loading {modname} failed with:
{error})rSr]z)Unable to load compiled module {modname}.F)rUz'Can't find a file for module {modname}.)rS)rr*rl�os�getcwd�chdirr]�dirname�file_from_module_name�typer�
ModuleType�PY_ZIPMODULE�zip_import_data�location�	C_BUILTIN�C_EXTENSIONrsrr%r�ast_from_module�PY_COMPILED�PY_NAMESPACErp�submodule_search_locations�	PY_FROZENrdr,)
r7rSrtru�old_cwd�
found_spec�module�named_module�e�hooks
          r&rcz#AstroidManager.ast_from_module_name�se���?�&�'>�?�?�?�
�d�(�(�(�Y�(��%�g�.�.��j� � ��*�*�7�3�3�3��	4��i�k�k�G��H�R�W�_�_�\�2�2�3�3�3�;	"��3�3�G�\�J�J�J���$�/�">�>�>��-�-�j�.A�B�B���%�!�j�
"����!�!�!�!�
"�m&�����)���+�%���
�O�t��'B�B�B� �4�4�W�=�=�C� �2�2�7�;�;�V�
"����!�!�!�!�
"�U�#8��#A�#A�L�L�� ����,�A� '�'�0�����	����������+�+�L�'�B�B�D�
"����!�!�!�!�
"�A��D�O�$?�?�?�(�?�#�#�,�������D�O�$@�@�@��3�3��Z�B�H�b���0�
"����!�!�!�!�
"�+��D�O�$=�=�=��&�.��2�2�7�;�;�&�
"����!�!�!�!�
"�!�)�)�*�*=�w�QV�)�W�W� �
"����!�!�!�!�
"��"�*�(�=�w������%�%�j�&9�7�U�%�S�S��
"����!�!�!�!�
"��$�	�	�	��1�
�
����4��=�=�(�(�(�(�(�(�(�
�
"����!�!�!�!�
"��	,�����D������G�����
	������
"����!�!�!�!�
"���s��A
L+�1A.L+�8F�L+�
F/�F*�*F/�/L+�A'L+�5L+�+L+�4L+�+
M?�5	M:�?
M(�	M:�M?�N�(
M5�2M:�4M5�5M:�:M?�?N�N�nodes.Module | Nonec���t�dSddlm}||��}tD]�}	|�|t
jjzd��\}}n#t$rY�;wxYw	tj	||z��}|�
t
jjd��}|�|��r|dz}|�|�
|��||��}	|	cS#t$rY��wxYwdS)Nrr[�rZz	.__init__)�	zipimportrar\�ZIP_IMPORT_EXTS�rsplitrxr]�sep�
ValueError�zipimporter�replace�
is_packageri�
get_sourcer%)
r7rRr\�builder�ext�eggpath�resource�importer�zmodnamer�s
          r&r�zAstroidManager.zip_import_datas3�����4�	3�2�2�2�2�2� �.��&�&��"�	�	�C�
�$,�O�O�C�"�'�+�4E�q�$I�$I�!������
�
�
���
����
�$�0��3��?�?��#�+�+�B�G�K��=�=���&�&�x�0�0�6�'�+�5�H� �-�-��'�'��1�1�8�X�����
�
�
���
�
�
���
�����ts$�+A�
A�A�"BC&�&
C3�2C3�contextfile�spec.ModuleSpecc	�x�	|j||f}n~#t$rq	t|�d��|���}n<#t$r/}td||�d�����}Yd}~nd}~wwxYw||j||f<YnwxYwt|t��r|�d���|S)NrZ)rtz6Failed to import module {modname} with error:
{error}.)rS�error)	r+�KeyErrorr�splitr_r�with_traceback�
isinstancer)r7rSr�r>r�s     r&r|z$AstroidManager.file_from_module_names��	A��(�'�;�)?�@�E�E���
	A�
	A�
	A�
�.��M�M�#�&�&�[��������
�
�
�*�M�#��*�*�4�0�0�	�������������
����<A�D� �'�;�!7�8�8�8�
	A�����e�1�2�2�	-��&�&�t�,�,�,��s8��
B
�$A�B
�
A;�%A6�1B
�6A;�;B
�B
r��types.ModuleTypec��|p|j}||jvr
|j|S	|j}t|��r|�||��Sn#t
$rYnwxYwddlm}||���||��S)z4Given an imported module, return the astroid object.rr[)	�__name__r*�__file__rrd�AttributeErrorrar\�module_build)r7r�rSrRr\s     r&r�zAstroidManager.ast_from_module5s����,�V�_���d�(�(�(��%�g�.�.�	���H���)�)�
=��)�)�(�G�<�<�<�
=���	�	�	��D�	����	3�2�2�2�2�2��~�d�#�#�0�0���A�A�As�+A�
A�A�klassr}�nodes.ClassDefc�$�|�<	|j}n3#t$r&}td|t|��|���|�d}~wwxYw|�|��}|�|j��d}t|tj	��sJ�|S)z Get astroid for the given class.Nz,Unable to get module for class {class_name}.)�cls�
class_reprrSr)
�
__module__r�rr'rc�getattrr�r�r�ClassDef)r7r�rS�exc�
modastroid�rets      r&�ast_from_classzAstroidManager.ast_from_classJs����?�
��*����!�
�
�
�*�B��(��/�/�#�	���
������
�����.�.�w�7�7�
�� � ���0�0��3���#�u�~�.�.�.�.�.��
s��
<�!7�<r �object�context�InferenceContext | None�Iterator[InferenceResult]c#�@K�t|d��rt|t��s|j}n7t|t��r|}nt	ddt|������	|j}n_#t$r%}t	d|t|�����|�d}~wt$r%}td|t|�����|�d}~wwxYw	|j
}n_#t$r%}t	d|t|�����|�d}~wt$r%}td|t|�����|�d}~wwxYw|�|��}||ur|�||��D]}|V��dS|�||��D]}|�
��V��dS)	z"Infer astroid for the given class.�	__class__z$Unable to get type for {class_repr}.N)r�r�z&Unable to get module for {class_repr}.zBUnexpected error while retrieving module for {class_repr}:
{error}z%Unable to get name for {class_repr}:
z@Unexpected error while retrieving name for {class_repr}:
{error})�hasattrr�r}r�rr'r�r�r%rr�rc�igetattr�instantiate_class)	r7r r�r�rSr��namer��inferreds	         r&�infer_ast_from_somethingz'AstroidManager.infer_ast_from_something[sL�����3��$�$�		�Z��T�-B�-B�		��M�E�E�
��T�
"�
"�	��E�E�&�6��$�S�>�>����
�
	��&�G�G���	�	�	�&�8��$�U�+�+�����	
�����
�	�	�	�$���$�U�+�+�	���
�
�����	����
	��>�D�D���	�	�	�&�8��$�U�+�+�����	
�����
�	�	�	�$�S��$�U�+�+�����	
�����	�����.�.�w�7�7�
��C�<�<�&�/�/��g�>�>�
�
�������
�
�'�/�/��g�>�>�
3�
3���0�0�2�2�2�2�2�2�
3�
3sH�(A0�0
C�: B�
C�' C�C�C�
D4�" D�
D4� D/�/D4r��Callable[[str], nodes.Module]c�:�|j�|��dS)a}Registers a hook to resolve imports that cannot be found otherwise.

        `hook` must be a function that accepts a single argument `modname` which
        contains the name of the module or package that could not be imported.
        If `hook` can resolve the import, must return a node of type `astroid.Module`,
        otherwise, it must raise `AstroidBuildingError`.
        N)r,�append)r7r�s  r&�register_failed_import_hookz*AstroidManager.register_failed_import_hook�s!��	
�!�(�(��.�.�.�.�.r9c�F�|j�|j|��dS)z<Cache a module if no module with the same name is known yet.N)r*�
setdefaultr�)r7r�s  r&�cache_modulezAstroidManager.cache_module�s#����%�%�f�k�6�:�:�:�:�:r9c�:�ddlm}|���dS)z�Bootstrap the required AST modules needed for the manager to work.

        The bootstrap usually involves building the AST for the builtins
        module, which is required by the rest of astroid to work correctly.
        r)�raw_buildingN)�astroidr��_astroid_bootstrapping)r7r�s  r&�	bootstrapzAstroidManager.bootstrap�s.��	)�(�(�(�(�(��+�+�-�-�-�-�-r9c��ddlm}ddlm}ddlm}ddlm}|��t��|j	�
��tjt��tjd_t#j��|jt(t*j|j|jfD]}|����|���t7j��D]Z}|jdkrMt=d|j����}|sJ�tA|��}|j!sJ�|j!�"|���[d	S)
zgClear the underlying caches, bootstrap the builtins module and
        re-register transforms.
        r)�clear_inference_tip_cache)�ObjectModel)�LookupMixIn)r�r0z.pyzastroid.brain.N)#�astroid.inference_tipr��astroid.interpreter.objectmodelr��astroid.nodes.node_classesr��astroid.nodes.scoped_nodesr�rr*�clear�collections�defaultdict�listr)r1�
transformsr�clear_all_caches�lookuprr�is_namespace�
attributes�_metaclass_lookup_attribute�cache_clearr�r
�iterdir�suffixr�stemr�loader�exec_module)	r7r�r�r�r��	lru_cacher��module_spec�
module_objects	         r&�clear_cachezAstroidManager.clear_cache�s���	D�C�C�C�C�C�?�?�?�?�?�?�:�:�:�:�:�:�7�7�7�7�7�7�!�!�#�#�#������� � �"�"�"�8C�8O�PT�8U�8U���\�*�5��&�(�(�(�
��"����"��0�
�	$�	$�I�
�!�!�#�#�#�#�������.�5�7�7�	>�	>�F��}��%�%�'�(F���(F�(F�G�G��"�"�"�{� 0�� =� =�
�"�)�)�)�)��"�.�.�}�=�=�=��
	>�	>r9)r!r4)r!r:)r>r:r!r4)r!rI)rMrNr!r)NTF)
rRr"rSrTrUr:rVr:r!rI)reN)rfr"rSr"rRrTr!rI)rSr"r!rI)rSr"r]rmr!rI)rSr"r!r:rr)rSrTrtrTrur:r!rI)rRr"r!r�)rSr"r�rTr!r�rE)r�r�rSrTr!rI)r�r}rSrTr!r�)r r�r�r�r!r�)r�r�r!r4)r�rIr!r4)"r�r��__qualname__�__doc__r��setrr1�__annotations__r3r8�propertyr-�setterr.rFrHrLrQrdrjrlrprsrcr�r|r�r�r�r�r�r�r��r9r&r)r)2s���������
�D��� "�"'��'*�s�u�u�&�&�(�(�"�"�E�����+.��-�-�-�-�=�=�=�=��>�>�>��X�>��"�?�?�?�#�"�?��4�4�4��X�4���5�5�5���5��2�2��X�2��4�4��X�4��.�.�.��X�.�+�+�+�+�#���X�X�X�X�X�BDH�	J�	J�	J�	J�	J�>�>�>�>�=�=�=�=�
�
�
�
�$(��	O"�O"�O"�O"�O"�b����6����2?C�B�B�B�B�B�*�����$?C�23�23�23�23�23�h/�/�/�/�;�;�;�;�.�.�.�.�&>�&>�&>�&>�&>�&>r9r))r r	r!r")2r��
__future__rr�rx�typesr��collections.abcrrr�importlib.utilrr�typingr	r
r�r�astroid._cacher�
astroid.constr
�astroid.contextrr�astroid.exceptionsrr�astroid.interpreter._importrr�astroid.modutilsrrrrrrrrr�astroid.transformsr�astroid.typingrrr�r'r)r�r9r&�<module>rs��
��
#�"�"�"�"�"�����	�	�	�	���������8�8�8�8�8�8�8�8�8�8�6�6�6�6�6�6�6�6� � � � � � � � �������(�(�(�(�(�(�1�1�1�1�1�1�?�?�?�?�?�?�?�?�G�G�G�G�G�G�G�G�2�2�2�2�2�2�2�2�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�0�/�/�/�/�/�?�?�?�?�?�?�?�?�;������[>�[>�[>�[>�[>�[>�[>�[>�[>�[>r9

Zerion Mini Shell 1.0