add-determinism 0.7.3

RPM buildroot helper to strip nondeterministic bits in files
Documentation
3

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

Implements the Distutils 'register' command (register with the repository).
�N)�warn)�
PyPIRCCommand)Z*)�logc@s�eZdZdZejdd gZejdddgZdd	d
�fgZdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd!dd�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���selfrr�2/usr/lib64/python3.6/distutils/command/register.pyZ<lambda>szregister.<lambda>cCstj|�d|_d|_dS)Nr)r�initialize_options�list_classifiersrrrrrrs
zregister.initialize_optionscCs*tj|�d|jfdd�}||jjd<dS)Nr�)r�restructuredtextr
)rr)r�finalize_optionsr�distributionZcommand_options)r
Z
check_optionsrrrr$s
zregister.finalize_optionscCsX|j�|j�x|j�D]}|j|�qW|jr<|j�n|jrL|j�n|j�dS�N)	r�_set_configZget_sub_commandsZrun_commandZdry_run�verify_metadatar�classifiers�
send_metadata)r
Zcmd_namerrr�run+s

zregister.runcCs8tdt�|jjd�}|j�|j|_d|_|j�dS)zDeprecated API.zddistutils.command.register.check_metadata is deprecated,               use the check command insteadr
rN)rZPendingDeprecationWarningrZget_command_objZensure_finalizedrrr)r
r
rrr�check_metadata:szregister.check_metadatacCsz|j�}|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_REPOSITORYZ
ValueError)r
ZconfigrrrrDs




zregister._set_configcCs*|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)r
ZurlZresponserrrrUs
zregister.classifierscCs&|j|jd��\}}tjd||�dS)zF Send the metadata to the package index server to be checked.
        r	�Server response (%s): %sN)�post_to_server�build_post_datarr#)r
�code�resultrrrr\szregister.verify_metadatac
Cs|jrd}|j}|j}nd}d}}dj�}x:||krf|jdtj�t�}|sTd}q.||kr.td�q.W|dk�r|x|s�td�}qtWx|s�t	j	d�}q�Wt
jj�}t
j
j|j�d	}|j|j|||�|j|jd
�|�\}}|jd||ftj�|dk�r|j�r||j_nj|jd
tj�|jd|j�tj�d}x&|j�dk�r\td�}|�s8d}�q8W|j�dk�r|j||��n�|dk�r�ddi}	d|	d<|	d<|	d<d|	d<x|	d�s�td�|	d<�q�Wx�|	d|	dk�rNx|	d�s�t	j	d�|	d<�q�Wx|	d�st	j	d�|	d<�qW|	d|	dk�r�d|	d<d|	d<td��q�Wx|	d�sltd�|	d<�qRW|j|	�\}}|dk�r�tjd||�ntjd�tjd �nT|d!k�rdd"i}	d|	d<x|	d�s�td#�|	d<�q�W|j|	�\}}tjd||�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.

        Z1Zx�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)ZXZynzSave your login (y/N)?ZnZyZ2�:actionZuser�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.Z3Zpassword_resetzYour email address: )r rrZsplit�announcer�INFOZinputZprint�getpassr!r"ZHTTPPasswordMgrZparseZurlparserZadd_passwordrr&r'rZ_get_rc_fileZlowerZ
_store_pypircr#)
r
ZchoicerrZchoices�authZhostr(r)�datarrrrcs�











zregister.send_metadatacCs�|jj}|d|j�|j�|j�|j�|j�|j�|j�|j	�|j
�|j�|j�|j
�|j�|j�|j�d�}|ds�|ds�|dr�d|d<|S)Nz1.0)r,�metadata_versionr-ZversionZsummaryZ	home_pageZauthorZauthor_emailZlicense�descriptionZkeywordsZplatformrZdownload_url�provides�requires�	obsoletesr5r6r7z1.1r3)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
ZactionZmetar2rrrr'�s*zregister.build_post_datacCsd|kr$|jd|d|jftj�d}d|}|d}tj�}x�|j�D]�\}}t|�tg�tf�fkrp|g}xZ|D]R}t|�}|j	|�|j	d|�|j	d�|j	|�|rv|dd	krv|j	d
�qvWqJW|j	|�|j	d
�|j
�jd�}d|tt|��d
�}	t
jj|j||	�}
t
jjt
jj|d��}d}y|j|
�}Wnxt
jjk
�r�}
z$|j�rl|
jj�}|
j|
jf}WYdd}
~
XnJt
jjk
�r�}
zdt|
�f}WYdd}
~
XnX|j�r�|j|�}d}|j�rd
jdd|ddf�}|j|tj�|S)zC Post a query to the server, and return a string response.
        r-zRegistering %s to %sz3--------------GHSKFJDLGDS7543FJKLFHRE75642756743254z
--z--z*
Content-Disposition: form-data; name="%s"z

rz
Z
zutf-8z/multipart/form-data; boundary=%s; charset=utf-8)zContent-typezContent-length)Zpassword_mgrr*Ni�r+�OKz-iKi����)r+r8)r.rrr/�ioZStringIOZitemsZtypeZstrZwriteZgetvalueZencodeZlenr!r"ZRequestZbuild_openerZHTTPBasicAuthHandlerZopenZerrorZ	HTTPErrorZ
show_responseZfpZreadr(�msgZURLErrorr$Zjoin)r
r2r1ZboundaryZsep_boundaryZend_boundaryZbodyZkeyZvalueZheadersZreqZopenerr)Zer:rrrr&�sV







zregister.post_to_server)rNr)rNrr)Z__name__Z
__module__Z__qualname__r4rZuser_optionsZboolean_optionsZsub_commandsrrrrrrrrr'r&rrrrrs&
zr)Z__doc__r0r9Zurllib.parser!Zurllib.requestZwarningsrZdistutils.corerZdistutils.errorsZ	distutilsrrrrrrZ<module>s