
    E$i-                     j    d Z ddlZddlZddlZddlZddlmZ ddlm	Z	 ddl
mZ  G d de	          ZdS )zhdistutils.command.register

Implements the Distutils 'register' command (register with the repository).
    N)warn)PyPIRCCommand)logc                       e Zd ZdZej        ddgz   Zej        g dz   Zdd fgZd Zd Z	d	 Z
d
 Zd Zd Zd Zd Zd ZddZdS )registerz7register the distribution with the Python package index)list-classifiersNz list the valid Trove classifiers)strictNzBWill stop the registering if the meta-data are not fully compliant)verifyr   r	   checkc                     dS )NT selfs    YC:\plebikus\WEB_uni\BACK\venv\Lib\site-packages\setuptools/_distutils/command/register.py<lambda>zregister.<lambda>#   s    4     c                 J    t          j        |            d| _        d| _        d S )Nr   )r   initialize_optionslist_classifiersr	   r   s    r   r   zregister.initialize_options%   s&    (... !r   c                 d    t          j        |            d| j        fdd}|| j        j        d<   d S )Nr   )r      )r	   restructuredtextr   )r   finalize_optionsr	   distributioncommand_options)r   check_optionss     r   r   zregister.finalize_options*   sG    &t,,, "4;/ /
 
 6C)'222r   c                 J   |                                   |                                  |                                 D ]}|                     |           | j        r|                                  d S | j        r|                                  d S |                                  d S N)	r   _set_configget_sub_commandsrun_commanddry_runverify_metadatar   classifierssend_metadata)r   cmd_names     r   runzregister.run3   s     --// 	' 	'HX&&&&< 	!  """""" 	!     r   c                     t          dt                     | j                            d          }|                                 | j        |_        d|_        |                                 dS )zDeprecated API.zVdistutils.command.register.check_metadata is deprecated; use the check command insteadr   r   N)r   DeprecationWarningr   get_command_objensure_finalizedr	   r   r'   )r   r   s     r   check_metadatazregister.check_metadataB   sh    ,	
 	
 	

 !11'::   {!"		r   c                 >   |                                  }|i k    r=|d         | _        |d         | _        |d         | _        |d         | _        d| _        d	S | j        d| j        fvrt          d| j        z            | j        dk    r| j        | _        d| _        d	S )
z0Reads the configuration file and set attributes.usernamepassword
repositoryrealmTpypiz%s not found in .pypircFN)_read_pypircr.   r/   r0   r1   
has_configDEFAULT_REPOSITORY
ValueError)r   configs     r   r   zregister._set_configO   s    ""$$R<<":.DM":.DM$\2DODJ"DOOOvt/F&GGG !:T_!LMMM&(("&"9#DOOOr   c                     | j         dz   }t          j                            |          }t	          j        |                     |                     dS )z.Fetch the list of classifiers from the server.z?:action=list_classifiersN)r0   urllibrequesturlopenr   info_read_pypi_response)r   urlresponses      r   r$   zregister.classifiers_   sH    o ;;>))#..))(3344444r   c                     |                      |                     d                    \  }}t          j        d||           dS )z<Send the metadata to the package index server to be checked.r
   Server response (%s): %sN)post_to_serverbuild_post_datar   r<   )r   coderesults      r   r#   zregister.verify_metadatae   sD     ,,T-A-A(-K-KLLv+T6:::::r   c                 @   | j         rd}| j        }| j        }nd}dx}}d                                }||vrJ|                     dt
          j                   t                      }|sd}n||vrt          d           ||vJ|dk    r|st          d          }||st          j	        d          }|t          j                                        }t          j                            | j                  d	         }|                    | j        |||           |                     |                     d
          |          \  }}|                     d                    ||          t
          j                   |dk    r| j         r|| j        _        dS |                     dt
          j                   |                     d|                                 z  t
          j                   d}|                                dvr)t          d          }|sd}|                                dv)|                                dk    r|                     ||           dS dS dS |dk    rYddi}	dx|	d<   x|	d<   |	d<   d|	d<   |	d         st          d          |	d<   |	d         |	d         |	d         k    r|	d         st          j	        d          |	d<   |	d         |	d         st          j	        d          |	d<   |	d         |	d         |	d         k    rd|	d<   d|	d<   t          d           |	d         |	d         k    |	d         st          d          |	d<   |	d         |                     |	          \  }}|dk    rt          j        d||           dS t          j        d            t          j        d!           dS |d"k    r[dd#i}	d|	d<   |	d         st          d$          |	d<   |	d         |                     |	          \  }}t          j        d||           dS dS )%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 z1 2 3 4zWe 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: r   submitzServer response ({}): {}   zAI can store your PyPI login so future submissions will be faster.z (the login will be stored in %s)XynzSave your login (y/N)?ny2:actionusernamer/   emailNconfirmz
 Confirm: z!Password and confirm don't match!z
   EMail: rA   z"You will receive an email shortly.z7Follow the instructions in it to complete registration.3password_resetzYour email address: )r4   r.   r/   splitannouncer   INFOinputprintgetpassr9   r:   HTTPPasswordMgrparseurlparser0   add_passwordr1   rB   rC   formatr   _get_rc_filelower_store_pypircr<   )
r   choicer.   r/   choicesauthhostrD   rE   datas
             r   r%   zregister.send_metadatak   s   < ? 	%F}H}HHF"$$Hx //##G##MM  	 	 	 WWF @w&&>??? G##" S== / ..  / 9"?<88  9 >1133D<((99!<Ddj$(CCC..t/C/CH/M/MtTTLD&MM4;;D&II38TTT s{{? ? 2:D%...MM:    MM:T=N=N=P=PP   !F ,,..44!&'?!@!@% )%(F !,,..44 ||~~,,**8X>>>>>/ {, -, s]]v&D>@@DL@4
+d7m"DO6l 3$\22V 6l 3z"d9o55z* E'.|'D'DD$ z* Ey/ D&-ol&C&CDO y/ D
#tI66')D$&*DO=>>> z"d9o55 7m 4 %l 3 3W 7m 4..t44LD&s{{3T6BBBBB=>>>UVVVVVs]]/0DDM7m > %&< = =W 7m >..t44LD&H/v>>>>> ]r   c                    | j         j        }i d|ddd|                                d|                                d|                                d|                                d|                                d	|                                d
|                                d|	                                d|
                                d|                                d|                                d|                                d|                                d|                                d|                                }|d         s|d         s|d         rd|d<   |S )NrQ   metadata_versionz1.0rS   versionsummary	home_pageauthorauthor_emaillicensedescriptionkeywordsplatformr$   download_urlprovidesrequires	obsoletesz1.1)r   metadataget_nameget_versionget_descriptionget_urlget_contactget_contact_emailget_licenceget_long_descriptionget_keywordsget_platformsget_classifiersget_download_urlget_providesget_requiresget_obsoletes)r   actionmetarj   s       r   rC   zregister.build_post_data   s     )
v

 DMMOO
 t''))	

 t++--
 
 d&&((
 D2244
 t''))
 44466
 ))++
 **,,
 4//11
 D1133
  ))++!
" ))++#
$ ++--%
( 
 	-tJ/ 	-43D 	-',D#$r   Nc                 
   d|v r?|                      d                    |d         | j                  t          j                   d}d|z   }|dz   }t          j                    }|                                D ]\  }}t          |          t          g           t          d          fvr|g}|D ]}t          |          }|
                    |           |
                    d|z             |
                    d           |
                    |           |r!|d	         d
k    r|
                    d           |
                    |           |
                    d           |                                                    d          }d|z  t          t          |                    d}	t          j                            | j        ||	          }
t          j                            t          j                            |                    }d}	 |                    |
          }| j        r|                     |          }d}n|# t          j        j        $ r8}| j        r|j                                        }|j        |j        f}Y d}~n5d}~wt          j        j        $ r}dt          |          f}Y d}~nd}~ww xY w| j        r8d                    d|df          }|                      |t          j                   |S )z9Post a query to the server, and return a string response.rS   zRegistering {} to {}z3--------------GHSKFJDLGDS7543FJKLFHRE75642756743254z
--z--r   z*
Content-Disposition: form-data; name="%s"z


zutf-8z/multipart/form-data; boundary=%s; charset=utf-8)zContent-typezContent-length)password_mgrrI   )rK   OKNi  zK---------------------------------------------------------------------------)rY   rb   r0   r   rZ   ioStringIOitemstypestrwritegetvalueencodelenr9   r:   Requestbuild_openerHTTPBasicAuthHandleropenshow_responser=   error	HTTPErrorfpreadrD   msgURLErrorjoin)r   rj   rh   boundarysep_boundaryend_boundarybodykeyvalueheadersreqopenerrE   er   s                  r   rB   zregister.post_to_server  s   T>>MM&--d6lDOLLch   I(#d*{}}**,, 	% 	%JCE{{488T"XX"666 % %E



<(((

H3NOOO

6"""

5!!! %U2Y$..JJt$$$% 	

<   

4}}%%g.. N!#d))nn
 

 n$$T_dGDD ,,N//T/BB
 
 	[[%%F ! 8//77FF |% 	# 	# 	#! #tyy{{VQU]FFFFFF|$ 	! 	! 	!#a&&[FFFFFF	!  	)))XtX677CMM#sx(((s$   I K.JK&J<<Kr   )__name__
__module____qualname__rs   r   user_optionsboolean_optionssub_commandsr   r   r'   r,   r   r$   r#   r%   rC   rB   r   r   r   r   r      s       KK -F	
1 L $3 7 7 7 O //01L  
C C C! ! !  $ $ $ 5 5 5; ; ;? ? ?B  87 7 7 7 7 7r   r   )__doc__r]   r   urllib.parser9   urllib.requestwarningsr   distutils.corer   	distutilsr   r   r   r   r   <module>r      s      				               ( ( ( ( ( (      m m m m m} m m m m mr   