3  f]@sdZddlZddlZddlZddlZddlmZddlmZm Z m Z ddl m Z ddl mZmZddlmZddlmZdd lmZGd d d eZdS) zm distutils.command.upload Implements the Distutils 'upload' subcommand (upload package to a package index). N)standard_b64encode)urlopenRequest HTTPError)urlparse)DistutilsErrorDistutilsOptionError) PyPIRCCommand)spawn)logc@sJeZdZdZejddgZejdgZdd Zd d Zd d Z ddZ dS)uploadzupload binary package to PyPIsignssign files to upload using gpg identity=iGPG identity used to sign filescCs,tj|d|_d|_d|_d|_d|_dS)NrF)r initialize_optionsusernamepassword show_responser identity)selfr=/opt/alt/python36/lib64/python3.6/distutils/command/upload.pyr s  zupload.initialize_optionscCsvtj||jr |j r td|j}|ikrX|d|_|d|_|d|_|d|_ |j rr|j jrr|j j|_dS)Nz.Must use --sign for --identity to have meaningrr repositoryrealm) r finalize_optionsrr rZ _read_pypircrrrr distribution)rconfigrrrr(s     zupload.finalize_optionscCs>|jjsd}t|x$|jjD]\}}}|j|||qWdS)NzHMust create and upload files in one command (e.g. setup.py sdist upload))rZ dist_filesr upload_file)rmsgcommand pyversionfilenamerrrrun:s z upload.runc$Cst|j\}}}}}} |s"|s"| r0td|j|d/krDtd||jr|ddd|g} |jrnd|jg| d d <t| |jd t|d } z | j} Wd| j X|j j } d d | j | j tjj|| f||tj| jd| j| j| j| j| j| j| j| j| j| j| j| j| j d}d}|dkrZt!j"\}}}|rtd||f}n|dkrtdt!j!dd}||d<|jrtjj|dt|dd jf|d<|j#d|j$j%d}dt&|j'd}d}d|j%d}|d}t(j)}x|j*D]\}}d |}t+|t,s |g}xr|D]j}t-|t.krR|d!|d"7}|d}nt/|j%d#}|j0||j0|j%d#|j0d$|j0|q&WqW|j0||j1}d%||jf}|j2|t3j4d&|t/t5||d'}t6|j||d(}yt7|}|j8} |j9}!Wnft:k r:}"z|"j;} |"j9}!WYdd}"~"Xn8tr|j?|}#d+j@d,d-|#d,d-f}|j2|t3j4n"d.| |!f}|j2|t3j=tA|dS)0NzIncompatible url %shttphttpszunsupported schema Zgpgz --detach-signz-az --local-user)dry_runrbZ file_upload1z1.0)z:actionZprotocol_versionnameversioncontentZfiletyper$Z md5_digestZmetadata_versionZsummaryZ home_pageZauthorZ author_emaillicense descriptionkeywordsplatformZ classifiersZ download_urlZprovidesZrequiresZ obsoletesrZ bdist_rpmzbuilt for %s %sZ bdist_dumbz built for %s)Ztersecommentz.ascZ gpg_signature:asciizBasic z3--------------GHSKFJDLGDS7543FJKLFHRE75642756743254s --s-- z+ Content-Disposition: form-data; name="%s"z; filename="%s"rzutf-8s zSubmitting %s to %sz multipart/form-data; boundary=%s)z Content-typezContent-lengthZ Authorization)dataheaderszServer response (%s): %s -KzUpload failed (%s): %s)r'r()BrrAssertionErrorr rr r*openreadcloserZmetadataZget_nameZ get_versionospathbasenamehashlibZmd5Z hexdigestZget_descriptionZget_urlZ get_contactZget_contact_emailZ get_licenceZget_long_descriptionZ get_keywordsZ get_platformsZget_classifiersZget_download_urlZ get_providesZ get_requiresZ get_obsoletesr3distrrencoderdecodeioBytesIOitems isinstancelisttypetuplestrwritegetvalueZannouncer INFOlenrrZgetcoder"rcodeOSErrorZERRORrZ_read_pypi_responsejoinr)$rr#r$r%ZschemaZnetlocZurlZparamsZqueryZ fragmentsZgpg_argsfr/metar8r5rFr.idZ user_passZauthboundaryZ sep_boundaryZ end_boundaryZbodykeyvaluetitler"r9ZrequestresultZstatusreasonetextrrrr!Bs                      zupload.upload_fileN)r rr)rrr) __name__ __module__ __qualname__r1r Z user_optionsZboolean_optionsrrr&r!rrrrr s r )__doc__rBrIr3rEbase64rZurllib.requestrrrZ urllib.parserZdistutils.errorsrrZdistutils.corer Zdistutils.spawnr Z distutilsr r rrrrs