<!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>
î
h f¼-  ã               @   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/python34/lib64/python3.4/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 |  ƒ i d |  j f d 6d d 6} | |  j j d <d  S)Nr   r	   é   Úrestructuredtextr   )zregisterr   )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 |  _ nU |  j d |  j f k r† t d |  j ƒ ‚ n  |  j d k r¤ |  j |  _ n  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   ÚinfoZ_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 ƒ  } xT | | k r– |  j d t j ƒ t ƒ  } | sz d } qC | | k rC t d ƒ qC 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  r{| |  j _ q|  j d t j ƒ |  j d |  j ƒ  t j ƒ d } x1 | j ƒ  d k rät d ƒ } | s´d } q´q´W| j ƒ  d k r|  j | | ƒ qqònâ| d k ri d d 6}	 d |	 d <|	 d <|	 d <d |	 d <x |	 d smt d ƒ |	 d <qP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 rqd |	 d <d |	 d <t d ƒ qqqqWx |	 d s&t d ƒ |	 d <q	W|  j |	 ƒ \ } } | d k rbt j d | | f ƒ qòt j d ƒ t j d  ƒ ns | d! k ròi d" d 6}	 d |	 d <x |	 d sÂt d# ƒ |	 d <q¥W|  j |	 ƒ \ } } t j d | | f ƒ n  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Ú2Úuserz:actionÚ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 } i | d 6d d 6| j ƒ  d 6| j ƒ  d 6| j ƒ  d 6| j ƒ  d 6| j ƒ  d 6| j ƒ  d	 6| j ƒ  d
 6| j	 ƒ  d 6| j
 ƒ  d 6| j ƒ  d 6| j ƒ  d 6| j ƒ  d 6| j ƒ  d 6| j ƒ  d 6| j ƒ  d 6} | d s| d s| d rd | d <n  | S)Nz:actionz1.0Zmetadata_versionr5   Ú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ÚmetarB   r   r   r   r)   Ý   s,    zregister.build_post_datac             C   s²  d | k r3 |  j  d | d |  j f t j ƒ n  d } d | } | d } t j ƒ  } xÅ | j ƒ  D]· \ } } t | ƒ t g  ƒ t f  ƒ f k r¢ | g } n  xx | D]p } t | ƒ } | j	 | ƒ | j	 d | ƒ | j	 d ƒ | j	 | ƒ | r© | d d	 k r© | j	 d
 ƒ q© q© Wqf W| j	 | ƒ | j	 d
 ƒ | j
 ƒ  j d ƒ } i d | d 6t t | ƒ ƒ d 6}	 t j j |  j | |	 ƒ }
 t j j t j j d | ƒ ƒ } d } y | j |
 ƒ } Wn” t j j k
 r#} z2 |  j rÿ| j j ƒ  } n  | j | j f } WYd d } ~ Xn[ t j j k
 r_} z d t | ƒ f } WYd d } ~ Xn X|  j rx| j ƒ  } n  d } |  j r®d d } |  j  d | | | f ƒ n  | S)zC Post a query to the server, and return a string response.
        r5   zRegistering %s to %sz3--------------GHSKFJDLGDS7543FJKLFHRE75642756743254z
--z--z*
Content-Disposition: form-data; name="%s"z

r   úÚ
zutf-8z/multipart/form-data; boundary=%s; charset=utf-8zContent-typezContent-lengthZpassword_mgrr.   Niô  r/   ÚOKú-éK   z%s%r%séÿÿÿÿ)r/   rL   )r8   r    r   r9   ÚioÚStringIOÚitemsÚtypeÚstrÚwriteÚgetvalueÚencodeÚlenr%   r&   ZRequestZbuild_openerZHTTPBasicAuthHandlerÚopenÚerrorZ	HTTPErrorZshow_responseÚfpÚreadr*   ÚmsgZURLError)r   rB   r@   ÚboundaryZsep_boundaryZend_boundaryZbodyÚkeyÚvalueZheadersZreqZopenerr+   ÚeZdashesr   r   r   r(   ù   sX    


$		$%		
zregister.post_to_server)r   Nr   )zstrictNr
   )Ú__name__Ú
__module__Ú__qualname__rE   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<   rP   Zurllib.parser%   Zurllib.requestÚwarningsr   Zdistutils.corer   Zdistutils.errorsZ	distutilsr   r   r   r   r   r   Ú<module>   s   $
