î Ôê[ãã@sdZddlZddlZddlZddlZddlZddlmZddlm Z m Z m Z ddl m Z ddlmZmZddlmZddlmZdd lmZejd krædd lmZndd lmZGd d „d eƒZdS)z`distutils.command.upload Implements the Distutils 'upload' subcommand (upload package to PyPI).éN)Ústandard_b64encode)ÚurlopenÚRequestÚ HTTPError)Úurlparse)ÚDistutilsErrorÚDistutilsOptionError)Ú PyPIRCCommand)Úspawn)Úlogz2.5)Úmd5c@sieZdZdZejddgZejdgZdd „Zd d „Zd d „Z dd„Z dS)Úuploadzupload binary package to PyPIÚsignÚsúsign files to upload using gpgú identity=ÚiúGPG identity used to sign filescCs>tj|ƒd|_d|_d|_d|_d|_dS)NÚrF)r Úinitialize_optionsÚusernameÚpasswordÚ show_responserÚidentity)Úself©rú./usr/lib/python3.4/distutils/command/upload.pyr#s      zupload.initialize_optionscCsªtj|ƒ|jr/|j r/tdƒ‚n|jƒ}|ikr~|d|_|d|_|d|_|d|_ n|j r¦|j jr¦|j j|_ndS)Nz.Must use --sign for --identity to have meaningrrÚ repositoryÚrealm) r Úfinalize_optionsrrrZ _read_pypircrrrrÚ distribution)rZconfigrrrr+s       zupload.finalize_optionscCsR|jjstdƒ‚nx0|jjD]"\}}}|j|||ƒq(WdS)Nz'No dist file created in earlier command)r Z dist_filesrÚ upload_file)rÚcommandÚ pyversionÚfilenamerrrÚrun=s z upload.runc$Csût|jƒ\}}}}}} |s3|s3| rItd|jƒ‚n|dIkrhtd|ƒ‚n|jr¾ddd|g} |jr¨d|jg| d d …6t,t2|ƒƒd?6|d@6}t3|jdA|dB|ƒ}y%t4|ƒ}|j5ƒ}|j6} Wnwt7k r}!z!|j/t,|!ƒt0j8ƒ‚WYdd}!~!Xn7t9k rM}!z|!j:}|!j6} WYdd}!~!XnX|dCkrz|j/dD|| ft0j1ƒn/dE|| f}"|j/|"t0j8ƒt;|"ƒ‚|j<r÷|j=|ƒ}#dFj>dGdH|#dGdHfƒ}"|j/|"t0j1ƒndS)KNzIncompatible url %sÚhttpÚhttpszunsupported schema Zgpgz --detach-signz-az --local-useréÚdry_runÚrbZ file_uploadz:actionÚ1Zprotcol_versionÚnameÚversionÚcontentZfiletyper#Z md5_digestz1.0Zmetadata_versionZsummaryZ home_pageZauthorZ author_emailZlicenseÚ descriptionÚkeywordsÚplatformZ classifiersZ download_urlZprovidesZrequiresZ obsoletesrZ bdist_rpmzbuilt for %s %sZ bdist_dumbz built for %sZterseéÚcommentz.ascZ gpg_signatureú:ÚasciizBasic z3--------------GHSKFJDLGDS7543FJKLFHRE75642756743254s --s-- z+ Content-Disposition: form-data; name="%s"z; filename="%s"rzutf-8s s s zSubmitting %s to %sz multipart/form-data; boundary=%sz Content-typezContent-lengthZ AuthorizationÚdataÚheaderséÈzServer response (%s): %szUpload failed (%s): %sÚ ú-éK)r&r'éÿÿÿÿ)?rrÚAssertionErrorrrr r)ÚopenÚreadÚcloser ZmetadataZget_nameZ get_versionÚosÚpathÚbasenamer Z hexdigestZget_descriptionZget_urlZ get_contactZget_contact_emailZ get_licenceZget_long_descriptionZ get_keywordsZ get_platformsZget_classifiersZget_download_urlZ get_providesZ get_requiresZ get_obsoletesr1ÚdistrrÚencoderÚdecodeÚioÚBytesIOÚitemsÚtypeÚtupleÚstrÚwriteÚgetvalueZannouncer ÚINFOÚlenrrZgetcodeÚmsgÚOSErrorZERRORrÚcoderrZ_read_pypi_responseÚjoin)$rr"r#r$ZschemaZnetlocZurlZparamsZqueryZ fragmentsZgpg_argsÚfr.Úmetar6r3rDr-ÚidZ user_passZauthÚboundaryZ sep_boundaryZ end_boundaryZbodyÚkeyÚvalueÚtitler7ZrequestÚresultZstatusÚreasonÚerQÚtextrrrr!CsÈ!                         #                        zupload.upload_fileN)zsignrr)rrr) Ú__name__Ú __module__Ú __qualname__r/r Z user_optionsZboolean_optionsrrr%r!rrrrr s     r )Ú__doc__ÚsysrArGZsocketr1Úbase64rZurllib.requestrrrZ urllib.parserZdistutils.errorsrrZdistutils.corer Zdistutils.spawnr Z distutilsr r-r Zhashlibr rrrrÚs