B ŒÛ™\Ûã@s<dZddlZddlmZddlmZdZGdd„deƒZdS)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@sheZdZdZdZdZdZdZdddefdgZd gZ 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])z show-responseNz&display full response text from serverz show-responsecCstj tj d¡d¡S)zReturns rc file path.ú~z.pypirc)ÚosÚpathÚjoinÚ expanduser)Úself©r ú&/usr/lib/python3.7/distutils/config.pyÚ _get_rc_file&szPyPIRCCommand._get_rc_filec CsH| ¡}t t |tjtjBd¡d¡}| t||f¡WdQRXdS)zCreates a default .pypirc file.i€ÚwN)rrÚfdopenÚopenÚO_CREATÚO_WRONLYÚwriteÚDEFAULT_PYPIRC)r ÚusernameÚpasswordÚrcÚfr r rÚ _store_pypirc*s zPyPIRCCommand._store_pypircc Csœ| ¡}tj |¡r˜| d|¡|jp.|j}tƒ}| |¡|  ¡}d|krF|  dd¡}dd„|  d¡Dƒ}|gkrŽd|krŠdg}niSx´|D]¬}d|i}|  |d ¡|d <xHd |jfd |j fd fD].\} } |  || ¡rî|  || ¡|| <qÈ| || <qÈW|dkr"||jdfkr"|j|d <|S|d|ks<|d |kr”|Sq”WnRd |kr˜d }|  |d ¡rp|  |d ¡}n|j}|  |d ¡|  |d¡|||j dœSiS)zReads the .pypirc file.zUsing PyPI login from %sZ distutilsz index-serverscSs g|]}| ¡dkr| ¡‘qS)Ú)Ústrip)Ú.0Úserverr r rú =sz.PyPIRCCommand._read_pypirc..Ú rrrÚ repositoryÚrealm)rNz server-loginr)rrr"rr#)rrr ÚexistsZannouncer"ÚDEFAULT_REPOSITORYrÚreadÚsectionsÚgetÚsplitÚ DEFAULT_REALMZ has_option) r rr"Zconfigr'Z index_serversZ_serversrZcurrentÚkeyÚdefaultr r rÚ _read_pypirc0sV               zPyPIRCCommand._read_pypirccCs8ddl}| dd¡}| |¡d dd¡}| ¡ |¡S)z%Read and decode a PyPI HTTP response.rNz content-typez text/plainéÚcharsetÚascii)ÚcgiZ getheaderZ parse_headerr(r&Údecode)r Zresponser1Z content_typeÚencodingr r rÚ_read_pypi_responseps z!PyPIRCCommand._read_pypi_responsecCsd|_d|_d|_dS)zInitialize options.Nr)r"r#Z show_response)r r r rÚinitialize_optionswsz PyPIRCCommand.initialize_optionscCs(|jdkr|j|_|jdkr$|j|_dS)zFinalizes options.N)r"r%r#r*)r r r rÚfinalize_options}s  zPyPIRCCommand.finalize_options)Ú__name__Ú __module__Ú __qualname__Ú__doc__r%r*r"r#Z user_optionsZboolean_optionsrrr-r4r5r6r r r rrs @r)r:rZ configparserrZ distutils.cmdrrrr r r rÚs