Viewing File: /opt/alt/python35/lib64/python3.5/distutils/command/__pycache__/register.cpython-35.opt-1.pyc



®ÕYfÕ-ã@s¢dZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlTddl
mZGdd„deƒZdS)	zhdistutils.command.register

Implements the Distutils 'register' command (register with the repository).
éN)Úwarn)Ú
PyPIRCCommand)Ú*)Úlogc@sÏeZdZdZejdd gZejdddgZdd	d
„fgZdd„Zd
d„Z	dd„Z
dd„Zdd„Zdd„Z
dd„Zdd„Zdd„Zddd„ZdS)!Úregisterz7register the distribution with the Python package indexúlist-classifiersNú list the valid Trove classifiersÚstrictúBWill stop the registering if the meta-data are not fully compliantÚverifyÚcheckcCsdS)NT©)Úselfr
r
ú?/opt/alt/python35/lib64/python3.5/distutils/command/register.pyÚ<lambda>szregister.<lambda>cCs#tj|ƒd|_d|_dS)Nr)rÚinitialize_optionsÚlist_classifiersr	)rr
r
rrs
	zregister.initialize_optionscCs<tj|ƒdd|jfddi}||jjd<dS)Nr	rÚrestructuredtextér)rr)rÚfinalize_optionsr	ÚdistributionZcommand_options)rZ
check_optionsr
r
rr$s
zregister.finalize_optionscCsr|jƒ|jƒx!|jƒD]}|j|ƒq!W|jrN|jƒn |jrd|jƒn
|jƒdS)N)	rÚ_set_configZget_sub_commandsZrun_commandZdry_runÚverify_metadatarÚclassifiersÚ
send_metadata)rZcmd_namer
r
rÚrun+s

	
	
zregister.runcCsLtdtƒ|jjdƒ}|jƒ|j|_d|_|jƒdS)zDeprecated API.zddistutils.command.register.check_metadata is deprecated,               use the check command insteadrrN)rÚPendingDeprecationWarningrZget_command_objZensure_finalizedr	rr)rrr
r
rÚcheck_metadata:s

	zregister.check_metadatacCs«|jƒ}|ikrX|d|_|d|_|d|_|d|_d|_nO|jd|jfkrƒtd|jƒ‚|jdkrž|j|_d|_d	S)
z: Reads the configuration file and set attributes.
        ÚusernameÚpasswordÚ
repositoryÚrealmTZpypiz%s not found in .pypircFN)Z_read_pypircrrr r!Ú
has_configZDEFAULT_REPOSITORYÚ
ValueError)rÚconfigr
r
rrDs



zregister._set_configcCs9|jd}tjj|ƒ}tj|j|ƒƒdS)z8 Fetch the list of classifiers from the server.
        z?:action=list_classifiersN)r ÚurllibÚrequestZurlopenrÚinfoÚ_read_pypi_response)rZurlZresponser
r
rrUs
zregister.classifierscCs9|j|jdƒƒ\}}tjd||fƒdS)zF Send the metadata to the package index server to be checked.
        rzServer response (%s): %sN)Úpost_to_serverÚbuild_post_datarr')rÚcodeÚresultr
r
rr\szregister.verify_metadatac
Csâ|jr$d}|j}|j}nd}d}}djƒ}xQ||kr“|jdtjƒtƒ}|szd}qC||krCtdƒqCW|dkrx|s¸tdƒ}q£Wx|sÔt	j	dƒ}q¼Wt
jjƒ}t
j
j|jƒd	}|j|j|||ƒ|j|jd
ƒ|ƒ\}}|jd||ftjƒ|dkrÞ|jrx||j_qÞ|jd
tjƒ|jd|jƒtjƒd}x.|jƒdkrÞtdƒ}|s±d}q±W|jƒdkrÞ|j||ƒnÚ|dkroddi}	d|	d<|	d<|	d<d|	d<x|	ds`tdƒ|	d<qCWx’|	d|	dkrõx!|	ds›t	j	dƒ|	d<q{Wx!|	ds¿t	j	dƒ|	d<qŸW|	d|	dkrdd|	d<d|	d<tdƒqdWx|	dstdƒ|	d<qùW|j|	ƒ\}}|dkrRtjd||fƒqÞtjdƒtjd ƒno|d!krÞdd"i}	d|	d<x|	ds±td#ƒ|	d<q”W|j|	ƒ\}}tjd||fƒdS)$a_ 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.

        Ú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: rZsubmitzServer response (%s): %séÈ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Ú2z:actionÚuserÚnamerZemailNZconfirmz
 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')
rZchoicerrÚchoicesÚauthÚhostr+r,Údatar
r
rrcsŒ		

				
		
	










zregister.send_metadatac"Csþ|jj}d|ddd|jƒd|jƒd|jƒd|jƒd|jƒd	|jƒd
|jƒd|j	ƒd|j
ƒd
|jƒd|jƒd|j
ƒd|jƒd|jƒd|jƒi}|dsð|dsð|drúd|d<|S)Nz:actionZmetadata_versionz1.0r6ÚversionZsummaryZ	home_pageZauthorZauthor_emailÚlicenseÚdescriptionÚkeywordsÚplatformrZdownload_urlZprovidesZrequiresZ	obsoletesz1.1)rZmetadataZget_nameZget_versionZget_descriptionZget_urlZget_contactZget_contact_emailZget_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_datacCs°d|kr0|jd|d|jftjƒd}d|}|d}tjƒ}x¿|jƒD]±\}}t|ƒtgƒtfƒfkrœ|g}xu|D]m}t|ƒ}|j	|ƒ|j	d|ƒ|j	dƒ|j	|ƒ|r£|dd	kr£|j	d
ƒq£WqcW|j	|ƒ|j	d
ƒ|j
ƒjdƒ}dd
|dtt|ƒƒi}	t
jj|j||	ƒ}
t
jjt
jjd|ƒƒ}d}y|j|
ƒ}Wn‘t
jjk
r}
z/|jrñ|
jjƒ}|
j|
jf}WYdd}
~
Xn[t
jjk
rQ}
zdt|
ƒf}WYdd}
~
XnX|jrj|j|ƒ}d}|jr¬d
jdd|ddfƒ}|j|tjƒ|S)zC Post a query to the server, and return a string response.
        r6zRegistering %s to %sz3--------------GHSKFJDLGDS7543FJKLFHRE75642756743254z
--z--z*
Content-Disposition: form-data; name="%s"z

rú
Ú
zutf-8zContent-typez/multipart/form-data; boundary=%s; charset=utf-8zContent-lengthZpassword_mgrr/Niôr0ÚOKú-éKéÿÿÿÿ)r0rM)r9r rr:ÚioÚStringIOÚitemsÚtypeÚstrÚwriteÚgetvalueÚencodeÚlenr%r&ZRequestZbuild_openerZHTTPBasicAuthHandlerÚopenÚerrorZ	HTTPErrorZ
show_responseÚfpÚreadr+ÚmsgZURLErrorr(Újoin)rrCrAÚboundaryZsep_boundaryZend_boundaryZbodyÚkeyÚvalueZheadersZreqZopenerr,Úer^r
r
rr)ùsV



$	






		$%		 zregister.post_to_server)rNr)r	Nr
)Ú__name__Ú
__module__Ú__qualname__rFrZuser_optionsZboolean_optionsZsub_commandsrrrrrrrrr*r)r
r
r
rrs&

zr)Ú__doc__ÚosÚstringr=rQZurllib.parser%Zurllib.requestÚwarningsrZdistutils.corerZdistutils.errorsZ	distutilsrrr
r
r
rÚ<module>s$

Back to Directory File Manager