mò &U²Ic@s‚dZdZdkZdkZdkZdkZdkZdkZdkZdk Z dk l Z dk Tde fd„ƒYZ dS(shdistutils.command.register Implements the Distutils 'register' command (register with the repository). s=$Id: register.py 52244 2006-10-09 17:15:39Z andrew.kuchling $N(sCommand(t*tregistercBs“tZdZdZdddefddgZd ddgZd „Zd „Zd „Z d„Z d„Z d„Z d„Z d„Zdd„ZRS(Ns7register the distribution with the Python package indexshttp://www.python.org/pypis repository=trsurl of repository [default: %s]slist-classifierss list the valid Trove classifierss show-responses&display full response text from servertverifycCsd|_d|_d|_dS(Ni(tNonetselft repositoryt show_responsetlist_classifiers(R((t7/data/zmath/lib/python2.4/distutils/command/register.pytinitialize_options s  cCs$|idjo|i|_ndS(N(RRRtDEFAULT_REPOSITORY(R((R tfinalize_options%scCsH|iƒ|io|iƒn#|io|iƒn |iƒdS(N(Rtcheck_metadatatdry_runtverify_metadataRt classifierst send_metadata(R((R trun)s    cCsï|ii}g}x?dD]7}t||ƒo t||ƒp|i|ƒqqW|o!|idt i |dƒƒn|i o#|i p|iddƒqënC|i o#|ip|idd ƒqën|id d d ƒd S(sïEnsure that all required elements of meta-data (name, version, URL, (author and author_email) or (maintainer and maintainer_email)) are supplied by the Distribution object; warn if any are missing. tnametversionturlsmissing required meta-data: s, s)missing meta-data: if 'author' supplied, s#'author_email' must be supplied toos-missing meta-data: if 'maintainer' supplied, s''maintainer_email' must be supplied toos4missing meta-data: either (author and author_email) s%or (maintainer and maintainer_email) smust be suppliedN(snamesversionR(Rt distributiontmetadatatmissingtattrthasattrtgetattrtappendtwarntstringtjointauthort author_emailt maintainertmaintainer_email(RRRR((R R 2s   !    cCs%ti|idƒ}|iƒGHdS(s8 Fetch the list of classifiers from the server. s?:action=list_classifiersN(turllib2turlopenRRtresponsetread(RR&((R RPscCs1|i|idƒƒ\}}d||fGHdS(sF Send the metadata to the package index server to be checked. RsServer response (%s): %sN(Rtpost_to_servertbuild_post_datatcodetresult(RR*R+((R RVsc CsŠd}d}} d,} tiidƒoƒtii tiddƒ} tii | ƒoPd| GHt i ƒ} | i | ƒ| iddƒ}| iddƒ} d }q¬nd iƒ}xF||jo8d Gtƒ}|p d }q»||jo d GHq»q»W|d jo£x|ptd ƒ}qWx| ptidƒ} q,Wtiƒ}ti|iƒd}|id||| ƒ|i|idƒ|ƒ\}} d|| fGHtiidƒoë| d,joÞ|djoÑtii tiddƒ} dGHd| GHd}x5|iƒdjo!tdƒ}|p d}qqW|iƒdjoRt | dƒ}|i"d|| fƒ|i#ƒyti$| dƒWq©q©Xq­q†nÖ|djoWhdd <}d|d!<|d<|d"W|i|ƒ\}} d|| fGHnd,S(-s Send the metadata to the package index server. Well, do the following: 1. figure who the user is, and then 2. send the data as a Basic auth'ed POST. First we try to read the username/password from $HOME/.pypirc, which is a ConfigParser-formatted file with a section [server-login] containing username and password entries (both in clear text). Eg: [server-login] username: fred password: sekrit Otherwise, to figure who the user is, we offer the user three choices: 1. use existing login, 2. register as a new user, or 3. set the password to a random string and email the user. txttHOMEs.pypircsUsing PyPI login from %ss server-logintusernametpasswordt1s1 2 3 4sâ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]: s&Please choose one of the four options!s Username: s Password: itpypitsubmitsServer response (%s): %siÈsAI can store your PyPI login so future submissions will be faster.s (the login will be stored in %s)tXtynsSave your login (y/N)?tntytws'[server-login] username:%s password:%s i€t2s:actiontuserRtemailtconfirms Confirm: s!Password and confirm don't match!s EMail: s"You will receive an email shortly.s7Follow the instructions in it to complete registration.t3tpassword_resetsYour email address: N(&tchoiceR/R0Rtconfigtostenvironthas_keytpathRtrctexistst ConfigParserR'tgettsplittchoicest raw_inputtgetpassR$tHTTPPasswordMgrtauthturlparseRRthostt add_passwordR(R)R*R+tlowertopentftwritetclosetchmodtdata( RR/R*RTRXRNR?RPRJR+RER0R@((R R]s°           -                cCsÜ|ii}hd|<dd<d|iƒ<d|iƒ<d|iƒ<d|iƒ<d|i ƒ<d |i ƒ<d |i ƒ<d |i ƒ<d |i ƒ<d |iƒ<d|iƒ<d|iƒ<}|S(Ns:actiontmetadata_versions1.0RRtsummaryt home_pageR R!tlicenset descriptiontkeywordstplatformRt download_url(RRRtmetatactiontget_namet get_versiontget_descriptiontget_urlt get_contacttget_contact_emailt get_licencetget_long_descriptiont get_keywordst get_platformstget_classifierstget_download_urlRX(RRbRaRX((R R)×s ÌcCsPd} d| } | d}tiƒ}xÓ|iƒD]Å\} } t | ƒt gƒt fƒfjo | g} nx„| D]|} t | ƒi dƒ} |i | ƒ|i d| ƒ|i dƒ|i | ƒ| o"| ddjo|i d ƒqxqxWq3W|i |ƒ|i d ƒ|i ƒ}hd d | <d tt|ƒƒ<}ti|i||ƒ}titid |ƒƒ}d}y|i|ƒ} Wnptij o8}|io|ii ƒ}n|i!|i"f} nKti#j o}dt|ƒf} n"X|io| i ƒ}nd} |ioddG|GddGHn| S(sC Post a query to the server, and return a string response. s3--------------GHSKFJDLGDS7543FJKLFHRE75642756743254s --s--sutf-8s* Content-Disposition: form-data; name="%s"s iÿÿÿÿs s s Content-types/multipart/form-data; boundary=%s; charset=utf-8sContent-lengtht password_mgrR-iôiÈtOKt-iKN(iÈRp($tboundaryt sep_boundaryt end_boundarytStringIOtbodyRXtitemstkeytvaluettypetunicodetencodeRUtgetvaluetstrtlentheadersR$tRequestRRtreqt build_openertHTTPBasicAuthHandlerRNtopenerRSR+t HTTPErrorteRtfpR'R*tmsgtURLError(RRXRNRtRvR‡R‚R€R…RsRxRrRyR+((R R(ísN    %       (   (slist-classifiersNs list the valid Trove classifiers(s show-responseNs&display full response text from server(t__name__t __module__R]R Rt user_optionstboolean_optionsR R RR RRRR)R((((R Rs      z (t__doc__t __revision__tsysRARR$RLRORuRGtdistutils.coretCommandtdistutils.errorsR( RLRRRuRR$R‘R“RORARG((R t?s 6