
    q"h=Q                         S SK r S SKrS SKrS SKrS SKrS SKr S SKJr  SSK
Jr  SSKJrJrJrJrJrJr  SSKJrJr  \R,                  " \5      rSrSr " S	 S
\5      rg! \ a	    S SK	Jr   NNf = f)    N)Thread   )DistlibException)HTTPBasicAuthHandlerRequestHTTPPasswordMgrurlparsebuild_openerstring_types)zip_dirServerProxyzhttps://pypi.org/pypipypic                       \ rS rSrSrSrSS jrS rS rS r	S	 r
S
 rS rSS jrSS jrSS jr  SS jrS r SS jr SS jrSS jrS rS rSS jrSrg)PackageIndex   zW
This class represents a package index compatible with PyPI, the Python
Package Index.
s.   ----------ThIs_Is_tHe_distlib_index_bouNdaRY_$Nc                    U=(       d    [         U l        U R                  5         [        U R                  5      u  p#pEpgU(       d  U(       d  U(       d  US;  a  [	        SU R                  -  5      eSU l        SU l        SU l        SU l        [        [        R                  S5       nS H*  n	 [        R                  " U	S/UUS9n
U
S:X  a  Xl          OM,     SSS5        g! [         a     MD  f = f! , (       d  f       g= f)	zt
Initialise an instance.

:param url: The URL of the index. If not specified, the URL for PyPI is
            used.
)httphttpszinvalid repository: %sNw)gpggpg2z	--versionstdoutstderrr   )DEFAULT_INDEXurlread_configurationr	   r   password_handlerssl_verifierr   gpg_homeopenosdevnull
subprocess
check_callOSError)selfr   schemenetlocpathparamsqueryfragsinksrcs              K/var/www/html/env/lib/python3.13/site-packages/pip/_vendor/distlib/index.py__init__PackageIndex.__init__%   s     '-!4<TXX4F1eUdf4E&E"#;dhh#FGG $ "**c"d %#..;/?6:<BQw#$ 	 % #"   #"s0   'C2.$C!C2!
C/+C2.C//C22
D c                     SSK Jn  U" 5       $ )z[
Get the distutils command for interacting with PyPI configurations.
:return: the command.
r   )_get_pypirc_command)utilr5   )r'   cmds     r1   r5    PackageIndex._get_pypirc_commandB   s    
 	5u    c                     SSK Jn  U" U 5      nUR                  S5      U l        UR                  S5      U l        UR                  SS5      U l        UR                  SU R                  5      U l        g)	z
Read the PyPI access configuration as supported by distutils. This populates
``username``, ``password``, ``realm`` and ``url`` attributes from the
configuration.
r   )_load_pypircusernamepasswordrealmr   
repositoryN)r6   r;   getr<   r=   r>   r   )r'   r;   cfgs      r1   r   PackageIndex.read_configurationJ   sY     	'4 
+
+WWWf-
77<2r9   c                 @    U R                  5         SSKJn  U" U 5        g)z|
Save the PyPI access configuration. You must have set ``username`` and
``password`` attributes before calling this method.
r   )_store_pypircN)check_credentialsr6   rD   )r'   rD   s     r1   save_configurationPackageIndex.save_configurationW   s    
 	 'dr9   c                    U R                   b  U R                  c  [        S5      e[        5       n[	        U R
                  5      u  p#      nUR                  U R                  X0R                   U R                  5        [        U5      U l	        g)zX
Check that ``username`` and ``password`` have been set, and raise an
exception if not.
Nz!username and password must be set)
r<   r=   r   r   r	   r   add_passwordr>   r   r   )r'   pm_r)   s       r1   rE   PackageIndex.check_credentials`   sm    
 == DMM$9"#FGG ( 21aA


FMM4==I 4R 8r9   c                 :   U R                  5         UR                  5         UR                  5       nSUS'   U R                  UR	                  5       / 5      nU R                  U5        SUS'   U R                  UR	                  5       / 5      nU R                  U5      $ )a9  
Register a distribution on PyPI, using the provided metadata.

:param metadata: A :class:`Metadata` instance defining at least a name
                 and version number for the distribution to be
                 registered.
:return: The HTTP response received from PyPI upon submission of the
        request.
verify:actionsubmit)rE   validatetodictencode_requestitemssend_request)r'   metadatadrequests       r1   registerPackageIndex.registerl   s     	 OO)%%aggi4'")%%aggi4  ))r9   c                      UR                  5       nU(       d  ONUR                  S5      R                  5       nUR                  U5        [        R                  U< SU< 35        Mf  UR                  5         g)aB  
Thread runner for reading lines of from a subprocess into a buffer.

:param name: The logical name of the stream (used for logging only).
:param stream: The stream to read from. This will typically a pipe
               connected to the output stream of a subprocess.
:param outbuf: The list to append the read lines to.
utf-8z: N)readlinedecoderstripappendloggerdebugclose)r'   namestreamoutbufr/   s        r1   _readerPackageIndex._reader   s]     !A!((*AMM!LLT1-.  	r9   c           	         U R                   SSS/nUc  U R                  nU(       a  UR                  SU/5        Ub  UR                  / SQ5        [        R                  " 5       n[
        R                  R                  U[
        R                  R                  U5      S-   5      nUR                  SSS	US
Xq/5        [        R                  SSR                  U5      5        XW4$ )a1  
Return a suitable command for signing a file.

:param filename: The pathname to the file to be signed.
:param signer: The identifier of the signer of the file.
:param sign_password: The passphrase for the signer's
                      private key used for signing.
:param keystore: The path to a directory which contains the keys
                 used in verification. If not specified, the
                 instance's ``gpg_home`` attribute is used instead.
:return: The signing command as a list suitable to be
         passed to :class:`subprocess.Popen`.
--status-fd2--no-tty	--homedir)z--batchz--passphrase-fd0z.ascz--detach-signz--armorz--local-userz--outputinvoking: %s )r   r    extendtempfilemkdtempr"   r*   joinbasenamera   rb   )r'   filenamesignersign_passwordkeystorer7   tdsfs           r1   get_sign_commandPackageIndex.get_sign_command   s     xxZ8}}HJJX./$JJ:;WW\\"bgg..x86AB

OYJ6 	7^SXXc]3wr9   c                 V   [         R                  [         R                  S.nUb  [         R                  US'   / n/ n[         R                  " U40 UD6n[        U R                  SUR
                  U4S9nUR                  5         [        U R                  SUR                  U4S9nUR                  5         Ub5  UR                  R                  U5        UR                  R                  5         UR                  5         UR                  5         UR                  5         UR                  XE4$ )a  
Run a command in a child process , passing it any input data specified.

:param cmd: The command to run.
:param input_data: If specified, this must be a byte string containing
                   data to be sent to the child process.
:return: A tuple consisting of the subprocess' exit code, a list of
         lines read from the subprocess' ``stdout``, and a list of
         lines read from the subprocess' ``stderr``.
r   stdinr   )targetargsr   )r$   PIPEPopenr   rg   r   startr   r   writerc   waitrt   
returncode)	r'   r7   
input_datakwargsr   r   pt1t2s	            r1   run_commandPackageIndex.run_command   s     !oo oo
 !(ooF7OS+F+ 4<<x6.JK

4<<x6.JK

!GGMM*%GGMMO	
	
	||V++r9   c                     U R                  XUU5      u  pVU R                  UUR                  S5      5      u  pxn	US:w  a  [        SU-  5      eU$ )a  
Sign a file.

:param filename: The pathname to the file to be signed.
:param signer: The identifier of the signer of the file.
:param sign_password: The passphrase for the signer's
                      private key used for signing.
:param keystore: The path to a directory which contains the keys
                 used in signing. If not specified, the instance's
                 ``gpg_home`` attribute is used instead.
:return: The absolute pathname of the file where the signature is
         stored.
r\   r   z&sign command failed with error code %s)r|   r   encoder   )
r'   rv   rw   rx   ry   r7   sig_filer0   r   r   s
             r1   	sign_filePackageIndex.sign_file   si     --h.68!--c.;.B.B7.KMF7" $-/1$2 3 3r9   c           	      d   U R                  5         [        R                  R                  U5      (       d  [	        SU-  5      eUR                  5         UR                  5       nSn	U(       a:  U R                  (       d  [        R                  S5        OU R                  X#UU5      n	[        US5       n
U
R                  5       nSSS5        [        R                  " W5      R                  5       n[        R                   " U5      R                  5       nUR#                  SSUUUUS.5        S[        R                  R%                  U5      U4/nU	(       a  [        U	S5       n
U
R                  5       nSSS5        UR'                  S	[        R                  R%                  U	5      W45        [(        R*                  " [        R                  R-                  U	5      5        U R/                  UR1                  5       U5      nU R3                  U5      $ ! , (       d  f       GNS= f! , (       d  f       N= f)
a  
Upload a release file to the index.

:param metadata: A :class:`Metadata` instance defining at least a name
                 and version number for the file to be uploaded.
:param filename: The pathname of the file to be uploaded.
:param signer: The identifier of the signer of the file.
:param sign_password: The passphrase for the signer's
                      private key used for signing.
:param filetype: The type of the file being uploaded. This is the
                distutils command which produced that file, e.g.
                ``sdist`` or ``bdist_wheel``.
:param pyversion: The version of Python which the release relates
                  to. For code compatible with any Python, this would
                  be ``source``, otherwise it would be e.g. ``3.2``.
:param keystore: The path to a directory which contains the keys
                 used in signing. If not specified, the instance's
                 ``gpg_home`` attribute is used instead.
:return: The HTTP response received from PyPI upon submission of the
        request.
znot found: %sNz)no signing program available - not signedrbfile_upload1)rO   protocol_versionfiletype	pyversion
md5_digestsha256_digestcontentgpg_signature)rE   r"   r*   existsr   rQ   rR   r   ra   warningr   r!   readhashlibmd5	hexdigestsha256updateru   r`   shutilrmtreedirnamerS   rT   rU   )r'   rV   rv   rw   rx   r   r   ry   rW   r   f	file_datar   r   filessig_datarX   s                    r1   upload_filePackageIndex.upload_file   s   . 	 ww~~h''"?X#=>>OO88JK>>(M*24(D!QI "[[+557
y1;;=	$ # "$*
 	 RWW--h7CDh%668 &LL/277+;+;H+E!# $MM"''//(34%%aggi7  ))) "! &%s   2H!H!
H!
H/c                 
   U R                  5         [        R                  R                  U5      (       d  [	        SU-  5      e[        R                  R                  US5      n[        R                  R                  U5      (       d  [	        SU-  5      eUR                  5         UR                  UR                  pT[        U5      R                  5       nSSU4SU4/nSXF4/nU R                  Xx5      n	U R                  U	5      $ )a  
Upload documentation to the index.

:param metadata: A :class:`Metadata` instance defining at least a name
                 and version number for the documentation to be
                 uploaded.
:param doc_dir: The pathname of the directory which contains the
                documentation. This should be the directory that
                contains the ``index.html`` for the documentation.
:return: The HTTP response received from PyPI upon submission of the
        request.
znot a directory: %rz
index.htmlznot found: %r)rO   
doc_uploadrd   versionr   )rE   r"   r*   isdirr   rt   r   rQ   rd   r   r   getvaluerS   rU   )
r'   rV   doc_dirfnrd   r   zip_datafieldsr   rX   s
             r1   upload_documentation!PackageIndex.upload_documentation!  s     	 ww}}W%%"#87#BCCWW\\'<0ww~~b!!"?R#788 x'7'7g7#,,.+4.9g"68T,-%%f4  ))r9   c                     U R                   SSS/nUc  U R                  nU(       a  UR                  SU/5        UR                  SX/5        [        R	                  SSR                  U5      5        U$ )a$  
Return a suitable command for verifying a file.

:param signature_filename: The pathname to the file containing the
                           signature.
:param data_filename: The pathname to the file containing the
                      signed data.
:param keystore: The path to a directory which contains the keys
                 used in verification. If not specified, the
                 instance's ``gpg_home`` attribute is used instead.
:return: The verifying command as a list suitable to be
         passed to :class:`subprocess.Popen`.
rj   rk   rl   rm   z--verifyro   rp   )r   r    rq   ra   rb   rt   )r'   signature_filenamedata_filenamery   r7   s        r1   get_verify_commandPackageIndex.get_verify_command=  sf     xxZ8}}HJJX./

J 2BC^SXXc]3
r9   c                     U R                   (       d  [        S5      eU R                  XU5      nU R                  U5      u  pVnUS;  a  [        SU-  5      eUS:H  $ )a  
Verify a signature for a file.

:param signature_filename: The pathname to the file containing the
                           signature.
:param data_filename: The pathname to the file containing the
                      signed data.
:param keystore: The path to a directory which contains the keys
                 used in verification. If not specified, the
                 instance's ``gpg_home`` attribute is used instead.
:return: True if the signature was verified, else False.
z0verification unavailable because gpg unavailable)r   r   z(verify command failed with error code %sr   )r   r   r   r   )r'   r   r   ry   r7   r0   r   r   s           r1   verify_signaturePackageIndex.verify_signatureU  sk     xx" $1 2 2%%&8&.0!--c2FV"#MPR#RSSQwr9   c           	         Uc  Sn[         R                  S5        OO[        U[        [        45      (       a  Uu  pcOSn[        [        U5      " 5       n[         R                  SU-  5        [        US5       nU R                  [        U5      5      n UR                  5       n	Sn
SnSnSnS	U	;   a  [        U	S
   5      nU(       a	  U" XU5         UR                  U
5      nU(       d  ONU[        U5      -  nUR                  U5        U(       a  UR                  U5        US-  nU(       a	  U" XU5        Mg  UR!                  5          SSS5        WS:  a  WU:  a  [#        SX4-  5      eU(       aF  UR%                  5       nX?:w  a  [#        W< SU< SU< SU< 35      e[         R                  SU5        gg! UR!                  5         f = f! , (       d  f       N= f)a  
This is a convenience method for downloading a file from an URL.
Normally, this will be a file from the index, though currently
no check is made for this (i.e. a file can be downloaded from
anywhere).

The method is just like the :func:`urlretrieve` function in the
standard library, except that it allows digest computation to be
done during download and checking that the downloaded data
matched any expected value.

:param url: The URL of the file to be downloaded (assumed to be
            available via an HTTP GET request).
:param destfile: The pathname where the downloaded file is to be
                 saved.
:param digest: If specified, this must be a (hasher, value)
               tuple, where hasher is the algorithm used (e.g.
               ``'md5'``) and ``value`` is the expected value.
:param reporthook: The same as for :func:`urlretrieve` in the
                   standard library.
NzNo digest specifiedr   zDigest specified: %swbi    r   zcontent-lengthzContent-Lengthr   z1retrieval incomplete: got only %d out of %d bytesz digest mismatch for z: expected z, got zDigest verified: %s)ra   rb   
isinstancelisttuplegetattrr   r!   rU   r   infointr   lenr   r   rc   r   r   )r'   r   destfiledigest
reporthookdigesterhasherdfpsfpheaders	blocksizesizer   blocknumblockactuals                   r1   download_filePackageIndex.download_filem  s   , >HLL./&4-00!'w/1HLL/&89 (D!S ##GCL1C((* 	#w.w'789DxD9HHY/E CJ&DIIe$ .MH!"8=  		5 ": 19"C,    '')F&7=x7=v(G H H LL.7  		5 "!s%   7GB$F97G9GG
Gc                     / nU R                   (       a  UR                  U R                   5        U R                  (       a  UR                  U R                  5        [        U6 nUR	                  U5      $ )z
Send a standard library :class:`Request` to PyPI and return its
response.

:param req: The request to send.
:return: The HTTP response from PyPI (a standard library HTTPResponse).
)r   r`   r   r
   r!   )r'   reqhandlersopeners       r1   rU   PackageIndex.send_request  sX       OOD112OOD--.x({{3r9   c           
      $   / nU R                   nU He  u  pV[        U[        [        45      (       d  U/nU H<  nUR	                  SU-   SU-  R                  S5      SUR                  S5      45        M>     Mg     U H6  u  pn
UR	                  SU-   SU< SU	< S3R                  S5      SU
45        M8     UR	                  SU-   S-   S45        SR                  U5      nS	U-   nU[        [        U5      5      S
.n[        U R                  X5      $ )z
Encode fields and files for posting to an HTTP server.

:param fields: The fields to send as a list of (fieldname, value)
               tuples.
:param files: The files to send as a list of (fieldname, filename,
              file_bytes) tuple.
s   --z)Content-Disposition: form-data; name="%s"r\   r9   z&Content-Disposition: form-data; name="z"; filename=""s   
s   multipart/form-data; boundary=)zContent-typezContent-length)boundaryr   r   r   rq   r   rt   strr   r   r   )r'   r   r   partsr   kvaluesvkeyrv   valuebodyctr   s                 r1   rS   PackageIndex.encode_request  s    ==IAftUm44 H$@wHHW%' ( 	   %* C5LL x!"(&/  %* 	eh&.45||E".9!#d)n
 txx//r9   c                     [        U[        5      (       a  SU0n[        U R                  SS9n UR	                  X=(       d    S5      U" S5      " 5         $ ! U" S5      " 5         f = f)Nrd   g      @)timeoutandrc   )r   r   r   r   search)r'   termsoperator	rpc_proxys       r1   r   PackageIndex.search  sW    e\**UOE#6		!##E+<u=g Ig s   A A%)r   r    r=   r   r>   r   r   r<   )N)NNsdistsourceN)NN)__name__
__module____qualname____firstlineno____doc__r   r2   r5   r   rF   rE   rY   rg   r|   r   r   r   r   r   r   r   rU   rS   r   __static_attributes__ r9   r1   r   r      s    
 AH:3
9*($8!,F. JNCG7*r*: %)2 #'0K8Z  )0V!r9   r   )r   loggingr"   r   r$   rr   	threadingr   ImportErrordummy_threading r   compatr   r   r   r	   r
   r   r6   r   r   	getLoggerr   ra   r   DEFAULT_REALMobjectr   r   r9   r1   <module>r     so      	   '  ; ; &			8	$'_!6 _!  '&'s   A   A/.A/