
    7fj                     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                   b    e Zd ZdZdZdZdZdZddde d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: ])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    Z/home/feoh/.local/pipx/shared/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|            | 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 r   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#   r1   r.   r2   )r   r   r   existsannouncer1   DEFAULT_REPOSITORYr   readsectionsgetsplitDEFAULT_REALM
has_option)r   r$   r1   configr7   index_servers_serversr.   currentkeydefaults              r   _read_pypirczPyPIRCCommand._read_pypirc2   s     7>>" B	MM7277888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)	getheaderr6   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.NF)r1   r2   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)r1   r5   r2   r:   r   s    r   finalize_optionszPyPIRCCommand.finalize_options   s2    ?""5DO:+DJJJ r   )__name__
__module____qualname____doc__r5   r:   r1   r2   user_optionsboolean_optionsr   r'   rB   rJ   rM   rO    r   r   r   r      s        @@:MJE 
Q<NQQQR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'
    rD   charsetascii)emailmessageEmailMessageparamsr8   )rI   msgs     r   rG   rG      s?     -
$
$
&
&C&C~%)))W===r   )rS   email.messagerZ   r   configparserr   cmdr   r!   r   rG   rV   r   r   <module>rb      s         				 ( ( ( ( ( (      s, s, s, s, s,G s, s, s,l	> 	> 	> 	> 	>r   