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/usr/lib64/python3.6/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&)Cs^t|j\}}}}}} |s"|s"| r0td|j|d2krDtd||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}ytj!| j}WnPt"k r}z2d|}|j#|t$j%ddl&m'}|s|WYdd}~Xn X||d<d}|dkrt(j)\}}}|rd||f}n|dkrdt(j(dd}||d<|jrtjj|dt|dd jf|d<|j*d|j+j,d}d t-|j.d}d!}d"|j,d}|d#}t/j0}x|j1D]\}}d$|}t2|t3s|g}xr|D]j}t4|t5kr|d%|d7}|d}nt6|j,d&}|j7||j7|j,d&|j7d'|j7|qWqjW|j7||j8}d(||jf}|j#|t$j%d)|t6t9||d*} t:|j|| d+}!yt;|!}"|"j<}#|"j=}$Wnft>k r}z|j?}#|j=}$WYdd}~Xn8t@k r}z|j#t6|t$jAWYdd}~XnX|#d,kr8|j#d-|#|$ft$j%|jBrZ|jC|"}%d.jDd/d0|%d/d0f}|j#|t$j%n"d1|#|$f}|j#|t$jAtE|dS)3NzIncompatible url %shttphttpszunsupported schema Zgpgz --detach-signz-az --local-user)dry_runrbZ file_upload1z1.0)z:actionZprotocol_versionnameversioncontentZfiletyper$Z sha256_digestZmetadata_versionZsummaryZ home_pageZauthorZ author_emaillicense descriptionkeywordsplatformZ classifiersZ download_urlZprovidesZrequiresZ obsoletesz#calculating md5 checksum failed: %sr) get_fips_modeZ md5_digestrZ 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"zutf-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()FrrAssertionErrorr rr r*openreadcloserZmetadataZget_nameZ get_versionospathbasenamehashlibZsha256Z hexdigestZget_descriptionZget_urlZ get_contactZget_contact_emailZ get_licenceZget_long_descriptionZ get_keywordsZ get_platformsZget_classifiersZget_download_urlZ get_providesZ get_requiresZ get_obsoletesZmd5 ValueErrorZannouncer INFOZ_hashlibr4r3distrrencoderdecodeioBytesIOitems isinstancelisttypetuplestrwritegetvaluelenrrZgetcoder"rcodeOSErrorZERRORrZ_read_pypi_responsejoinr)&rr#r$r%ZschemaZnetlocZurlZparamsZqueryZ fragmentsZgpg_argsfr/metar9Zdigester"r4r6rIr.idZ user_passZauthboundaryZ sep_boundaryZ end_boundaryZbodykeyvaluetitler:ZrequestresultZstatusreasontextrrrr!Bs                       zupload.upload_fileN)r rr)rrr) __name__ __module__ __qualname__r1r Z user_optionsZboolean_optionsrrr&r!rrrrr s r )__doc__rCrLr3rFbase64rZurllib.requestrrrZ urllib.parserZdistutils.errorsrrZdistutils.corer Zdistutils.spawnr Z distutilsr r rrrrs