Your IP : 3.12.153.197


Current Path : /lib64/python2.7/distutils/command/
Upload File :
Current File : //lib64/python2.7/distutils/command/register.pyc

�
�mec@szdZdZddlZddlZddlZddlmZddlmZddl	m
Z
defd��YZdS(	shdistutils.command.register

Implements the Distutils 'register' command (register with the repository).
s$Id$i����N(twarn(t
PyPIRCCommand(tlogtregistercBs�eZdZejddgZejdddgZdd�fgZd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
d�Zd�Zd�Zdd�ZRS(s7register the distribution with the Python package indexslist-classifierss list the valid Trove classifierststrictsBWill stop the registering if the meta-data are not fully complianttverifytcheckcCstS(N(tTrue(tself((s2/usr/lib64/python2.7/distutils/command/register.pyt<lambda>scCs#tj|�d|_d|_dS(Ni(Rtinitialize_optionstlist_classifiersR(R((s2/usr/lib64/python2.7/distutils/command/register.pyR
 s
	cCs>tj|�id|jfd6dd6}||jjd<dS(NRRitrestructuredtextR(sregisteri(Rtfinalize_optionsRtdistributiontcommand_options(Rt
check_options((s2/usr/lib64/python2.7/distutils/command/register.pyR
%s

cCsr|j�|j�x!|j�D]}|j|�q!W|jrN|j�n |jrd|j�n
|j�dS(N(	R
t_set_configtget_sub_commandstrun_commandtdry_runtverify_metadataRtclassifierst
send_metadata(Rtcmd_name((s2/usr/lib64/python2.7/distutils/command/register.pytrun,s

	
	
cCsLtdt�|jjd�}|j�|j|_d|_|j�dS(sDeprecated API.sddistutils.command.register.check_metadata is deprecated,               use the check command insteadRiN(RtPendingDeprecationWarningRtget_command_objtensure_finalizedRRR(RR((s2/usr/lib64/python2.7/distutils/command/register.pytcheck_metadata;s

	cCs�|j�}|ikrX|d|_|d|_|d|_|d|_t|_nU|jd|jfkr�td|j��n|jdkr�|j|_nt	|_dS(s: Reads the configuration file and set attributes.
        tusernametpasswordt
repositorytrealmtpypis%s not found in .pypircN(
t_read_pypircRRR R!Rt
has_configtDEFAULT_REPOSITORYt
ValueErrortFalse(Rtconfig((s2/usr/lib64/python2.7/distutils/command/register.pyREs



cCs-tj|jd�}tj|j��dS(s8 Fetch the list of classifiers from the server.
        s?:action=list_classifiersN(turllib2turlopenR Rtinfotread(Rtresponse((s2/usr/lib64/python2.7/distutils/command/register.pyRVscCs9|j|jd��\}}tjd||f�dS(sF Send the metadata to the package index server to be checked.
        RsServer response (%s): %sN(tpost_to_servertbuild_post_dataRR+(Rtcodetresult((s2/usr/lib64/python2.7/distutils/command/register.pyR\sc
Cs�|jr$d}|j}|j}nd}d}}dj�}xO||kr�|jdtj�t�}|szd}qC||krCdGHqCqCW|dkrx|s�td�}q�Wx|s�tjd�}q�Wt	j
�}tj|j�d	}|j
|j|||�|j|jd
�|�\}}|jd||ftj�|dkr�|jrp||j_q|jd
tj�|jd|j�tj�d}x1|j�dkr�td�}|s�d}q�q�W|j�dkr|j||�qq�n�|dkroidd6}	d|	d<|	d<|	d<d#|	d<x|	dsbtd�|	d<qEWx�|	d|	dkr�x!|	ds�tjd�|	d<q}Wx!|	ds�tjd�|	d<q�W|	d|	dkrfd|	d<d#|	d<dGHqfqfWx|	dstd�|	d<q�W|j|	�\}}|dkrRtjd||f�q�tjd�tjd�ns|d kr�id!d6}	d|	d<x|	ds�td"�|	d<q�W|j|	�\}}tjd||f�nd#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
            [distutils] containing username and password entries (both
            in clear text). Eg:

                [distutils]
                index-servers =
                    pypi

                [pypi]
                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.

        t1txts1 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: itsubmitsServer 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)?tntyt2tusers:actiontnameRtemailtconfirms
 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(R$RRtsplittannounceRtINFOt	raw_inputtgetpassR)tHTTPPasswordMgrturlparseR tadd_passwordR!R.R/Rt_get_rc_filetlowert
_store_pypirctNoneR+(
RtchoiceRRtchoicestauththostR0R1tdata((s2/usr/lib64/python2.7/distutils/command/register.pyRds�		

				
		
	












cCs|jj}i|d6dd6|j�d6|j�d6|j�d6|j�d6|j�d6|j�d	6|j�d
6|j	�d6|j
�d6|j�d
6|j�d6|j
�d6|j�d6|j�d6|j�d6}|ds|ds|drd|d<n|S(Ns:actions1.0tmetadata_versionR<tversiontsummaryt	home_pagetauthortauthor_emailtlicensetdescriptiontkeywordstplatformRtdownload_urltprovidestrequirest	obsoletess1.1(Rtmetadatatget_nametget_versiontget_descriptiontget_urltget_contacttget_contact_emailtget_licencetget_long_descriptiontget_keywordst
get_platformstget_classifierstget_download_urltget_providestget_requirest
get_obsoletes(RtactiontmetaRQ((s2/usr/lib64/python2.7/distutils/command/register.pyR/�s,














cCs�d|kr3|jd|d|jftj�nd}d|}|d}g}x�|j�D]�\}}t|�tg�td�fkr�|g}nxl|D]d}|j|�|jd|�|jd�|j|�|r�|dd	kr�|jd
�q�q�Wq`W|j|�|jd
�g}	xC|D];}
t|
t�rd|	j|
j	d��q6|	j|
�q6Wdj
|	�}	id
|d6tt|	��d6}t
j|j|	|�}t
jt
jd|��}
d}y|
j|�}Wnjt
jk
r9}|jr$|jj�}n|j|jf}nFt
jk
r`}dt|�f}nX|jry|j�}nd}|jr�dd}|jd|||f�n|S(sC Post a query to the server, and return a string response.
        R<sRegistering %s to %ss3--------------GHSKFJDLGDS7543FJKLFHRE75642756743254s
--s--s*
Content-Disposition: form-data; name="%s"s

i����s
s
sutf-8R4s/multipart/form-data; boundary=%s; charset=utf-8sContent-typesContent-lengthtpassword_mgri�i�tOKt-iKs%s%s%s((i�Rs(RBR RRCtitemsttypetappendt
isinstancetunicodetencodetjointstrtlenR)tRequesttbuild_openertHTTPBasicAuthHandlertopent	HTTPErrort
show_responsetfpR,R0tmsgtURLError(RRQROtboundarytsep_boundarytend_boundarytchunkstkeytvaluetbodytchunktheaderstreqtopenerR1tetdashes((s2/usr/lib64/python2.7/distutils/command/register.pyR.�s`



$






			
N(slist-classifiersNs list the valid Trove classifiers(sstrictNsBWill stop the registering if the meta-data are not fully compliant(t__name__t
__module__RYRtuser_optionsRLtboolean_optionstsub_commandsR
R
RRRRRRR/R.(((s2/usr/lib64/python2.7/distutils/command/register.pyRs&
				
				{	(t__doc__t__revision__R)RERGtwarningsRtdistutils.coreRt	distutilsRR(((s2/usr/lib64/python2.7/distutils/command/register.pyt<module>s