
    $wLfj                     X    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
dS )
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dS )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                            t           j                            d          d          S )zReturns rc file path.~z.pypirc)ospathjoin
expanduserselfs    <lib/python3.11/site-packages/setuptools/_distutils/config.py_get_rc_filezPyPIRCCommand._get_rc_file'   s(    w||BG..s33Y???    c                 &   |                                  }t          j        |t          j        t          j        z  d          }t          j        |dd          5 }|                    t          ||fz             ddd           dS # 1 swxY w Y   dS )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+   s      gb"*r{2E::YsC'222 	;aGGNh%99:::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;s    BB
B
c                    |                                  }t          j                            |          r|                     d|z             | j        p| j        }t                      }|                    |d           |	                                }d|v r|
                    dd          }d |                    d          D             }|g k    r
d|v rdg}ni S |D ]}d	|i}|
                    |d
          |d
<   d| j        fd| j        fdfD ]:\  }	}
|                    ||	          r|
                    ||	          ||	<   5|
||	<   ;|dk    r|| j        dfv r| j        |d<   |c S |d	         |k    s|d         |k    r|c S nod|v rkd}|                    |d          r|
                    |d          }n| j        }|
                    |d
          |
                    |d          ||| j        dS i S )zReads the .pypirc file.zUsing PyPI login from %sr   r   	distutilszindex-serversc                 f    g | ].}|                                 d k    |                                 /S ) )strip).0servers     r   
<listcomp>z.PyPIRCCommand._read_pypirc.<locals>.<listcomp>?   s=       ||~~++ LLNN+++r   
r   r-   r!   
repositoryrealm)r"   Nzserver-loginr"   )r!   r"   r0   r-   r1   )r   r   r   existsannouncer0   DEFAULT_REPOSITORYr   readsectionsgetsplitDEFAULT_REALM
has_option)r   r#   r0   configr6   index_servers_serversr-   currentkeydefaults              r   _read_pypirczPyPIRCCommand._read_pypirc2   s     7>>" B	MM4r9:::CD,CJ$&&FKKWK---((Hh&& &

; H H "/"5"5d";";  
 r>>))$*8  "	& ' 'F'0G*0**VZ*H*HGJ' &t'>? $"45*) 3 3W
 ",,VS99 3+1::fc+B+BGCLL+2GCLL
 ''J/; - - 150G-&  )Z77"<0J>>& ?7'<  8++'$$V\:: 9!'FL!A!AJJ!%!8J &

6: > > &

6: > >",$!/   	r   c                     |                     dd          }|                                                    t          |                    S )z%Read and decode a PyPI HTTP response.content-typez
text/plain)	getheaderr5   decode_extract_encoding)r   responsecontent_types      r   _read_pypi_responsez!PyPIRCCommand._read_pypi_response{   s<    )).,GG}}%%&7&E&EFFFr   c                 0    d| _         d| _        d| _        dS )zInitialize options.Nr   )r0   r1   show_responser   s    r   initialize_optionsz PyPIRCCommand.initialize_options   s    
r   c                 V    | j         | j        | _         | j        | j        | _        dS dS )zFinalizes options.N)r0   r4   r1   r9   r   s    r   finalize_optionszPyPIRCCommand.finalize_options   s2    ?""5DO:+DJJJ r   )__name__
__module____qualname____doc__r4   r9   r0   r1   user_optionsboolean_optionsr   r&   rA   rI   rL   rN    r   r   r   r      s        @@:MJE 
>ASSTIL
 ''O@ @ @; ; ;G G GRG G G
  , , , , ,r   r   c                     t           j                                        }| |d<   |d         j                            dd          S )z{
    >>> _extract_encoding('text/plain')
    'ascii'
    >>> _extract_encoding('text/html; charset="utf8"')
    'utf8'
    rC   charsetascii)emailmessageEmailMessageparamsr7   )rH   msgs     r   rF   rF      s?     -
$
$
&
&C&C~%)))W===r   )rR   email.messagerY   r   configparserr   cmdr   r    r   rF   rU   r   r   <module>ra      s         				 ( ( ( ( ( (      s, s, s, s, s,G s, s, s,l	> 	> 	> 	> 	>r   