U e5dÀ-ã@s`ddlZddlZddlZddlZddlmZddlmZddl Tddl m Z Gdd„deƒZ dS)éN)Úwarn)Ú PyPIRCCommand)Ú*)Úlogc@sŽeZdZdZejddgZejdddgZddd „fgZd d „Zd d „Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zddd„ZdS) Úregisterz7register the distribution with the Python package index)úlist-classifiersNz list the valid Trove classifiers)ÚstrictNzBWill stop the registering if the meta-data are not fully compliantÚverifyrrÚcheckcCsdS)NT©©Úselfr r ú2/usr/lib64/python3.8/distutils/command/register.pyÚózregister.cCst |¡d|_d|_dS)Nr)rÚinitialize_optionsÚlist_classifiersrr r r rrs zregister.initialize_optionscCs*t |¡d|jfddœ}||jjd<dS)Nr)ré)rÚrestructuredtextr )rÚfinalize_optionsrÚ distributionZcommand_options)r Z check_optionsr r rr$s  ÿzregister.finalize_optionscCsT| ¡| ¡| ¡D]}| |¡q|jr8| ¡n|jrH| ¡n| ¡dS)N) rÚ _set_configZget_sub_commandsZ run_commandZdry_runÚverify_metadatarÚ classifiersÚ send_metadata)r Zcmd_namer r rÚrun+s    z register.runcCs8tdtƒ|j d¡}| ¡|j|_d|_| ¡dS)Nzddistutils.command.register.check_metadata is deprecated, use the check command insteadr r)rÚPendingDeprecationWarningrZget_command_objZensure_finalizedrrr)r r r r rÚcheck_metadata:sÿ zregister.check_metadatacCsz| ¡}|ikr@|d|_|d|_|d|_|d|_d|_n6|jd|jfkr^td|jƒ‚|jdkrp|j|_d|_dS) NÚusernameÚpasswordÚ repositoryÚrealmTZpypiz%s not found in .pypircF)Z _read_pypircrrr r!Ú has_configZDEFAULT_REPOSITORYÚ ValueError)r Zconfigr r rrDs     zregister._set_configcCs*|jd}tj |¡}t | |¡¡dS)Nz?:action=list_classifiers)r ÚurllibÚrequestZurlopenrÚinfoÚ_read_pypi_response)r ZurlZresponser r rrUs  zregister.classifierscCs&| | d¡¡\}}t d||¡dS)Nr úServer response (%s): %s)Úpost_to_serverÚbuild_post_datarr&)r ÚcodeÚresultr r rr\szregister.verify_metadatac CsÜ|jrd}|j}|j}n d}d}}d ¡}||krd| dtj¡tƒ}|sRd}q,||kr,tdƒq,|dkrl|s|tdƒ}qn|sŒt   d¡}q|t j   ¡}t j  |j¡d }| |j|||¡| | d ¡|¡\}}| d ||ftj¡|d krØ|jr||j_nf| d tj¡| d| ¡tj¡d}| ¡dkrNtdƒ}|s*d}q*| ¡dkrØ| ||¡nl|dkrˆddi} d| d<| d<| d<d| d<| ds¸tdƒ| d<qž| d| dkr0| dsæt   d¡| d<qÊ| dst   d¡| d<qæ| d| dkr¸d| d<d| d<tdƒq¸| dsJtdƒ| d<q0| | ¡\}}|d krrt d ||¡nt d¡t d¡nP|d krØdd!i} d| d<| ds¼td"ƒ| d<q¢| | ¡\}}t d ||¡dS)#NÚ1ÚxÚz1 2 3 4zâWe need to know who you are, so please choose either: 1. use your existing login, 2. register as a new user, 3. have the server generate a new password for you (and email it to you), or 4. quit Your selection [default 1]: z&Please choose one of the four options!z Username: z Password: rZsubmitr(éÈzAI can store your PyPI login so future submissions will be faster.z (the login will be stored in %s)ÚXZynzSave your login (y/N)?ÚnÚyÚ2ú:actionÚuserÚnamerZemailZconfirmz Confirm: z!Password and confirm don't match!z EMail: z"You will receive an email shortly.z7Follow the instructions in it to complete registration.Ú3Zpassword_resetzYour email address: )r"rrÚsplitÚannouncerÚINFOÚinputÚprintÚgetpassr$r%ZHTTPPasswordMgrÚparseZurlparser Z add_passwordr!r)r*rZ _get_rc_fileÚlowerZ _store_pypircr&) r ZchoicerrÚchoicesÚauthZhostr+r,Údatar r rrcsšú      ÿÿ  ÿÿÿ           zregister.send_metadatacCs|jj}|d| ¡| ¡| ¡| ¡| ¡| ¡| ¡|  ¡|  ¡|  ¡|  ¡|  ¡| ¡| ¡| ¡dœ}|ds„|ds„|drŒd|d<|S)Nz1.0)r5Úmetadata_versionr7ÚversionZsummaryZ home_pageZauthorZ author_emailÚlicenseÚ descriptionÚkeywordsÚplatformrZ download_urlÚprovidesÚrequiresÚ obsoletesrJrKrLz1.1rD)rZmetadataZget_nameZ get_versionZget_descriptionZget_urlZ get_contactZget_contact_emailZ get_licenceZget_long_descriptionZ get_keywordsZ get_platformsZget_classifiersZget_download_urlZ get_providesZ get_requiresZ get_obsoletes)r ÚactionÚmetarCr r rr*Ýs,îzregister.build_post_dataNc Csôd|kr$| d|d|jftj¡d}d|}|d}t ¡}| ¡D]~\}}t|ƒtgƒtdƒfkrn|g}|D]R}t|ƒ}|  |¡|  d|¡|  d¡|  |¡|rr|d d krr|  d ¡qrqH|  |¡|  d ¡|  ¡  d ¡}d |tt |ƒƒdœ} t j |j|| ¡} t j t jj|d¡} d}z|  | ¡} Wnxt jjk r€} z"|jrd| j ¡}| j| jf} W5d} ~ XYnJt jjk r²} zdt| ƒf} W5d} ~ XYnX|jrÆ| | ¡}d} |jrðd  d|df¡}| |tj¡| S)Nr7zRegistering %s to %sz3--------------GHSKFJDLGDS7543FJKLFHRE75642756743254z --z--r z* Content-Disposition: form-data; name="%s"z éÿÿÿÿú Ú zutf-8z/multipart/form-data; boundary=%s; charset=utf-8)z Content-typezContent-length)Z password_mgrr/iô)r0ZOKzK---------------------------------------------------------------------------)r:r rr;ÚioÚStringIOÚitemsÚtypeÚstrÚwriteÚgetvalueÚencodeÚlenr$r%ZRequestZ build_openerZHTTPBasicAuthHandlerÚopenÚerrorZ HTTPErrorZ show_responseÚfpÚreadr+ÚmsgZURLErrorr'Újoin)r rCrBÚboundaryZ sep_boundaryZ end_boundaryZbodyÚkeyÚvalueZheadersZreqZopenerr,Úer_r r rr)ùs^ ÿþ      þ ÿ  zregister.post_to_server)N)Ú__name__Ú __module__Ú __qualname__rGrZ user_optionsZboolean_optionsZ sub_commandsrrrrrrrrr*r)r r r rrs*ýÿ zr) r>rRZ urllib.parser$Zurllib.requestÚwarningsrZdistutils.corerZdistutils.errorsZ distutilsrrr r r rÚs