<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>

ðÕYfÕ-  ã               @   s¢   d  Z  d d l Z d d l 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 Td d l m Z Gd d „  d e ƒ Z d S)	zhdistutils.command.register

Implements the Distutils 'register' command (register with the repository).
é    N)Úwarn)ÚPyPIRCCommand)Ú*)Úlogc               @   sÏ   e  Z d  Z d Z e j d d  g Z e j d d d g Z d d	 d
 „  f g Z d d „  Z d d „  Z	 d d „  Z
 d d „  Z d d „  Z d d „  Z d d „  Z d d „  Z d d „  Z d d d „ Z d S)!Ú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Úcheckc             C   s   d S)NT© )Úselfr   r   ú?/opt/alt/python35/lib64/python3.5/distutils/command/register.pyÚ<lambda>   s    zregister.<lambda>c             C   s#   t  j |  ƒ d |  _ d |  _ d  S)Nr   )r   Úinitialize_optionsÚlist_classifiersr	   )r   r   r   r   r      s    	zregister.initialize_optionsc             C   s<   t  j |  ƒ d d |  j f d d i } | |  j j d <d  S)Nr	   r   Úrestructuredtexté   r   )r   r   )r   Úfinalize_optionsr	   ÚdistributionZcommand_options)r   Zcheck_optionsr   r   r   r   $   s    zregister.finalize_optionsc             C   sr   |  j  ƒ  |  j ƒ  x! |  j ƒ  D] } |  j | ƒ q! W|  j rN |  j ƒ  n  |  j rd |  j ƒ  n
 |  j ƒ  d  S)N)	r   Ú_set_configZget_sub_commandsZrun_commandZdry_runÚverify_metadatar   ÚclassifiersÚsend_metadata)r   Zcmd_namer   r   r   Úrun+   s    

		zregister.runc             C   sL   t  d t ƒ |  j j d ƒ } | j ƒ  |  j | _ d | _ | j ƒ  d S)zDeprecated API.zddistutils.command.register.check_metadata is deprecated,               use the check command insteadr   r   N)r   ÚPendingDeprecationWarningr   Zget_command_objZensure_finalizedr	   r   r   )r   r   r   r   r   Úcheck_metadata:   s    

	zregister.check_metadatac             C   s«   |  j  ƒ  } | i  k rX | d |  _ | d |  _ | d |  _ | d |  _ d |  _ nO |  j d |  j f k rƒ t d |  j ƒ ‚ |  j d k rž |  j |  _ d |  _ d	 S)
z: Reads the configuration file and set attributes.
        ÚusernameÚpasswordÚ
repositoryÚrealmTZpypiz%s not found in .pypircFN)Z_read_pypircr   r   r    r!   Ú
has_configZDEFAULT_REPOSITORYÚ
ValueError)r   Úconfigr   r   r   r   D   s    zregister._set_configc             C   s9   |  j  d } t j j | ƒ } t j |  j | ƒ ƒ d S)z8 Fetch the list of classifiers from the server.
        z?:action=list_classifiersN)r    ÚurllibÚrequestZurlopenr   ÚinfoÚ_read_pypi_response)r   ZurlZresponser   r   r   r   U   s    zregister.classifiersc             C   s9   |  j  |  j d ƒ ƒ \ } } t j d | | f ƒ d S)zF Send the metadata to the package index server to be checked.
        r   zServer response (%s): %sN)Úpost_to_serverÚbuild_post_datar   r'   )r   ÚcodeÚresultr   r   r   r   \   s    zregister.verify_metadatac       
      C   sâ  |  j  r$ d } |  j } |  j } n d } d } } d j ƒ  } xQ | | k r“ |  j d t j ƒ t ƒ  } | sz d } qC | | k rC t d ƒ qC W| d k rx | s¸ t d ƒ } q£ Wx | sÔ t	 j	 d ƒ } q¼ Wt
 j j ƒ  } t
 j j |  j ƒ d	 } | j |  j | | | ƒ |  j |  j d
 ƒ | ƒ \ } } |  j d | | f t j ƒ | d k rÞ|  j  rx| |  j _ qÞ|  j d t j ƒ |  j d |  j ƒ  t j ƒ d } x. | j ƒ  d k rÞt d ƒ } | s±d } q±W| j ƒ  d k rÞ|  j | | ƒ nÚ| d k rod d i }	 d |	 d <|	 d <|	 d <d |	 d <x |	 d s`t d ƒ |	 d <qCWx’ |	 d |	 d k rõx! |	 d s›t	 j	 d ƒ |	 d <q{Wx! |	 d s¿t	 j	 d ƒ |	 d <qŸW|	 d |	 d k rdd |	 d <d |	 d <t d ƒ qdWx |	 d st d ƒ |	 d <qùW|  j |	 ƒ \ } } | d k rRt j d | | f ƒ qÞt j d ƒ t j d  ƒ no | d! k rÞd d" i }	 d |	 d <x |	 d s±t d# ƒ |	 d <q”W|  j |	 ƒ \ } } t j d | | f ƒ 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 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: r   ZsubmitzServer response (%s): %séÈ   zAI can store your PyPI login so future submissions will be faster.z (the login will be stored in %s)ÚXZynzSave your login (y/N)?ÚnÚyÚ2z:actionÚuserÚnamer   ZemailNZconfirmz
 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.Ú3Zpassword_resetzYour email address: )r"   r   r   ÚsplitÚannouncer   ÚINFOÚinputÚprintÚgetpassr%   r&   ZHTTPPasswordMgrÚparseZurlparser    Zadd_passwordr!   r)   r*   r   Z_get_rc_fileÚlowerZ_store_pypircr'   )
r   Zchoicer   r   ÚchoicesÚauthÚhostr+   r,   Údatar   r   r   r   c   sŒ    		
				
		
	




zregister.send_metadatac          "   C   sþ   |  j  j } d | d d 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 ƒ  d | j ƒ  i } | d sð | d sð | d rú d | d <| S)Nz:actionZmetadata_versionz1.0r6   ÚversionZsummaryZ	home_pageZauthorZauthor_emailÚlicenseÚdescriptionÚkeywordsÚplatformr   Zdownload_urlZprovidesZrequiresZ	obsoletesz1.1)r   ZmetadataZget_nameZget_versionZget_descriptionZget_urlZget_contactZget_contact_emailZget_licenceZget_long_descriptionZget_keywordsZget_platformsZget_classifiersZget_download_urlZget_providesZget_requiresZget_obsoletes)r   ÚactionÚmetarC   r   r   r   r*   Ý   s*    
zregister.build_post_datac             C   s°  d | k r0 |  j  d | d |  j f t j ƒ d } d | } | d } t j ƒ  } x¿ | j ƒ  D]± \ } } t | ƒ t g  ƒ t f  ƒ f k rœ | g } xu | D]m } t | ƒ } | j	 | ƒ | j	 d | ƒ | j	 d ƒ | j	 | ƒ | r£ | d d	 k r£ | j	 d
 ƒ q£ Wqc W| j	 | ƒ | j	 d
 ƒ | j
 ƒ  j d ƒ } d d | d t t | ƒ ƒ i }	 t j j |  j | |	 ƒ }
 t j j t j j d | ƒ ƒ } d } y | j |
 ƒ } Wn‘ t j j k
 r} z/ |  j rñ| j j ƒ  } | j | j f } WYd d } ~ Xn[ t j j k
 rQ} z d t | ƒ f } WYd d } ~ Xn X|  j rj|  j | ƒ } d } |  j r¬d
 j d d | d d f ƒ } |  j  | t j ƒ | S)zC Post a query to the server, and return a string response.
        r6   zRegistering %s to %sz3--------------GHSKFJDLGDS7543FJKLFHRE75642756743254z
--z--z*
Content-Disposition: form-data; name="%s"z

r   úÚ
zutf-8zContent-typez/multipart/form-data; boundary=%s; charset=utf-8zContent-lengthZpassword_mgrr/   Niô  r0   ÚOKú-éK   éÿÿÿÿ)r0   rM   )r9   r    r   r:   ÚioÚStringIOÚitemsÚtypeÚstrÚwriteÚgetvalueÚencodeÚlenr%   r&   ZRequestZbuild_openerZHTTPBasicAuthHandlerÚopenÚerrorZ	HTTPErrorZshow_responseÚfpÚreadr+   ÚmsgZURLErrorr(   Újoin)r   rC   rA   ÚboundaryZsep_boundaryZend_boundaryZbodyÚkeyÚvalueZheadersZreqZopenerr,   Úer^   r   r   r   r)   ù   sV    



$	
		$%		 zregister.post_to_server)r   Nr   )r	   Nr
   )Ú__name__Ú
__module__Ú__qualname__rF   r   Zuser_optionsZboolean_optionsZsub_commandsr   r   r   r   r   r   r   r   r*   r)   r   r   r   r   r      s&     

zr   )Ú__doc__ÚosÚstringr=   rQ   Zurllib.parser%   Zurllib.requestÚwarningsr   Zdistutils.corer   Zdistutils.errorsZ	distutilsr   r   r   r   r   r   Ú<module>   s   $
