
    yIf@\              	         U d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddlZddlmZmZmZ ddlmZmZ ddlmZ ddlmZ ddlmZmZmZ dd	lmZmZ erdd
l
m Z  ndd
l!m Z   ej"        e#          Z$e
j%        &                    d          rdZ'dZ(ndZ'dZ( ej)        d           ej)        d          hZ*e	j+        dk    re*,                    e	j-        .                    e
j/        d                     	 e*,                    e	j-        .                    e
j0        d                     nK# e1$ rC 	 e*,                    e	j-        .                    e
j2        d                     n# e1$ r Y nw xY wY nw xY were
j3        dk     re*,                     e4 e ej)        d                    j5        dz                       e*,                     e4 e ej)        d                    j5        dz                       e*,                     e4 e ej)        d                    j5        dz                       e*,                     e4 e ej)        d                    j5        dz                       e	j+        dk    rk	 e
j0        Z/de6d<   n# e1$ r
 e
j/        Z/Y nw xY wdgdZ7e*,                     e7d                     e
j8        dk    re*,                     e7d                      ej)        d            ej)        d!          hZ9e:;                    e
j<        d"          Z= G d# d$e>          Z?dgd%Z@efdhd)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\ZVdd]ZWdd_ZXddaZYddbZZddfZ[dS )aV  Python 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pyi)dllpyd)r   r   )sostdlib
platstdlibntdlls)      lib_pypyzlib-python/3posixstrprefixpathreturnc                |    dt           j        d d         z  }t          j                            t
          | |          S )Nzpython%d.%d   )sysversion_infoosr"   joinr!   )r"   base_pythons     D/var/www/piapp/venv/lib/python3.11/site-packages/astroid/modutils.py_posix_pathr,   c   s0    #c&6rr&::w||FD+666    libl        lib64purelibplatlibTc                      e Zd ZdZdS )NoSourceFilezbException raised when we are not able to get a python
    source file for a precompiled file.
    N)__name__
__module____qualname____doc__ r-   r+   r3   r3   v   s           r-   r3   c                z    t           j                            t           j                            |                     S )zResolve 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BG,,T22333r-   filename	is_jythonboolc                N    |s| S |                      d          \  }}}|r|dz   S | S )Nz	$py.class.py)	partition)r>   r?   headhas_pyclass_s        r+   _path_from_filenamerG      s@     #--k::D+q e|Or-   	blacklistSequence[str]dirnames	list[str]	filenamesNonec                v    | D ]5}||v r|                     |           ||v r|                     |           6dS )zaRemove files/directories in the black list.

    dirnames/filenames are usually from os.walk
    N)remove)rH   rJ   rL   norecurss       r+   _handle_blacklistrQ      s]      ' 'xOOH%%%%""X&&&	' 'r-   c                     t          |           S N)r=   r<   s    r+   _cache_normalize_path_rT      s    4   r-   c                B    | st          |           S t          |           S )zNormalize path with caching.)r=   rT   r<   s    r+   _cache_normalize_pathrV      s(    
  %t$$$!$'''r-   dotted_nametypes.ModuleTypec                   	 t           j        |          S # t          $ r Y nw xY wt          t	          j                              5 }t          t	          j                              5 }t          j        |           }ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |	                                }|rt                              d| |           |	                                }|rt                              d| |           |S )zLoad 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)rW   stderrstdoutmodulestderr_valuestdout_values         r+   load_module_from_nameri      s   {;''   
 
	'	' 66?
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    t          d                    |                     S )zLoad 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
    .)ri   r)   )rj   s    r+   load_module_from_modpathrm      s     !%111r-   filepathc                >    t          |           }t          |          S )zLoad 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_filerm   )rn   modpaths     r+   load_module_from_filerr      s      ))G#G,,,r-   mod_pathc                    g }|D ]r}|                     |           t          j                            | |          } t	          |           s,t          j        d                    |                    }|s dS sdS )z3Check there are some __init__.py all along the way.rl   FT)appendr(   r"   r)   	_has_initr   is_namespace)r"   rs   rq   partold_namespaces        r+   check_modpath_has_initrz      s|    G  tw||D$'' 	 -chhw.?.?@@M  uu4r-   path_to_checklist[str] | Nonec                b   d}t           j                            |          }t           j                            |           }t           j                            |                              |          r|}t           j                            |           }t           j                            |                              |          r|}|ret           j                            |          d         }|t          |          d         }d |                    t           j	                  D             S dS )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
    Nr   c                    g | ]}||S r8   r8   ).0pkgs     r+   
<listcomp>z+_get_relative_base_path.<locals>.<listcomp>  s    GGG3GGGGr-   )
r(   r"   r:   abspath
startswithr;   splitextlensplitsep)r>   r{   importable_pathabs_filenamereal_filename	base_pathrelative_base_paths          r+   _get_relative_base_pathr      s     OG$$]33M7??8,,L	w%%00?? '&G$$X..M	w&&11-@@ (' HG$$_55a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                   t           j                            t          |                     } t          j                                        }|r||z  }t          j        |t          t          |                    D ]4}|st          | |          }|s|J  |||d d                   r|c S 5t          d                    | d                    t          j                                      )Nz"Unable to find module for {} in {}z, 
)r(   r"   
expanduserrG   r&   copy	itertoolschainmaprV   r   ImportErrorformatr)   )r>   r"   r   paths_to_checkpathnamerq   s         r+   modpath_from_file_with_callbackr     s    
 w!!"5h"?"?@@HX]]__N $O1>BB  
 
  	)(H== 	(((=73B3<00 	NNN	 ,33Hfkk#(>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   rz   )r>   r"   s     r+   rp   rp   7  s    $ +8T;QRRRr-   rq   context_file
str | Nonec                .    t          | ||          j        S rS   )file_info_from_modpathlocation)rq   r"   r   s      r+   file_from_modpathr   L  s    
 "'4>>GGr-   spec.ModuleSpecc                |   | t           j                            |          }n|}| d         dk    r?	 t          dg| dd         z   ||          S # t          $ r t          | ||          cY S w xY w| ddgk    r5t          j        dt           j        j        t
          j        j	        	          S t          | ||          S )
ax  Given 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)rq   r"   r   contexts       r+   r   r   T  s    >  gool;;qzU	>%zlWQRR[&@$PPP 	> 	> 	>%gtW=====	>	T6N	"	"W%*
 
 
 	

 gtW555s   A A-,A-c           	        |                      d          rdS |                     d          }|9|d         t          v r*t          |          dk    rt	          |           |d         S d}d}|d         dk    r|
J d            g }d}|t          |          k     r[||         dk    rO|dz  }|
J d            t
          j                            |          }|t          |          k     r||         dk    Ot          |t          |                    D ]t}	 t          |||dz            ||	           !# t          $ rG |t          dt          |          dz
            k     r d                    |d|                   cY c S w xY w| 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   rl   Nr   r%    z.explicit relative import, but no context_file?r   )r"   r   )r   r   BUILTIN_MODULESr   r   r(   r"   r   ranger   maxr)   )rW   r   rj   r"   startiis         r+   get_module_partr     s   . i(( yc""E 8&&5zzA~~!+...8O!DFQx2~~$$; %$$
3u::

%-2"5"5!$$; %$$w|44 3u::

%-2"5"5 63u::&& ' '	'fq1un%D|      	' 	' 	'3q#e**q.))))88E"1"I&&&&&&&	' s   D44AFFFsrc_directorylist_allc                @   g }t          j        |           D ]\  }}}||v rt          |||           |sddh                    |          rd|dd<   =|D ]F}t	          |          r5t           j                            ||          }|                    |           G|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__.pyz__init__.pyir8   N)r(   walkrQ   
isdisjoint_is_python_filer"   r)   ru   )	r   rH   r   files	directoryrJ   rL   r>   srcs	            r+   get_module_filesr     s    & E*,'-*@*@ " "&	8Y	!!)Xy999 	]N;FFyQQ 	HQQQK! 	" 	"Hx(( "gll9h77S!!!	" Lr-   include_no_extc                   t           j                            t          |                     } t           j                            |           \  }}|dk    r)t           j                            | |           r| | S t          D ],}| d| }t           j                            |          r|c S -|r#|s!t           j                            |          r|S t          |           )ao  Given 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
    .pyirl   )r(   r"   r   rG   r   existsPY_SOURCE_EXTSr3   )r>   r   baseorig_extextsource_paths         r+   get_source_filer     s     w28<<==HW%%h//ND(6bgnn-@h-@-@AA""""  oooo7>>+&& 		 h 27>>$+?+? 
x
 
  r-   c                r    | sdS t           j                            |           d         dd         t          v S )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          d         t          v S )z6Return: True if the modname is in the standard libraryrl   r   )r   r   )r   s    r+   is_stdlib_moduler     s    ==a $777r-   str | Iterable[str]c                J   |                      d          d         } 	 t          | g          n# t          $ r Y dS w xY wdS t                    t	          |t
                    r"                    t          |                    S t          fd|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`
    rl   r   FNc              3  \   K   | ]&}                     t          |                    V  'd S rS   r   rV   )r   entryr>   s     r+   	<genexpr>z!module_in_path.<locals>.<genexpr>&  s:      SSUx""#8#?#?@@SSSSSSr-   )	r   r   r   r=   
isinstancer    r   rV   any)r   r"   r>   s     @r+   module_in_pathr     s     mmC  #G$gY//   uu ux((H$ @""#8#>#>???SSSSdSSSSSSs   / 
==std_pathIterable[str] | Nonec                   t          j        dt          d           |                     d          d         } 	 t	          | g          n# t
          $ r Y dS w xY wt          j        |            S t                    t          D ]'}
                    t          |                    r dS (|t          }t          fd|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%   )
stacklevelrl   r   FNc              3  \   K   | ]&}                     t          |                    V  'd S rS   r   )r   r"   r>   s     r+   r   z%is_standard_module.<locals>.<genexpr>O  s:      UUDx""#8#>#>??UUUUUUr-   )warningswarnDeprecationWarningr   r   r   r   rw   r=   EXT_LIB_DIRSr   rV   STD_LIB_DIRSr   )r   r   r"   r>   s      @r+   is_standard_moduler   )  s
    Ma    mmC  #G$gY//    uu $W----x((H  4T::;; 	55	UUUUHUUUUUUs   A 
AA	from_filec                :   t           j                            |          st           j                            |          }|t          j        v rdS t          t          j        j        	                    | 
                    dd          d         |g                    S )a6  Return 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`
    Frl   r   )maxsplitr   )r(   r"   isdirr   r&   r@   r^   	machinery
PathFinder	find_specr   )r   r   s     r+   is_relativer   R  s     7==## /GOOI..	CHu&00MM#M**1-	{	
 	
  r-   r   c                   | sJ d}|K	 t          j        | |g          }|j        }nA# t          $ r t          j        | |          }|j        }Y nw xY wt          j        | |          }|j        t           j        j        k    rj	 |j        J t          |j                  }|                    |t           j        j	                  S # t          $ r |                    |          cY S w xY w|j        t           j        j        k    r|                    d          S |j        t           j        j        k    rC|j        J t          |j                  }|                    |t           j        j	                  S |S )zGiven 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   )r   r   r   r   r   r   PY_COMPILEDr   _replacer   r3   	C_BUILTINPKG_DIRECTORYrv   )rq   r"   r   r   
found_specs        r+   r   r   l  s    NNNH	+';;J!*HH 	+ 	+ 	+66J!*HHH	+ ^GT22
$/555	:&222&z':;;H&&!(A '     	: 	: 	:&&&99999	:	DO5	5	5""D"111	DO9	9	9"...Z011""H4?;T"UUUs"   ( &AAAC  C*)C*c                ,    |                      d          S )zlReturn true if the given filename should be considered as a python file.

    .pyc and .pyo are ignored
    )rB   r   z.soz.pydz.pyw)endswithr   s    r+   r   r     s    
 CDDDr-   r   c                    t           j                            | d          }g t          ddR D ]1}t           j                            |dz   |z             r
|dz   |z   c S 2dS )z]If the given directory has a valid __init__ file, return its path,
    else return None.
    __init__pycpyorl   N)r(   r"   r)   r   r   )r   mod_or_packr   s      r+   rv   rv     sz     ',,y*55K..... + +7>>++c122 	+$s****	+4r-   specobjc                6    | j         t          j        j        k    S rS   )r   r   r   PY_NAMESPACEr   s    r+   rw   rw     s    <4?777r-   c                6    | j         t          j        j        k    S rS   )r   r   r   r   r  s    r+   is_directoryr    s    <4?888r-   module_namepackage_whitelistset[str]c           	         |                      d          t          fdt          dt                    dz             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
    rl   c              3  V   K   | ]#}d                      d|                   v V  $dS )rl   N)r)   )r   xr  rj   s     r+   r   zEis_module_name_part_of_extension_package_whitelist.<locals>.<genexpr>  sN        56rr00     r-   r   )r   r   r   r   )r  r  rj   s    `@r+   2is_module_name_part_of_extension_package_whitelistr
    sk     c""E     :?3u::PQ>:R:R     r-   )r"   r    r#   r    )r>   r    r?   r@   r#   r    )rH   rI   rJ   rK   rL   rK   r#   rM   )rW   r    r#   rX   )rj   rI   r#   rX   )rn   r    r#   rX   )r"   r    rs   rK   r#   r@   )r>   r    r{   r    r#   r|   )NN)r>   r    r"   r   r   r   r#   rK   rS   )r>   r    r"   r   r#   rK   )rq   rK   r"   r   r   r   r#   r   )rq   rK   r"   r   r   r   r#   r   )rW   r    r   r   r#   r    )F)r   r    rH   rI   r   r@   r#   rK   )r>   r    r   r@   r#   r    )r>   r   r#   r@   )r   r    r#   r@   )r   r    r"   r   r#   r@   )r   r    r   r   r#   r@   )r   r    r   r    r#   r@   )rq   rK   r"   r   r   r   r#   r   )r>   r    r#   r@   )r   r    r#   r   )r   r   r#   r@   )r  r    r  r  r#   r@   )\r7   
__future__r   r^   importlib.machineryimportlib.utilr\   r   loggingr(   r&   	sysconfigtypesr   collections.abcr   r   r   
contextlibr   r   	functoolsr	   pathlibr
   astroid.constr   r   r   astroid.interpreter._importr   r   r   astroid._backport_stdlib_names	getLoggerr4   ra   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   	Exceptionr3   r=   rG   rQ   rT   rV   ri   rm   rr   rz   r   r   rp   r   r   r   r   r   r   r   r   r   r   r   r   rv   rw   r  r
  r8   r-   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7d??RW\\#*f55666
 	cov>>????   	RW\\#*>GGHHHH 	 	 	D	  s&(( SS0i0::;;BZOPPQQQSS0i0::;;B^STTUUU SS0i0>>??FSTTUUUDD##L11229NJKK   7g
o%%%%%   7 7 7 7 [[''(((
{U 	W--..."	"9--/Ay/A)/L/LM-- 8$??    9   4 4 4 4 :C     ' ' ' ' ! ! ! !( ( ( (" " " "J
2 
2 
2 
2- - - -
 
 
 
   H "&=A    4S S S S S. "&#H H H H H "&#06 06 06 06 06f: : : : :| DI         F! ! ! ! !0? ? ? ?8 8 8 8
T T T T<&V &V &V &V &VR   8 "&& & & & &RE E E E   8 8 8 89 9 9 9     sH   3D; ;F3E54F5E=:F<E==FFJ   J/.J/