
    UhD*                     .   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	j8                  eiZ	 	 d dlZeeejD                  <   eeejF                  <   eeejH                  <   [d Z&i Z'd Z( ejR                   e*d            Z+d Z,y# e $ r d dl!ZY ]w xY w# e e%f$ r Y <w xY w)    )unicode_literalsN   )DistlibException)cached_propertyget_cache_baseCachec                   ,     e Zd Zd fd	Zd Zd Z xZS )ResourceCachec                     |1t         j                  j                  t               t	        d            }t
        t        |   |       y )Nzresource-cache)ospathjoinr   strsuperr
   __init__)selfbase	__class__s     W/var/www/html/IOPaint/env/lib/python3.12/site-packages/pip/_vendor/distlib/resources.pyr   zResourceCache.__init__   s4    <77<< 0#6F2GHDmT+D1    c                      y)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     r   c                 R   |j                   j                  |      \  }}||}|S t        j                  j	                  | j
                  | j                  |      |      }t        j                  j                  |      }t        j                  j                  |      st        j                  |       t        j                  j                  |      sd}n| j                  ||      }|r2t        |d      5 }|j                  |j                         ddd       |S |S # 1 sw Y   |S xY w)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?>F  WW\\$))T-?-?-GNFggoof-G77==)G$77>>&)h5&$' ,1GGHNN+,v,s   4DD&N)__name__
__module____qualname__r   r   r,   __classcell__r   s   @r   r
   r
      s    2	r   r
   c                       e Zd Zd Zy)ResourceBasec                      || _         || _        y 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                   J    e Zd ZdZdZd Zed        Zed        Zed        Z	y)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                 8    | j                   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                 L    t         
t               a t         j                  |       S r-   )cacher
   r,   r;   s    r   	file_pathzResource.file_path^   s     =!OEyyr   c                 8    | j                   j                  |       S r-   )r   	get_bytesr;   s    r   r'   zResource.bytese   s    {{$$T**r   c                 8    | j                   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   sO    
 L,   + + * *r   r8   c                        e Zd ZdZed        Zy)ResourceContainerTc                 8    | j                   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   s    L/ /r   rH   c                       e Zd ZdZej
                  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y)ResourceFinderz4
    Resource finder for file system resources.
    java).pyc.pyoz.class)rO   rP   c                     || _         t        |dd       | _        t        j                  j                  t        |dd            | _        y )N
__loader____file__ )modulegetattrloaderr   r   r!   r   )r   rU   s     r   r   zResourceFinder.__init__   s6    flD9GGOOGFJ$CD	r   c                 @    t         j                  j                  |      S r-   )r   r   realpathr   r   s     r   _adjust_pathzResourceFinder._adjust_path   s    ww%%r   c                     t        |t              rd}nd}|j                  |      }|j                  d| j                         t        j                  j                  | }| j                  |      S )N   //r   )	
isinstancer'   splitinsertr   r   r   r   r[   )r   resource_nameseppartsr)   s        r   
_make_pathzResourceFinder._make_path   s]     mU+CC##C(Q		"u%  ((r   c                 @    t         j                  j                  |      S r-   )r   r   r$   rZ   s     r   _findzResourceFinder._find   s    ww~~d##r   c                     d |j                   fS r-   )r   r   r   s     r   r   zResourceFinder.get_cache_info   s    X]]""r   c                     | j                  |      }| j                  |      sd }|S | j                  |      rt        | |      }nt	        | |      }||_        |S r-   )re   rg   _is_directoryrH   r8   r   )r   rb   r   r)   s       r   findzResourceFinder.find   s\    }-zz$F  !!$'*4?!$6FKr   c                 .    t        |j                  d      S Nrb)r%   r   ri   s     r   r:   zResourceFinder.get_stream   s    HMM4((r   c                 z    t        |j                  d      5 }|j                         cd d d        S # 1 sw Y   y xY wrn   )r%   r   read)r   r   r+   s      r   rA   zResourceFinder.get_bytes   s0    (--& 	!668	 	 	s   1:c                 T    t         j                  j                  |j                        S r-   )r   r   getsizeri   s     r   rC   zResourceFinder.get_size   s    wwx}}--r   c                       fd}t        t        j                  |j                        D cg c]  } ||      s| c}      S c c}w )Nc                 J    | dk7  xr | j                  j                         S )N__pycache__)endswithskipped_extensions)r+   r   s    r   allowedz-ResourceFinder.get_resources.<locals>.allowed   s,    & 8JJt667,8 9r   )setr   listdirr   )r   r   ry   r+   s   `   r   rJ   zResourceFinder.get_resources   s6    	9 rzz(--8G!GAJAGHHGs
   AAc                 8    | j                  |j                        S r-   )rk   r   ri   s     r   rF   zResourceFinder.is_container   s    !!(--00r   c              #   X  K   | j                  |      }||g}|r|j                  d      }| |j                  rh|j                  }|j                  D ]M  }|s|}ndj                  ||g      }| j                  |      }|j                  r|j                  |       J| O |ry y y w)Nr   r^   )rl   poprF   r6   rK   r   append)r   rb   r   todornamer6   new_namechilds           r   iteratorzResourceFinder.iterator   s     99]+:D88A;(($MME ( 2 2 	($'+H'*xx'>H $		( 3 -- KK."'K	(   s   B$B*'B*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   sy     ||v&7-E
&
)$#
).I1 !/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                 F   t         t        |   |       | j                  j                  }dt        |      z   | _        t        | j                  d      r| j                  j                  | _        nt        j                  |   | _        t        | j                        | _        y )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__   ss    /7++%%c'l*4;;)++,,DK#88ADKDKK(
r   c                     |S r-   r   rZ   s     r   r[   zZipResourceFinder._adjust_path   s    r   c                    || j                   d  }|| j                  v rd}nj|r)|d   t        j                  k7  r|t        j                  z   }t	        j                  | j
                  |      }	 | j
                  |   j                  |      }|s-t        j                  d|| j                  j                         |S t        j                  d|| j                  j                         |S # t        $ r d}Y iw xY w)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    DOO$%4;;FRBFF*bff}djj$/AA11$7 LL.dkk6H6HI  LL.dkk6H6HI  s   -C' 'C54C5c                 l    | 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   s4    $$}}QV_-.t|r   c                 L    | j                   j                  |j                        S r-   )rW   get_datar   ri   s     r   rA   zZipResourceFinder.get_bytes   s    {{##HMM22r   c                 J    t        j                  | j                  |            S r-   )ioBytesIOrA   ri   s     r   r:   zZipResourceFinder.get_stream   s    zz$..233r   c                 X    |j                   | j                  d  }| j                  |   d   S )N   )r   r   r   r   s      r   rC   zZipResourceFinder.get_size   s+    }}T__-.{{4 ##r   c                 .   |j                   | j                  d  }|r)|d   t        j                  k7  r|t        j                  z  }t	        |      }t               }t        j                  | j                  |      }|t	        | j                        k  r| j                  |   j                  |      s	 |S | j                  |   |d  }|j                  |j                  t        j                  d      d          |dz  }|t	        | j                        k  r|S )Nr   r   r   )r   r   r   rc   r   rz   r   r   r   addr`   )r   r   r   plenr)   r   ss          r   rJ   zZipResourceFinder.get_resources  s    }}T__-.DH&BFFND4yMM$**d+#djj/!::a=++D1  

1de$AJJqwwrvvq)!,-FA #djj/! r   c                    || j                   d  }|r)|d   t        j                  k7  r|t        j                  z  }t        j                  | j                  |      }	 | j                  |   j                  |      }|S # t        $ r d}Y |S w xY w)Nr   F)r   r   rc   r   r   r   r   )r   r   r   r)   s       r   rk   zZipResourceFinder._is_directory  s    DOO$%DH&BFFNDMM$**d+	ZZ]--d3F   	F	s   A< <B
B)r.   r/   r0   rE   r   r[   rg   r   rA   r:   rC   rJ   rk   r1   r2   s   @r   r   r      s5    	)$
34$	r   r   c                 (    |t         t        |       <   y r-   )_finder_registrytype)rW   finder_makers     r   register_finderr   2  s    %1T&\"r   c                 X   | t         v rt         |    }|S | t        j                  vrt        |        t        j                  |    }t	        |dd      }|t        d      t	        |dd      }t        j                  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' M #++%wW%vz40<" $8 9 9t4'++DL9"#Cg#MNNf%!'gMr   	__dummy__c                 &   d}t        j                  |        t        j                  j	                  |       }t
        j	                  t        |            }|r:t        }t        j                  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  su     F$$((.F!!$v,/F'',,tR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      sR   (  	  	  
    8 8			8	$ 	)E )X6 *| *B/ /W(V W(tK K^ 	J, 
	(0 .<S))*'5S^^$1?S--.
2 2 !  [!12]  ('( 	^$ 		s0   %C; ).D
 ;	DD
 DD
 
DD