
    /hD*                     4   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
mZ ddlmZmZmZ  ej        e          Zda G d de          Z G d d	e          Z G d
 de          Z G d de          Z G d de          Z G d de          Z ed          ee	j        eiZ	 	 d dlZn# e $ r d dl!ZY nw xY weeej"        <   eeej#        <   eeej$        <   [n# e e%f$ r Y nw xY wd Z&i Z'd Z( ej)         e*d                    Z+d Z,dS )    )unicode_literalsN   )DistlibException)cached_propertyget_cache_baseCachec                   ,     e Zd Zd fd	Zd Zd Z xZS )ResourceCacheNc                     |9t           j                            t                      t	          d                    }t          t          |                               |           d S )Nzresource-cache)ospathjoinr   strsuperr
   __init__)selfbase	__class__s     P/var/www/html/venv/lib/python3.11/site-packages/pip/_vendor/distlib/resources.pyr   zResourceCache.__init__   sP    <7<< 0 0#6F2G2GHHDmT""++D11111    c                     dS )z
        Is the cache stale for the given resource?

        :param resource: The :class:`Resource` being cached.
        :param path: The path of the resource in the cache.
        :return: True if the cache is stale.
        T r   resourcer   s      r   is_stalezResourceCache.is_stale"   s	     tr   c                 Z   |j                             |          \  }}||}nt          j                            | j        |                     |          |          }t          j                            |          }t          j                            |          st          j	        |           t          j        
                    |          sd}n|                     ||          }|rBt          |d          5 }|                    |j                   ddd           n# 1 swxY w Y   |S )z
        Get a resource into the cache,

        :param resource: A :class:`Resource` instance.
        :return: The pathname of the resource in the cache.
        NTwb)finderget_cache_infor   r   r   r   prefix_to_dirdirnameisdirmakedirsexistsr   openwritebytes)r   r   prefixr   resultr!   stalefs           r   getzResourceCache.get-   s<     55h??>FFW\\$)T-?-?-G-GNNFgoof--G7==)) %G$$$7>>&)) 6h55 ,&$'' ,1GGHN+++, , , , , , , , , , , , , , ,s   9D  D$'D$N)__name__
__module____qualname__r   r   r,   __classcell__r   s   @r   r
   r
      s[        2 2 2 2 2 2	 	 	      r   r
   c                       e Zd Zd ZdS )ResourceBasec                 "    || _         || _        d S r-   )r   name)r   r   r6   s      r   r   zResourceBase.__init__H   s    			r   N)r.   r/   r0   r   r   r   r   r4   r4   G   s#            r   r4   c                   ^    e Zd ZdZdZd Zed             Zed             Zed             Z	dS )Resourcez
    A class representing an in-package resource, such as a data file. This is
    not normally instantiated by user code, but rather by a
    :class:`ResourceFinder` which manages the resource.
    Fc                 6    | j                             |           S )z
        Get the resource as a stream.

        This is not a property to make it obvious that it returns a new stream
        each time.
        )r   
get_streamr   s    r   	as_streamzResource.as_streamU   s     {%%d+++r   c                 `    t           t                      a t                               |           S r-   )cacher
   r,   r;   s    r   	file_pathzResource.file_path^   s"     =!OOEyyr   c                 6    | j                             |           S r-   )r   	get_bytesr;   s    r   r'   zResource.bytese   s    {$$T***r   c                 6    | j                             |           S r-   )r   get_sizer;   s    r   sizezResource.sizei   s    {##D)))r   N)
r.   r/   r0   __doc__is_containerr<   r   r?   r'   rD   r   r   r   r8   r8   M   s         
 L, , ,   _ + + _+ * * _* * *r   r8   c                   (    e Zd ZdZed             ZdS )ResourceContainerTc                 6    | j                             |           S r-   )r   get_resourcesr;   s    r   	resourceszResourceContainer.resourcesq   s    {((...r   N)r.   r/   r0   rF   r   rK   r   r   r   rH   rH   n   s2        L/ / _/ / /r   rH   c                       e Zd ZdZej                            d          rdZndZd Zd Z	d Z
d Zd	 Zd
 Zd Zd Zd Zd Zd Z eej        j                  Zd ZdS )ResourceFinderz4
    Resource finder for file system resources.
    java).pyc.pyoz.class)rO   rP   c                     || _         t          |dd           | _        t          j                            t          |dd                    | _        d S )N
__loader____file__ )modulegetattrloaderr   r   r!   r   )r   rU   s     r   r   zResourceFinder.__init__   sA    flD99GOOGFJ$C$CDD			r   c                 @    t           j                            |          S r-   )r   r   realpathr   r   s     r   _adjust_pathzResourceFinder._adjust_path   s    w%%%r   c                     t          |t                    rd}nd}|                    |          }|                    d| j                   t          j        j        | }|                     |          S )N   //r   )	
isinstancer'   splitinsertr   r   r   r   r[   )r   resource_nameseppartsr)   s        r   
_make_pathzResourceFinder._make_path   sm     mU++ 	CCC##C((Q	"""u%  (((r   c                 @    t           j                            |          S r-   )r   r   r$   rZ   s     r   _findzResourceFinder._find   s    w~~d###r   c                     d |j         fS r-   )r   r   r   s     r   r   zResourceFinder.get_cache_info   s    X]""r   c                     |                      |          }|                     |          sd }n=|                     |          rt          | |          }nt	          | |          }||_        |S r-   )re   rg   _is_directoryrH   r8   r   )r   rb   r   r)   s       r   findzResourceFinder.find   sp    }--zz$ 	FF!!$'' 7*4??!$66FKr   c                 ,    t          |j        d          S Nrb)r%   r   ri   s     r   r:   zResourceFinder.get_stream   s    HM4(((r   c                     t          |j        d          5 }|                                cd d d            S # 1 swxY w Y   d S rn   )r%   r   read)r   r   r+   s      r   rA   zResourceFinder.get_bytes   s    (-&& 	!6688	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   7;;c                 J    t           j                            |j                  S r-   )r   r   getsizeri   s     r   rC   zResourceFinder.get_size   s    wx}---r   c                 t      fdt          fdt          j        |j                  D                       S )Nc                 F    | dk    o|                      j                   S )N__pycache__)endswithskipped_extensions)r+   r   s    r   allowedz-ResourceFinder.get_resources.<locals>.allowed   s,    & 8JJt677,8 9r   c                 *    g | ]} |          |S r   r   ).0r+   ry   s     r   
<listcomp>z0ResourceFinder.get_resources.<locals>.<listcomp>   s&    GGG!GGAJJGAGGGr   )setr   listdirr   )r   r   ry   s   ` @r   rJ   zResourceFinder.get_resources   sN    	9 	9 	9 	9 	9 GGGGrz(-88GGGHHHr   c                 6    |                      |j                  S r-   )rk   r   ri   s     r   rF   zResourceFinder.is_container   s    !!(-000r   c              #   T  K   |                      |          }||g}|r|                    d          }|V  |j        rc|j        }|j        D ]T}|s|}nd                    ||g          }|                      |          }|j        r|                    |           P|V  U|d S d S d S )Nr   r^   )rl   poprF   r6   rK   r   append)r   rb   r   todornamer6   new_namechilds           r   iteratorzResourceFinder.iterator   s      99]++:D (88A;;( ($ME ( 2 	( 	($ ?'+HH'*xx'>'>H $		( 3 3 - ( KK...."'KKKK  ( ( (  ( (r   N)r.   r/   r0   rE   sysplatform
startswithrx   r   r[   re   rg   r   rl   r:   rA   rC   rJ   rF   staticmethodr   r   r"   rk   r   r   r   r   rM   rM   v   s         |v&& .7-E E E
& & &
) 
) 
)$ $ $# # #
 
 
) ) )  . . .I I I1 1 1 !L//M( ( ( ( (r   rM   c                   R     e Zd ZdZ fdZd Zd Zd Zd Zd Z	d Z
d	 Zd
 Z xZS )ZipResourceFinderz6
    Resource finder for resources in .zip files.
    c                 L   t          t          |                               |           | j        j        }dt          |          z   | _        t          | j        d          r| j        j        | _        nt          j
        |         | _        t          | j                  | _        d S )Nr   _files)r   r   r   rW   archivelen
prefix_lenhasattrr   	zipimport_zip_directory_cachesortedindex)r   rU   r   r   s      r   r   zZipResourceFinder.__init__   s    &&//777+%c'll*4;)) 	B+,DKK#8ADKDK((


r   c                     |S r-   r   rZ   s     r   r[   zZipResourceFinder._adjust_path   s    r   c                    || j         d          }|| j        v rd}nu|r%|d         t          j        k    r|t          j        z   }t	          j        | j        |          }	 | j        |                             |          }n# t          $ r d}Y nw xY w|s't          	                    d|| j
        j                   n&t          	                    d|| j
        j                   |S )NTFz_find failed: %r %rz_find worked: %r %r)r   r   r   rc   bisectr   r   
IndexErrorloggerdebugrW   r(   )r   r   r)   is       r   rg   zZipResourceFinder._find   s    DO$$%4;FF %RBF**bf}dj$//AA11$77    	JLL.dk6HIIIILL.dk6HIIIs    A? ?BBc                 `    | j         j        }|j        dt          |          z   d          }||fS )Nr   )rW   r   r   r   )r   r   r(   r   s       r   r   z ZipResourceFinder.get_cache_info   s2    $}QV_--.t|r   c                 @    | j                             |j                  S r-   )rW   get_datar   ri   s     r   rA   zZipResourceFinder.get_bytes   s    {##HM222r   c                 P    t          j        |                     |                    S r-   )ioBytesIOrA   ri   s     r   r:   zZipResourceFinder.get_stream   s    z$..22333r   c                 P    |j         | j        d          }| j        |         d         S )N   )r   r   r   r   s      r   rC   zZipResourceFinder.get_size   s(    }T_--.{4 ##r   c                 2   |j         | j        d          }|r%|d         t          j        k    r|t          j        z  }t	          |          }t                      }t          j        | j        |          }|t	          | j                  k     r| j        |                             |          snk| j        |         |d          }|	                    |
                    t          j        d          d                    |dz  }|t	          | j                  k     |S )Nr   r   r   )r   r   r   rc   r   r}   r   r   r   addr`   )r   r   r   plenr)   r   ss          r   rJ   zZipResourceFinder.get_resources  s    }T_--. 	DH&&BFND4yyM$*d++#dj//!!:a=++D11 
1dee$AJJqwwrvq))!,---FA #dj//!! r   c                    || j         d          }|r%|d         t          j        k    r|t          j        z  }t          j        | j        |          }	 | j        |                             |          }n# t          $ r d}Y nw xY w|S )Nr   F)r   r   rc   r   r   r   r   )r   r   r   r)   s       r   rk   zZipResourceFinder._is_directory  s    DO$$% 	DH&&BFNDM$*d++	Z]--d33FF 	 	 	FFF	s    A3 3BB)r.   r/   r0   rE   r   r[   rg   r   rA   r:   rC   rJ   rk   r1   r2   s   @r   r   r      s         	) 	) 	) 	) 	)    $  
3 3 34 4 4$ $ $  	 	 	 	 	 	 	r   r   c                 4    |t           t          |           <   d S r-   )_finder_registrytype)rW   finder_makers     r   register_finderr   2  s    %1T&\\"""r   c                    | t           v rt           |          }n| t          j        vrt          |            t          j        |          }t	          |dd          }|t          d          t	          |dd          }t                              t          |                    }|t          d| z             ||          }|t           | <   |S )z
    Return a resource finder for a package.
    :param package: The name of the package.
    :return: A :class:`ResourceFinder` instance for the package.
    __path__Nz8You cannot get a finder for a module, only for a packagerR   zUnable to locate finder for %r)	_finder_cacher   modules
__import__rV   r   r   r,   r   )packager)   rU   r   rW   r   s         r   r   r   9  s     -w'#+%%wW%vz400<" $8 9 9 9t44'++DLL99"#Cg#MNNNf%%!'gMr   	__dummy__c                 >   d}t          j        |            t          j                            |           }t
                              t          |                    }|r>t          }t          j	        
                    | d          |_        ||_         ||          }|S )z
    Return a resource finder for a path, which should represent a container.

    :param path: The path.
    :return: A :class:`ResourceFinder` instance for the path.
    NrT   )pkgutilget_importerr   path_importer_cacher,   r   r   _dummy_moduler   r   r   rS   rR   )r   r)   rW   r   rU   s        r   finder_for_pathr   U  s     F$((..F!!$v,,//F  ',,tR00"Mr   )-
__future__r   r   r   loggingr   r   r   typesr   rT   r   utilr   r   r   	getLoggerr.   r   r>   r
   objectr4   r8   rH   rM   r   r   zipimporterr   _frozen_importlib_external_fiImportError_frozen_importlibSourceFileLoader
FileFinderSourcelessFileLoaderAttributeErrorr   r   r   
ModuleTyper   r   r   r   r   r   <module>r      s   ( ' ' ' ' '  				  				  



            8 8 8 8 8 8 8 8 8 8		8	$	$ 	) ) ) ) )E ) ) )X    6   * * * * *| * * *B/ / / / / / / /W( W( W( W( W(V W( W( W(tK K K K K K K K^ 	DJJ, 
	(00000 ( ( (''''''(-;S)*'5S^$1?S-.^$ 	 	 	D	2 2 2   2 ! [!1!122    s0   3B8 7C' 8	CC' C"C' 'C10C1