3 \ã@s<dZddlZddlmZddlmZdZGdd„deƒZdS)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@sheZdZdZdZdZdZdZdddefdgZdgZ d d „Z d d „Z dd„Z dd„Z dd„Zdd„ZdS)Ú PyPIRCCommandz;Base command that knows how to handle the .pypirc file zhttps://upload.pypi.org/legacy/ÚpypiNz repository=Úrzurl of repository [default: %s]ú show-responseú&display full response text from servercCstjjtjjdƒdƒS)zReturns rc file path.ú~z.pypirc)ÚosÚpathÚjoinÚ expanduser)Úself©rú(/usr/lib64/python3.6/distutils/config.pyÚ _get_rc_file&szPyPIRCCommand._get_rc_filec CsH|jƒ}tjtj|tjtjBdƒdƒ�}|jt||fƒWdQRXdS)zCreates a default .pypirc file.i€ÚwN)rr ÚfdopenÚopenÚO_CREATÚO_WRONLYÚwriteÚDEFAULT_PYPIRC)rÚusernameÚpasswordÚrcÚfrrrÚ _store_pypirc*s zPyPIRCCommand._store_pypircc Cs¨|jƒ}tjj|ƒ�r¤|jd|ƒ|jp.|j}|jp:|j}t ƒ}|j |ƒ|j ƒ}d|k�rR|j ddƒ}dd„|j dƒDƒ}|gkršd|kr–dg}niSx´|D]¬}d|i} |j |d ƒ| d <xHd |jfd |jfdfD].\} } |j|| ƒrú|j || ƒ| | <qÔ| | | <qÔW|dk�r.||jdfk�r.|j| d <| S| d|k�sH| d |kr | Sq WnRd|k�r¤d}|j|d ƒ�r||j |d ƒ}n|j}|j |d ƒ|j |d ƒ|||jdœSiS)zReads the .pypirc file.zUsing PyPI login from %sZ distutilsz index-serverscSs g|]}|jƒdkr|jƒ‘qS)Ú)Ústrip)Ú.0Úserverrrrú >sz.PyPIRCCommand._read_pypirc..Ú rr!rÚ repositoryÚrealmrNz server-login)rrr$r!r%)rN)rr r ÚexistsZannouncer$ÚDEFAULT_REPOSITORYr%Ú DEFAULT_REALMrÚreadÚsectionsÚgetÚsplitZ has_option) rrr$r%Úconfigr*Z index_serversZ_serversr!ZcurrentÚkeyÚdefaultrrrÚ _read_pypirc0sX                zPyPIRCCommand._read_pypirccCs8ddl}|jddƒ}|j|ƒdjddƒ}|jƒj|ƒS)z%Read and decode a PyPI HTTP response.rNz content-typez text/plainéÚcharsetÚascii)ÚcgiZ getheaderZ parse_headerr+r)Údecode)rZresponser4Z content_typeÚencodingrrrÚ_read_pypi_responseqs z!PyPIRCCommand._read_pypi_responsecCsd|_d|_d|_dS)zInitialize options.Nr)r$r%Z show_response)rrrrÚinitialize_optionsxsz PyPIRCCommand.initialize_optionscCs(|jdkr|j|_|jdkr$|j|_dS)zFinalizes options.N)r$r'r%r()rrrrÚfinalize_options~s  zPyPIRCCommand.finalize_options)rNr)Ú__name__Ú __module__Ú __qualname__Ú__doc__r'r(r$r%Z user_optionsZboolean_optionsrrr0r7r8r9rrrrrs"Ar)r=r Z configparserrZ distutils.cmdrrrrrrrÚs