Hacked By AnonymousFox

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

�

�܋f�[�	��UdZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlmZmZmZddlmZmZddlmZddlmZddlmZmZmZdd	lmZmZerdd
l
m Z ndd
l!m Z ej"e#��Z$e
j%�&d��rdZ'd
Z(ndZ'dZ(ej)d��ej)d��hZ*e	j+dkr�e*�,e	j-�.e
j/d����	e*�,e	j-�.e
j0d����nK#e1$rC	e*�,e	j-�.e
j2d����n#e1$rYnwxYwYnwxYwer�e
j3dkr�e*�,e4eej)d����j5dz����e*�,e4eej)d����j5dz����e*�,e4eej)d����j5dz����e*�,e4eej)d����j5dz����e	j+dkrk	e
j0Z/de6d<n#e1$r
e
j/Z/YnwxYwdgd�Z7e*�,e7d����e
j8dkre*�,e7d����ej)d ��ej)d!��hZ9e:�;e
j<d"��Z=Gd#�d$e>��Z?dgd%�Z@efdhd)�ZAdid0�ZBe��dgd1���ZCdgd2�ZDdjd5�ZEdkd7�ZFdld9�ZGdmd;�ZHdnd>�ZI		dodpdB�ZJdqdrdC�ZK		dodsdG�ZL		dodtdI�ZMdqdudJ�ZN	dvdwdN�ZOdvdxdP�ZPdydQ�ZQdzdS�ZRd{dU�ZSdqd|dX�ZTd}dZ�ZU		dod~d\�ZVdd]�ZWd�d_�ZXd�da�ZYd�db�ZZd�df�Z[dS)�aVPython modules manipulation utility functions.

:type PY_SOURCE_EXTS: tuple(str)
:var PY_SOURCE_EXTS: list of possible python source file extension

:type STD_LIB_DIRS: set of str
:var STD_LIB_DIRS: directories where standard modules are located

:type BUILTIN_MODULES: dict
:var BUILTIN_MODULES: dictionary with builtin module names has key
�)�annotationsN)�Callable�Iterable�Sequence)�redirect_stderr�redirect_stdout)�	lru_cache)�Path)�	IS_JYTHON�IS_PYPY�
PY310_PLUS)�spec�util)�stdlib_module_names�win)�py�pyw)�dll�pyd)r)�so�stdlib�
platstdlib�nt�dlls)���lib_pypyzlib-python/3�posix�str�prefix�path�returnc�|�dtjdd�z}tj�t
||��S)Nzpython%d.%d�)�sys�version_info�osr!�joinr )r!�base_pythons  �a/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/astroid/modutils.py�_posix_pathr+cs0��#�c�&6�r��r�&:�:���w�|�|�F�D�+�6�6�6��libl�lib64�purelib�platlibTc��eZdZdZdS)�NoSourceFilezbException raised when we are not able to get a python
    source file for a precompiled file.
    N)�__name__�
__module__�__qualname__�__doc__�r,r*r2r2vs���������r,r2c�z�tj�tj�|����S)z�Resolve symlinks in path and convert to absolute path.

    Note that environment variables and ~ in the path need to be expanded in
    advance.

    This can be cached by using _cache_normalize_path.
    )r'r!�normcase�realpath�r!s r*�_normalize_pathr<|s*���7���B�G�,�,�T�2�2�3�3�3r,�filename�	is_jython�boolc�N�|s|S|�d��\}}}|r|dzS|S)Nz	$py.class�.py)�	partition)r=r>�head�has_pyclass�_s     r*�_path_from_filenamerF�s@������#�-�-�k�:�:��D�+�q����e�|���Or,�	blacklist�
Sequence[str]�dirnames�	list[str]�	filenames�Nonec�v�|D]5}||vr|�|���||vr|�|���6dS)zaRemove files/directories in the black list.

    dirnames/filenames are usually from os.walk
    N)�remove)rGrIrK�norecurss    r*�_handle_blacklistrP�s]���'�'���x����O�O�H�%�%�%�%�
��
"�
"����X�&�&�&��	'�'r,c� �t|��S�N)r<r;s r*�_cache_normalize_path_rS�s���4� � � r,c�B�|st|��St|��S)zNormalize path with caching.)r<rSr;s r*�_cache_normalize_pathrU�s(��
�%��t�$�$�$�!�$�'�'�'r,�dotted_name�types.ModuleTypec��	tj|S#t$rYnwxYwtt	j����5}t
t	j����5}tj|��}ddd��n#1swxYwYddd��n#1swxYwY|�	��}|rt�d||��|�	��}|rt�d||��|S)z�Load a Python module from its name.

    :type dotted_name: str
    :param dotted_name: python name of a module or package

    :raise ImportError: if the module or package is not found

    :rtype: module
    :return: the loaded module
    Nz&Captured stderr while importing %s:
%sz&Captured stdout while importing %s:
%s)
r%�modules�KeyErrorr�io�StringIOr�	importlib�
import_module�getvalue�logger�error�info)rV�stderr�stdout�module�stderr_value�stdout_values      r*�load_module_from_namerh�s���
��{�;�'�'���
�
�
���
����

�����	'�	'�6�6�?�
��
�
�4�4�6�	��(��5�5��6�6�6�6�6�6�6�6�6�6�6����6�6�6�6�6�6�6�6�6�6�6�6�6�6�6����6�6�6�6�
�?�?�$�$�L��
����5�{�L�	
�	
�	
��?�?�$�$�L��
����5�{�L�	
�	
�	
��MsB��
!�!�!B�%B�:B�B
	�
B�
B
	�B�B!�$B!�partsc�F�td�|����S)z�Load a python module from its split name.

    :param parts:
      python name of a module or package split on '.'

    :raise ImportError: if the module or package is not found

    :return: the loaded module
    �.)rhr()ris r*�load_module_from_modpathrl�s��!����%���1�1�1r,�filepathc�>�t|��}t|��S)z�Load a Python module from it's path.

    :type filepath: str
    :param filepath: path to the python module or package

    :raise ImportError: if the module or package is not found

    :rtype: module
    :return: the loaded module
    )�modpath_from_filerl)rm�modpaths  r*�load_module_from_filerq�s�� ��)�)�G�#�G�,�,�,r,�mod_pathc���g}|D]r}|�|��tj�||��}t	|��s,tjd�|����}|sdS�sdS)z3Check there are some __init__.py all along the way.rkFT)�appendr'r!r(�	_has_initr�is_namespace)r!rrrp�part�
old_namespaces     r*�check_modpath_has_initry�s|���G��������t�����w�|�|�D�$�'�'������	� �-�c�h�h�w�.?�.?�@�@�M� �
��u�u���4r,�
path_to_check�list[str] | Nonec�b�d}tj�|��}tj�|��}tj�|���|��r|}tj�|��}tj�|���|��r|}|retj�|��d}|t|��d�}d�|�tj	��D��SdS)a>Extracts the relative mod path of the file to import from.

    Check if a file is within the passed in path and if so, returns the
    relative mod path from the one passed in.

    If the filename is no in path_to_check, returns None

    Note this function will look for both abs and realpath of the file,
    this allows to find the relative base path even if the file is a
    symlink of a file in the passed in path

    Examples:
        _get_relative_base_path("/a/b/c/d.py", "/a/b") ->  ["c","d"]
        _get_relative_base_path("/a/b/c/d.py", "/dev") ->  None
    Nrc��g|]}|�|��Sr7r7)�.0�pkgs  r*�
<listcomp>z+_get_relative_base_path.<locals>.<listcomp>s��G�G�G��3�G��G�G�Gr,)
r'r!r9�abspath�
startswithr:�splitext�len�split�sep)r=rz�importable_path�abs_filename�
real_filename�	base_path�relative_base_paths       r*�_get_relative_base_pathr��s�� �O��G�$�$�]�3�3�M��7�?�?�8�,�,�L�	�w����%�%�0�0��?�?�'�&���G�$�$�X�.�.�M�	�w���
�&�&�1�1�-�@�@�(�'��
�H��G�$�$�_�5�5�a�8�	�&�s�=�'9�'9�';�';�<��G�G�1�7�7���?�?�G�G�G�G��4r,�Sequence[str] | None�
is_package_cb�'Callable[[str, list[str]], bool] | Nonec���tj�t|����}tj���}|r||z
}t
j|tt|����D]4}|s�t||��}|s�|�J�|||dd���r|cS�5td�|d�
tj�������)N���z"Unable to find module for {} in {}z, 
)r'r!�
expanduserrFr%�copy�	itertools�chain�maprUr��ImportError�formatr()r=r!r��paths_to_check�pathnamerps      r*�modpath_from_file_with_callbackr� s��
�w�!�!�"5�h�"?�"?�@�@�H��X�]�]�_�_�N����$����O���1�>�B�B���
�
���	��)�(�H�=�=���	���(�(�(��=��7�3�B�3�<�0�0�	��N�N�N�	��,�3�3�H�f�k�k�#�(�>S�>S�T�T���r,c�.�t||t��S)a*Get the corresponding split module's name from a filename.

    This function will return the name of a module or package split on `.`.

    :type filename: str
    :param filename: file's path for which we want the module's name

    :type Optional[List[str]] path:
      Optional list of path where the module or package should be
      searched (use sys.path if nothing or None is given)

    :raise ImportError:
      if the corresponding module's name has not been found

    :rtype: list(str)
    :return: the corresponding split module's name
    )r�ry)r=r!s  r*roro:s��$+�8�T�;Q�R�R�Rr,rp�context_file�
str | Nonec�.�t|||��jSrR)�file_info_from_modpath�location)rpr!r�s   r*�file_from_modpathr�Os��
"�'�4��>�>�G�Gr,�spec.ModuleSpecc�|�|� tj�|��}n|}|ddkr?	tdg|dd�z||��S#t$rt|||��cYSwxYw|ddgkr5tjdtjjt
jj	�	��St|||��S)
axGiven a mod path (i.e. split module / package name), return the
    corresponding file.

    Giving priority to source file over precompiled file if it exists.

    :param modpath:
      split module's name (i.e name of a module or package split
      on '.')
      (this means explicit relative imports that start with dots have
      empty strings in this list!)

    :param path:
      optional list of path where the module or package should be
      searched (use sys.path if nothing or None is given)

    :param context_file:
      context file to consider, necessary if the identifier has been
      introduced using a relative import unresolvable in the actual
      context (i.e. modutils)

    :raise ImportError: if there is no such module in the directory

    :return:
      the path to the module's file or None if it's an integrated
      builtin module such as 'sys'
    Nr�xml�_xmlplus�r'r!�os.path)�namer��type)
r'r!�dirname�_spec_from_modpathr�r�
ModuleSpec�__file__�
ModuleType�	PY_SOURCE)rpr!r��contexts    r*r�r�Ws���>�� �g�o�o�l�;�;������q�z�U���	>�%�z�l�W�Q�R�R�[�&@�$��P�P�P���	>�	>�	>�%�g�t�W�=�=�=�=�=�	>����	�T�6�N�	"�	"�����W�%���*�
�
�
�	
�
�g�t�W�5�5�5s�A�A-�,A-c	��|�d��rdS|�d��}|�9|dtvr*t|��dkrt	|���|dSd}d}|ddkr|�
Jd���g}d}|t|��kr[||dkrO|dz
}|�
Jd���t
j�|��}|t|��kr||dk�Ot|t|����D]t}	t|||dz�||�	���!#t$rG|tdt|��dz
��kr�d�|d|���cYcSwxYw|S)
a�Given a dotted name return the module part of the name :

    >>> get_module_part('astroid.as_string.dump')
    'astroid.as_string'

    :param dotted_name: full name of the identifier we are interested in

    :param context_file:
      context file to consider, necessary if the identifier has been
      introduced using a relative import unresolvable in the actual
      context (i.e. modutils)

    :raise ImportError: if there is no such module in the directory

    :return:
      the module part of the name or None if we have not been able at
      all to import the given name

    XXX: deprecated, since it doesn't handle package precedence over module
    (see #10066)
    r�rkNrr$�z.explicit relative import, but no context_file?r�)r!r�)r�r��BUILTIN_MODULESr�r�r'r!r��ranger��maxr()rVr�rir!�starti�is      r*�get_module_partr��s���.���i�(�(���y����c�"�"�E�����8��&�&��5�z�z�A�~�~�!�+�.�.�.���8�O�!�D�
�F��Q�x�2�~�~��$�$�;�
%�$�$�����
�3�u�:�:�
�
�%��-�2�"5�"5��!����$�$�;�
%�$�$��w���|�4�4���3�u�:�:�
�
�%��-�2�"5�"5��6�3�u�:�:�
&�
&�'�'��	'���f�q�1�u�n�%�D�|�
�
�
�
�
���	'�	'�	'��3�q�#�e�*�*�q�.�)�)�)�)���8�8�E�"�1�"�I�&�&�&�&�&�&�&�	'�����s�D4�4AF�FF�
src_directory�list_allc��g}tj|��D]s\}}}||vr�t|||��|sd|vrd|dd�<�*|D]F}t|��r5tj�||��}|�|���G�t|S)a�Given a package directory return a list of all available python
    module's files in the package and its subpackages.

    :param src_directory:
      path of the directory corresponding to the package

    :param blacklist: iterable
      list of files or directories to ignore.

    :param list_all:
        get files from all paths, including ones without __init__.py

    :return:
      the list of all available python module's files in the package and
      its subpackages
    z__init__.pyr7N)r'�walkrP�_is_python_filer!r(rt)	r�rGr��files�	directoryrIrKr=�srcs	         r*�get_module_filesr��s���&�E�*,�'�-�*@�*@�"�"�&�	�8�Y��	�!�!���)�X�y�9�9�9��	�M��:�:��H�Q�Q�Q�K��!�	"�	"�H��x�(�(�
"��g�l�l�9�h�7�7�����S�!�!�!��	"��Lr,�include_no_extc�n�tj�t|����}tj�|��\}}t
D],}|�d|��}tj�|��r|cS�-|r#|s!tj�|��r|St|���)asGiven a python module's file name return the matching source file
    name (the filename will be returned identically if it's already an.

    absolute path to a python source file...)

    :param filename: python module's file name

    :raise NoSourceFile: if no source file exists on the file system

    :return: the absolute path of the source file if it exists
    rk)r'r!r�rFr��PY_SOURCE_EXTS�existsr2)r=r��base�orig_ext�ext�source_paths      r*�get_source_filer��s����w���2�8�<�<�=�=�H��W�%�%�h�/�/�N�D�(������o�o��o�o��
�7�>�>�+�&�&�	�����	���h��2�7�>�>�$�+?�+?����
�x�
 �
 � r,c�r�|sdStj�|��ddd�tvS)z5Return: True if the filename is a python source file.Fr�N)r'r!r�r��r=s r*�is_python_sourcer�s8�����u�
�7���H�%�%�a�(����,��>�>r,�modnamec�F�|�d��dtvS)z6Return: True if the modname is in the standard libraryrkr)r�r)r�s r*�is_stdlib_moduler�s���=�=����a� �$7�7�7r,�str | Iterable[str]c�J��|�d��d}	t|g���n#t$rYdSwxYw��dSt����t	|t
��r"��t|����St�fd�|D����S)a
Try to determine if a module is imported from one of the specified paths

    :param modname: name of the module

    :param path: paths to consider

    :return:
      true if the module:
      - is located on the path listed in one of the directory in `paths`
    rkrFNc3�\�K�|]&}��t|����V��'dSrR�r�rU)r~�entryr=s  �r*�	<genexpr>z!module_in_path.<locals>.<genexpr>(s:�����S�S�U�x�"�"�#8��#?�#?�@�@�S�S�S�S�S�Sr,)	r�r�r�r<�
isinstancerr�rU�any)r�r!r=s  @r*�module_in_pathr�
s�����m�m�C� � ��#�G��$�g�Y�/�/���������u�u��������u��x�(�(�H��$����@��"�"�#8��#>�#>�?�?�?��S�S�S�S�d�S�S�S�S�S�Ss�/�
=�=�std_path�Iterable[str] | Nonec���tjdtd���|�d��d}	t	|g���n#t
$rYdSwxYw��t
j|��St����tD]'}��
t|����rdS�(|�t}t�fd�|D����S)	a|Try to guess if a module is a standard python module (by default,
    see `std_path` parameter's description).

    :param modname: name of the module we are interested in

    :param std_path: list of path considered has standard

    :return:
      true if the module:
      - is located on the path listed in one of the directory in `std_path`
      - is a built-in module
    zWis_standard_module() is deprecated. Use, is_stdlib_module() or module_in_path() insteadr$)�
stacklevelrkrFNc3�\�K�|]&}��t|����V��'dSrRr�)r~r!r=s  �r*r�z%is_standard_module.<locals>.<genexpr>Qs:�����U�U�D�x�"�"�#8��#>�#>�?�?�U�U�U�U�U�Ur,)�warnings�warn�DeprecationWarningr�r�r�rrvr<�EXT_LIB_DIRSr�rU�STD_LIB_DIRSr�)r�r�r!r=s   @r*�is_standard_moduler�+s
���
�M�a��������m�m�C� � ��#�G��$�g�Y�/�/���������u�u��������$�W�-�-�-�-��x�(�(�H��������4�T�:�:�;�;�	��5�5�	������U�U�U�U�H�U�U�U�U�U�Us�A�
A�A�	from_filec�:�tj�|��stj�|��}|tjvrdSttjj�	|�
dd���d|g����S)a6Return true if the given module name is relative to the given
    file name.

    :param modname: name of the module we are interested in

    :param from_file:
      path of the module from which modname has been imported

    :return:
      true if the module has been imported relatively to `from_file`
    Frkr�)�maxsplitr)r'r!�isdirr�r%r?r]�	machinery�
PathFinder�	find_specr�)r�r�s  r*�is_relativer�Ts����7�=�=��#�#�/��G�O�O�I�.�.�	��C�H����u����&�0�0��M�M�#��M�*�*�1�-�	�{�	
�	
���r,r�c��|sJ�d}|�K	tj||g��}|j}nA#t$rtj||��}|j}YnwxYwtj||��}|jtjjkrj	|j�J�t|j��}|�|tjj	���S#t$r|�|���cYSwxYw|jtjjkr|�d���S|jtjjkrC|j�J�t|j��}|�|tjj	���S|S)z�Given a mod path (i.e. split module / package name), return the
    corresponding spec.

    this function is used internally, see `file_from_modpath`'s
    documentation for more information
    N)r�r�)r�)rr�r�r�r�r��PY_COMPILEDr��_replacer�r2�	C_BUILTIN�
PKG_DIRECTORYru)rpr!r�r��
found_specs     r*r�r�ns����N�N�7��H���	+����'��;�;�J�!�*�H�H���	+�	+�	+�����6�6�J�!�*�H�H�H�	+�����^�G�T�2�2�
���$�/�5�5�5�	:��&�2�2�2�&�z�':�;�;�H��&�&�!���(A�'���
���	:�	:�	:��&�&��&�9�9�9�9�9�	:����	��D�O�5�	5�	5��"�"�D�"�1�1�1�	��D�O�9�	9�	9��"�.�.�.��Z�0�1�1���"�"�H�4�?�;T�"�U�U�U��s"�(�&A�A�AC� C*�)C*c�,�|�d��S)zlReturn true if the given filename should be considered as a python file.

    .pyc and .pyo are ignored
    )rAz.soz.pydz.pyw)�endswithr�s r*r�r��s��
���;�<�<�<r,r�c��tj�|d��}tdzD]1}tj�|dz|z��r
|dz|zcS�2dS)z]If the given directory has a valid __init__ file, return its path,
    else return None.
    �__init__)�pyc�pyorkN)r'r!r(r�r�)r��mod_or_packr�s   r*ruru�sm���'�,�,�y�*�5�5�K���.�+�+��
�7�>�>�+��+�c�1�2�2�	+���$�s�*�*�*�*�	+��4r,�specobjc�6�|jtjjkSrR)r�rr��PY_NAMESPACE�r�s r*rvrv�s���<�4�?�7�7�7r,c�6�|jtjjkSrR)r�rr�r�r�s r*�is_directoryr�s���<�4�?�8�8�8r,�module_name�package_whitelist�set[str]c	����|�d���t��fd�tdt���dz��D����S)z�
    Returns True if one part of the module name is in the package whitelist.

    >>> is_module_name_part_of_extension_package_whitelist('numpy.core.umath', {'numpy'})
    True
    rkc3�V�K�|]#}d��d|����vV��$dS)rkN)r()r~�xrris  ��r*r�zEis_module_name_part_of_extension_package_whitelist.<locals>.<genexpr>�sN�������56�����r��r����0�0������r,r�)r�r�r�r�)rrris `@r*�2is_module_name_part_of_extension_package_whitelistr�sk����
���c�"�"�E�������:?��3�u�:�:�PQ�>�:R�:R������r,)r!rr"r)r=rr>r?r"r)rGrHrIrJrKrJr"rL)rVrr"rW)rirHr"rW)rmrr"rW)r!rrrrJr"r?)r=rrzrr"r{)NN)r=rr!r�r�r�r"rJrR)r=rr!r�r"rJ)rprJr!r�r�r�r"r�)rprJr!r�r�r�r"r�)rVrr�r�r"r)F)r�rrGrHr�r?r"rJ)r=rr�r?r"r)r=r�r"r?)r�rr"r?)r�rr!r�r"r?)r�rr�r�r"r?)r�rr�rr"r?)rprJr!r�r�r�r"r�)r=rr"r?)r�rr"r�)r�r�r"r?)rrrrr"r?)\r6�
__future__rr]�importlib.machinery�importlib.utilr[r��loggingr'r%�	sysconfig�typesr��collections.abcrrr�
contextlibrr�	functoolsr	�pathlibr
�
astroid.constrrr
�astroid.interpreter._importrrr�astroid._backport_stdlib_names�	getLoggerr3r`�platformr�r��PY_COMPILED_EXTS�get_pathr�r��addr!r(r �real_prefix�AttributeError�base_exec_prefixr&r�parent�__annotations__r+�maxsizer��dict�fromkeys�builtin_module_namesr��	Exceptionr2r<rFrPrSrUrhrlrqryr�r�ror�r�r�r�r�r�r�r�r�r�r�r�rurvrrr7r,r*�<module>r$s���

�
�
�#�"�"�"�"�"�������������	�	�	�	���������	�	�	�	�
�
�
�
�������������8�8�8�8�8�8�8�8�8�8�7�7�7�7�7�7�7�7�������������8�8�8�8�8�8�8�8�8�8�2�2�2�2�2�2�2�2�
�C�'�'�'�'�'�'�'�B�B�B�B�B�B�	��	�8�	$�	$���<���5�!�!��"�N�%����N���
#�	�"�8�,�,�.@�i�.@��.N�.N�O���7�d�?�?����R�W�\�\�#�*�f�5�5�6�6�6�
�
	�������c�o�v�>�>�?�?�?�?������	����R�W�\�\�#�*>��G�G�H�H�H�H���	�	�	��D�	������
������s��&�(�(����S�S���0�i�0��:�:�;�;�B�Z�O�P�P�Q�Q�Q����S�S���0�i�0��:�:�;�;�B�^�S�T�T�U�U�U����S�S���0�i�0��>�>�?�?�F��S�T�T�U�U�U������D�D�#��#�L�1�1�2�2�9�N�J�K�K�����7�g���
��o��%�%�%�%�%���������������7�7�7�7����[�[��'�'�(�(�(�
�{�U���	�����W�-�-�.�.�.�"�	�"�9�-�-�/A�y�/A�)�/L�/L�M���-�-�� 8�$�?�?�������9����4�4�4�4�:C������'�'�'�'�����!�!�!�
��!�(�(�(�(�"�"�"�"�J
2�
2�
2�
2�-�-�-�-�
�
�
�
�"�"�"�"�N"&�=A������4S�S�S�S�S�."&�#�H�H�H�H�H�"&�#�06�06�06�06�06�f:�:�:�:�:�|DI� � � � � �F!�!�!�!�!�.?�?�?�?�8�8�8�8�
T�T�T�T�<&V�&V�&V�&V�&V�R����8"&��&�&�&�&�&�R=�=�=�=�����8�8�8�8�9�9�9�9������sH�3D;�;F�3E5�4F�5E=�:F�<E=�=F�F�J � J/�.J/

Hacked By AnonymousFox1.0, Coded By AnonymousFox