
    
_d/                     B    d Z ddlZddlmZ ddlmZ dZ G d de      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    >/usr/lib/python3/dist-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                  t        j
                  z  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  wN)r   r   fdopenopenO_CREATO_WRONLYwriteDEFAULT_PYPIRC)r   usernamepasswordrcfs        r   _store_pypirczPyPIRCCommand._store_pypirc)   se     YYrwwr2::#;UCSI 	;QGGNh%99:	; 	; 	;s   A??Bc                    | j                         }t        j                  j                  |      r| j	                  d|z         | j
                  xs | j                  }t               }|j                  |       |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 %s	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(   configr.   index_serversr'   _serverscurrentkeydefaults              r   _read_pypirczPyPIRCCommand._read_pypirc/   sK    77>>"MM4r9:CD,C,CJ$&FKKO(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   4*H
c                     ddl }|j                  dd      }|j                  |      d   j                  dd      }|j	                         j                  |      S )z%Read and decode a PyPI HTTP response.r   Nzcontent-typez
text/plainr   charsetascii)cgi	getheaderparse_headerr/   r-   decode)r   responser>   content_typeencodings        r   _read_pypi_responsez!PyPIRCCommand._read_pypi_responsex   sP    )).,G##L1!488GL}}%%h//r   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(   r,   r)   r2   r   s    r   finalize_optionszPyPIRCCommand.finalize_options   s5    ??""55DO::++DJ r   )__name__
__module____qualname____doc__r,   r2   r(   r)   user_optionsboolean_optionsr   r"   r:   rE   rH   rJ    r   r   r   r      sb    @:MJE 
>ASSTIL
 ''O@;GR0,r   r   )rN   r   configparserr   cmdr   r   r   rQ   r   r   <module>rT      s*   
 
 ( u,G u,r   