Hacked By AnonymousFox

Current Path : /opt/alt/python37/lib64/python3.7/distutils/command/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/distutils/command/__pycache__/register.cpython-37.opt-1.pyc

B

� f�-�@sddZddlZddlZddlZddlZddlmZddlm	Z	ddl
TddlmZGdd�de	�Z
dS)	zhdistutils.command.register

Implements the Distutils 'register' command (register with the repository).
�N)�warn)�
PyPIRCCommand)�*)�logc@s�eZdZdZejddgZejdddgZddd	�fgZd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zddd�ZdS) �registerz7register the distribution with the Python package index)zlist-classifiersNz list the valid Trove classifiers)�strictNzBWill stop the registering if the meta-data are not fully compliant�verifyzlist-classifiersr�checkcCsdS)NT�)�selfr
r
�?/opt/alt/python37/lib64/python3.7/distutils/command/register.py�<lambda>�zregister.<lambda>cCst�|�d|_d|_dS)Nr)r�initialize_options�list_classifiersr)rr
r
rrs
zregister.initialize_optionscCs*t�|�d|jfdd�}||jjd<dS)Nr)r�)r�restructuredtextr	)r�finalize_optionsr�distributionZcommand_options)rZ
check_optionsr
r
rr$s
zregister.finalize_optionscCsX|��|��x|��D]}|�|�qW|jr<|��n|jrL|��n|��dS)N)	r�_set_configZget_sub_commandsZrun_commandZdry_run�verify_metadatar�classifiers�
send_metadata)rZcmd_namer
r
r�run+s

zregister.runcCs8tdt�|j�d�}|��|j|_d|_|��dS)zDeprecated API.zddistutils.command.register.check_metadata is deprecated,               use the check command insteadr	rN)r�PendingDeprecationWarningrZget_command_objZensure_finalizedrrr)rr	r
r
r�check_metadata:szregister.check_metadatacCsz|��}|ikr@|d|_|d|_|d|_|d|_d|_n6|jd|jfkr^td|j��|jdkrp|j|_d|_d	S)
z: Reads the configuration file and set attributes.
        �username�password�
repository�realmTZpypiz%s not found in .pypircFN)Z_read_pypircrrrr�
has_configZDEFAULT_REPOSITORY�
ValueError)rZconfigr
r
rrDs




zregister._set_configcCs*|jd}tj�|�}t�|�|��dS)z8 Fetch the list of classifiers from the server.
        z?:action=list_classifiersN)r�urllib�requestZurlopenr�info�_read_pypi_response)rZurlZresponser
r
rrUs
zregister.classifierscCs&|�|�d��\}}t�d||�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
rr\szregister.verify_metadatac
Cs|jrd}|j}|j}nd}d}}d��}x:||krf|�dtj�t�}|sTd}q.||kr.td�q.W|dk�r|x|s�td�}qtWx|s�t	�	d�}q�Wt
j��}t
j
�|j�d	}|�|j|||�|�|�d
�|�\}}|�d||ftj�|dk�r|j�r||j_nj|�d
tj�|�d|��tj�d}x&|��dk�r\td�}|�s8d}�q8W|��dk�r|�||��n�|dk�r�ddi}	d|	d<|	d<|	d<d|	d<x|	d�s�td�|	d<�q�Wx�|	d|	dk�rNx|	d�s�t	�	d�|	d<�q�Wx|	d�st	�	d�|	d<�qW|	d|	dk�r�d|	d<d|	d<td��q�Wx|	d�sltd�|	d<�qRW|�|	�\}}|dk�r�t�d||�nt�d�t�d �nT|d!k�rdd"i}	d|	d<x|	d�s�td#�|	d<�q�W|�|	�\}}t�d||�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�parseZurlparserZadd_passwordrr&r'rZ_get_rc_file�lowerZ
_store_pypircr$)
rZchoicerr�choices�authZhostr(r)�datar
r
rrcs�











zregister.send_metadatacCs�|jj}|d|��|��|��|��|��|��|��|�	�|�
�|��|��|�
�|��|��|��d�}|ds�|ds�|dr�d|d<|S)Nz1.0)z:action�metadata_versionr3�versionZsummaryZ	home_pageZauthorZauthor_email�license�description�keywords�platformrZdownload_url�provides�requires�	obsoletesrFrGrHz1.1r@)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�metar?r
r
rr'�s*zregister.build_post_dataNc
Cs�d|kr$|�d|d|jftj�d}d|}|d}t��}x�|��D]�\}}t|�tg�td�fkrp|g}xZ|D]R}t|�}|�	|�|�	d|�|�	d�|�	|�|rv|d	d
krv|�	d�qvWqJW|�	|�|�	d�|�
��d�}d
|tt|��d�}	t
j�|j||	�}
t
j�t
jj|d��}d}y|�|
�}Wnxt
jjk
�r�}
z"|j�rl|
j��}|
j|
jf}Wdd}
~
XYnJt
jjk
�r�}
zdt|
�f}Wdd}
~
XYnX|j�r�|�|�}d}|j�r�d�d|df�}|�|tj�|S)zC Post a query to the server, and return a string response.
        r3zRegistering %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,Ni�)r-ZOKzK---------------------------------------------------------------------------)r6rrr7�io�StringIO�items�type�str�write�getvalue�encode�lenr"r#ZRequestZbuild_openerZHTTPBasicAuthHandler�open�errorZ	HTTPErrorZ
show_response�fp�readr(�msgZURLErrorr%�join)rr?r>�boundaryZsep_boundaryZend_boundaryZbody�key�valueZheadersZreq�openerr)�er[r
r
rr&�sV







zregister.post_to_server)N)�__name__�
__module__�__qualname__rCrZuser_optionsZboolean_optionsZsub_commandsrrrrrrrrr'r&r
r
r
rrs"
zr)�__doc__r:rNZurllib.parser"Zurllib.request�warningsrZdistutils.corerZdistutils.errorsZ	distutilsrrr
r
r
r�<module>s

Hacked By AnonymousFox1.0, Coded By AnonymousFox