
    wffj                     P    d Z ddlZddlZddlmZ ddlmZ dZ G d de      Z	d	 Z
y)
zdistutils.pypirc

Provides the PyPIRCCommand class, the base class for the command classes
that uses .pypirc in the distutils.command package.
    N)RawConfigParser   )CommandzE[distutils]
index-servers =
    pypi

[pypi]
username:%s
password:%s
c                   ^    e Zd ZdZdZdZdZdZdddez  fdgZd	gZ	d
 Z
d Zd Zd Zd Zd Zy)PyPIRCCommandz6Base command that knows how to handle the .pypirc filezhttps://upload.pypi.org/legacy/pypiNzrepository=rzurl of repository [default: %s])show-responseNz&display full response text from serverr
   c                 |    t         j                  j                  t         j                  j                  d      d      S )zReturns rc file path.~z.pypirc)ospathjoin
expanduserselfs    UC:\xampp-8.1.2\htdocs\client\python\Lib\site-packages\setuptools/_distutils/config.py_get_rc_filezPyPIRCCommand._get_rc_file'   s&    ww||BGG..s3Y??    c                    | j                         }t        j                  |t        j                  t        j                  z  d      }t        j
                  |dd      5 }|j                  t        ||fz         ddd       y# 1 sw Y   yxY w)zCreates a default .pypirc file.i  wutf-8encodingN)r   r   openO_CREATO_WRONLYfdopenwriteDEFAULT_PYPIRC)r   usernamepasswordrcrawfs         r   _store_pypirczPyPIRCCommand._store_pypirc+   sl     ggb"**r{{2E:YYsC'2 	;aGGNh%99:	; 	; 	;s   BBc                 "   | j                         }t        j                  j                  |      r| j	                  d|z         | j
                  xs | j                  }t               }|j                  |d       |j                         }d|v r|j                  dd      }|j                  d      D cg c]%  }|j                         dk7  r|j                         ' }}|g k(  r
d|v rdg}ni S |D ]  }d	|i}|j                  |d
      |d
<   d| j                  fd| j                  fdfD ]2  \  }	}
|j                  ||	      r|j                  ||	      ||	<   .|
||	<   4 |dk(  r#|| j                  dfv r| j                  |d<   |c S |d	   |k(  s	|d   |k(  s|c S  i S d|v red}|j                  |d      r|j                  |d      }n| j                  }|j                  |d
      |j                  |d      ||| j                  dS i S c c}w )zReads the .pypirc file.zUsing PyPI login from %sr   r   	distutilszindex-servers
 r   serverr!   
repositoryrealm)r"   Nzserver-loginr"   )r!   r"   r,   r+   r-   )r   r   r   existsannouncer,   DEFAULT_REPOSITORYr   readsectionsgetsplitstripDEFAULT_REALM
has_option)r   r#   r,   configr2   index_serversr+   _serverscurrentkeydefaults              r   _read_pypirczPyPIRCCommand._read_pypirc2   sP    77>>"MM4r9:CD,C,CJ$&FKKWK-(Hh& &

; H #0"5"5d";||~+ LLN 
 r>)$*8  "	& 'F'0G*0**VZ*HGJ' &t'>'>? $"4"45*) 3W
 ",,VS9+1::fc+BGCL+2GCL3 'J//; - 150G0G-&  )Z7"<0J>&;'Z 	  8+'$$V\:!'FL!AJ!%!8!8J &

6: > &

6: >",$!//  	us   6*Hc                 v    |j                  dd      }|j                         j                  t        |            S )z%Read and decode a PyPI HTTP response.content-typez
text/plain)	getheaderr1   decode_extract_encoding)r   responsecontent_types      r   _read_pypi_responsez!PyPIRCCommand._read_pypi_response{   s1    )).,G}}%%&7&EFFr   c                 .    d| _         d| _        d| _        y)zInitialize options.Nr   )r,   r-   show_responser   s    r   initialize_optionsz PyPIRCCommand.initialize_options   s    
r   c                 z    | j                   | j                  | _         | j                  | j                  | _        yy)zFinalizes options.N)r,   r0   r-   r6   r   s    r   finalize_optionszPyPIRCCommand.finalize_options   s5    ??""55DO::++DJ r   )__name__
__module____qualname____doc__r0   r6   r,   r-   user_optionsboolean_optionsr   r&   r>   rF   rI   rK    r   r   r   r      sc    @:MJE 
>ASSTIL
 ''O@;GRG
,r   r   c                     t         j                  j                         }| |d<   |d   j                  j	                  dd      S )z{
    >>> _extract_encoding('text/plain')
    'ascii'
    >>> _extract_encoding('text/html; charset="utf8"')
    'utf8'
    r@   charsetascii)emailmessageEmailMessageparamsr3   )rE   msgs     r   rC   rC      s>     --
$
$
&C&C~%%)))W==r   )rO   email.messagerV   r   configparserr   cmdr   r    r   rC   rR   r   r   <module>r^      s3     	 ( s,G s,l	>r   