509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3

  \  ã               @   s<   d Z ddlZddlmZ ddlmZ dZG dd„ deƒZdS )z�distutils.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               @   sh   e Zd ZdZdZdZdZdZddde fdgZdgZ	d
d„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚPyPIRCCommandz;Base command that knows how to handle the .pypirc file
    zhttps://upload.pypi.org/legacy/ÚpypiNzrepository=Úrzurl of repository [default: %s]úshow-responseú&display full response text from serverc             C   s   t jjt jjdƒdƒS )zReturns rc file path.ú~z.pypirc)ÚosÚpathÚjoinÚ
expanduser)Úself© r   ú(/usr/lib64/python3.6/distutils/config.pyÚ_get_rc_file&   s    zPyPIRCCommand._get_rc_filec             C   sH   | j ƒ }tjtj|tjtjB dƒdƒ�}|jt||f ƒ W dQ R X dS )zCreates a default .pypirc file.i€  ÚwN)r   r
   ÚfdopenÚopenÚO_CREATÚO_WRONLYÚwriteÚDEFAULT_PYPIRC)r   ÚusernameÚpasswordÚrcÚfr   r   r   Ú_store_pypirc*   s     zPyPIRCCommand._store_pypircc             C   s¨  | j ƒ }tjj|ƒ�r¤| jd| ƒ | jp.| j}| jp:| j}t	ƒ }|j
|ƒ |jƒ }d|k�rR|jddƒ}dd„ |jdƒD ƒ}|g kršd|kr–dg}ni S x´|D ]¬}d|i}	|j|d	ƒ|	d	< xHd
| jfd| jfdfD ].\}
}|j||
ƒrú|j||
ƒ|	|
< qÔ||	|
< qÔW |dk�r.|| jdfk�r.| j|	d
< |	S |	d |k�sH|	d
 |kr |	S q W nRd|k�r¤d}|j|d
ƒ�r||j|d
ƒ}n| j}|j|d	ƒ|j|dƒ||| jdœS i S )zReads the .pypirc file.zUsing PyPI login from %sZ	distutilszindex-serversc             S   s    g | ]}|j ƒ d kr|j ƒ ‘qS )Ú )Ústrip)Ú.0Úserverr   r   r   ú
<listcomp>>   s    z.PyPIRCCommand._read_pypirc.<locals>.<listcomp>Ú
r   r!   r   Ú
repositoryÚrealmr   Nzserver-login)r   r   r$   r!   r%   )r   N)r   r
   r   ÚexistsZannouncer$   ÚDEFAULT_REPOSITORYr%   ÚDEFAULT_REALMr   ÚreadÚsectionsÚgetÚsplitZ
has_option)r   r   r$   r%   Úconfigr*   Zindex_serversZ_serversr!   ZcurrentÚkeyÚdefaultr   r   r   Ú_read_pypirc0   sX    









zPyPIRCCommand._read_pypircc             C   s8   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/plainé   ÚcharsetÚascii)ÚcgiZ	getheaderZparse_headerr+   r)   Údecode)r   Zresponser4   Zcontent_typeÚencodingr   r   r   Ú_read_pypi_responseq   s    z!PyPIRCCommand._read_pypi_responsec             C   s   d| _ d| _d| _dS )zInitialize options.Nr   )r$   r%   Zshow_response)r   r   r   r   Úinitialize_optionsx   s    z PyPIRCCommand.initialize_optionsc             C   s(   | j dkr| j| _ | jdkr$| j| _dS )zFinalizes options.N)r$   r'   r%   r(   )r   r   r   r   Úfinalize_options~   s    

zPyPIRCCommand.finalize_options)r   Nr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r'   r(   r$   r%   Zuser_optionsZboolean_optionsr   r   r0   r7   r8   r9   r   r   r   r   r      s"    Ar   )r=   r
   Zconfigparserr   Zdistutils.cmdr   r   r   r   r   r   r   Ú<module>   s
   
