� !A?h�-��r�dZddlZddlZddlZddlZddlmZddlm Z ddl Tddl m Z Gd�de ��Z dS) zhdistutils.command.register Implements the Distutils 'register' command (register with the repository). �N)�warn)� PyPIRCCommand)�*)�logc��eZdZdZejddgzZejgd�zZdd�fgZd�Zd�Z d �Z d �Z d �Z d �Z d �Zd�Zd�Zdd�ZdS)�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��dS)NT���selfs �G/opt/alt/python-internal/lib64/python3.11/distutils/command/register.py�zregister.s��4��c�J�tj|��d|_d|_dS)Nr)r�initialize_options�list_classifiersr rs rrzregister.initialize_optionss&���(��.�.�.� !����� � � rc�d�tj|��d|jfdd�}||jjd<dS)Nr)r�)r �restructuredtextr )r�finalize_optionsr � distribution�command_options)r� check_optionss rrzregister.finalize_options$sB���&�t�,�,�,�$.�� �#<�-<�>�>� �5B���)�'�2�2�2rc�J�|���|���|���D]}|�|���|jr|���dS|jr|���dS|���dS�N) r� _set_config�get_sub_commands� run_command�dry_run�verify_metadatar� classifiers� send_metadata)r�cmd_names r�runz register.run+s��� ������ �������-�-�/�/� '� '�H� � � �X� &� &� &� &� �<� !� � � � "� "� "� "� "� � "� !� � � � � � � � � � � � � � � � rc���tdt��|j�d��}|���|j|_d|_|���dS)zDeprecated API.zddistutils.command.register.check_metadata is deprecated, use the check command insteadr rN)r�PendingDeprecationWarningr�get_command_obj�ensure_finalizedr rr()rr s r�check_metadatazregister.check_metadata:si�� �-�.G� I� I� I��!�1�1�'�:�:�� ��� � � ��{�� �!"��� � � � � � � � rc�>�|���}|ikr=|d|_|d|_|d|_|d|_d|_d S|jd|jfvrtd|jz���|jdkr |j|_d|_d S) z: Reads the configuration file and set attributes. �username�password� repository�realmT�pypiz%s not found in .pypircFN)� _read_pypircr/r0r1r2� has_config�DEFAULT_REPOSITORY� ValueError)r�configs rr zregister._set_configDs����"�"�$�$�� �R�<�<�"�:�.�D�M�"�:�.�D�M�$�\�2�D�O����D�J�"�D�O�O�O���v�t�/F�&G�G�G� �!:�T�_�!L�M�M�M���&�(�(�"&�"9���#�D�O�O�Orc��|jdz}tj�|��}t j|�|����dS)z8 Fetch the list of classifiers from the server. z?:action=list_classifiersN)r1�urllib�request�urlopenr�info�_read_pypi_response)r�url�responses rr%zregister.classifiersUsJ���o�9�9���>�)�)�#�.�.�� ���)�)�(�3�3�4�4�4�4�4rc��|�|�d����\}}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�results rr$zregister.verify_metadata\sD���,�,�T�-A�-A�(�-K�-K�L�L���v� ��+�T�6�:�:�:�:�:rc�$�|jrd}|j}|j}nd}dx}}d���}||vrJ|�dt j��t��}|sd}n||vrtd��||v�J|dk�r�|std��}|�|stj d��}|�tj � ��}tj �|j��d }|�|j|||��|�|�d ��|��\}}|�d |�d |��t j��|d kr�|jr||j_dS|�dt j��|�d|���zt j��d}|���dvr)td��}|sd}|���dv�)|���dkr|�||��dSdSdS|dk�rYddi} dx| d<x| d<| d<d| d<| dstd��| d<| d�| d| dkr�| dstj d��| d<| d�| dstj d��| d<| d�| d| dkrd| d<d| d<td��| d| dk��| dstd��| d<| d�|�| ��\}}|d krt jd ||��dSt jd!��t jd"��dS|d#kr[dd$i} d| d<| dstd%��| d<| d�|�| ��\}}t jd ||��dSdS)&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: r�submitzServer response (z): ��zAI can store your PyPI login so future submissions will be faster.z (the login will be stored in %s)�X�ynzSave your login (y/N)?�n�y�2�:action�user�namer0�emailN�confirmz Confirm: z!Password and confirm don't match!z EMail: rBz"You will receive an email shortly.z7Follow the instructions in it to complete registration.�3�password_resetzYour email address: )r5r/r0�split�announcer�INFO�input�print�getpassr:r;�HTTPPasswordMgr�parse�urlparser1� add_passwordr2rCrDr� _get_rc_file�lower� _store_pypircr=) r�choicer/r0�choices�auth�hostrErF�datas rr&zregister.send_metadatacs���< �?� %��F��}�H��}�H�H��F�"$� $�H�x��/�/�#�#���G�#�#� �M�M� � "%��  +� +� +��W�W�F�� @�����w�&�&��>�?�?�?��G�#�#� �S�=�=�� /� ��.�.��� /�� 9�"�?�<�8�8��� 9��>�1�1�3�3�D��<�(�(���9�9�!�<�D� � � �d�j�$��(� C� C� C��.�.�t�/C�/C�H�/M�/M����L�D�&� �M�M�M����f�f�E��(� $� $� $��s�{�{��?�?�2:�D�%�.�.�.��M�M�$A�CF�8�M�M�M��M�M�"D�"&�"3�"3�"5�"5�#6�7:�x�A�A�A� �F� �,�,�.�.��4�4�!&�'?�!@�!@��%�)�%(�F�!�,�,�.�.��4�4��|�|�~�~��,�,��*�*�8�X�>�>�>�>�>�!�{�-�,��s�]�]��v�&�D�>@� @�D��L� @�4� �+�d�7�m�"�D��O��6�l� 3�$�\�2�2��V� ��6�l� 3��z�"�d�9�o�5�5��z�*�E�'.��|�'D�'D�D��$��z�*�E��y�/�D�&-�o�l�&C�&C�D��O��y�/�D�� �#�t�I��6�6�')�D��$�&*�D��O��=�>�>�>��z�"�d�9�o�5�5��7�m� 4� %�l� 3� 3��W� ��7�m� 4��.�.�t�4�4�L�D�&��s�{�{���3�T�6�B�B�B�B�B���=�>�>�>���3�5�5�5�5�5� �s�]�]��/�0�D��D��M��7�m� >� %�&<� =� =��W� ��7�m� >��.�.�t�4�4�L�D�&� �H�/��v� >� >� >� >� >� �]rc���|jj}id|�dd�d|����d|����d|����d|����d|����d |����d |����d |� ���d |� ���d |� ���d|� ���d|� ���d|����d|����d|����}|ds|ds|drd|d<|S)NrR�metadata_versionz1.0rT�version�summary� home_page�author� author_email�license� description�keywords�platformr%� download_url�provides�requires� obsoletesz1.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�metarjs rrDzregister.build_post_data�s���� �)�� � �v� � �� � �D�M�M�O�O� � �t�'�'�)�)�  � �t�+�+�-�-�  � ������  � �d�&�&�(�(� � �D�2�2�4�4� � �t�'�'�)�)� � �4�4�4�6�6� � ��)�)�+�+� � ��*�*�,�,� � �4�/�/�1�1� � �D�1�1�3�3� � ��)�)�+�+�! �" ��)�)�+�+�# �$ ��+�+�-�-�% ��( � � � -�t�J�/� -�4� �3D� -�',�D�#� $�� rNc���d|vr1|�d|d�d|j��tj��d}d|z}|dz}t j��}|���D]�\}}t|��tg��td��fvr|g}|D]�}t|��}|� |��|� d|z��|� d ��|� |��|r!|d d kr|� d ������|� |��|� d ��|� ��� d ��}d|ztt|����d�} tj�|j|| ��} tj�tj�|�����} d} | �| ��} |jr|�| ��}d} n|#tjj$r8} |jr| j���}| j| jf} Yd} ~ n5d} ~ wtjj$r} dt| ��f} Yd} ~ nd} ~ wwxYw|jr8d �d|df��}|�|tj��| S)zC Post a query to the server, and return a string response. rTz Registering z to z3--------------GHSKFJDLGDS7543FJKLFHRE75642756743254z --z--rz* Content-Disposition: form-data; name="%s"z ������ � zutf-8z/multipart/form-data; boundary=%s; charset=utf-8)z Content-typezContent-length)� password_mgrrJ)rL�OKNi�zK---------------------------------------------------------------------------)rZr1rr[�io�StringIO�items�type�str�write�getvalue�encode�lenr:r;�Request� build_opener�HTTPBasicAuthHandler�open� show_responser>�error� HTTPError�fp�readrE�msg�URLError�join)rrjrh�boundary� sep_boundary� end_boundary�body�key�value�headers�req�openerrF�er�s rrCzregister.post_to_server�s�� �T�>�>� �M�M�M�D��L�L�L�48�O�O�E�47�H� >� >� >�I����(� �#�d�*� ��{�}�}���*�*�,�,� %� %�J�C���E�{�{�4��8�8�T�2�Z�Z�"8�8�8����� %� %���E� � ��� � �<�(�(�(�� � �H��L�M�M�M�� � �6�"�"�"�� � �5�!�!�!��%�U�2�Y�$�.�.��J�J�t�$�$�$�� %� � � �<� � � � � � �4�����}�}���%�%�g�.�.��N�h�V�!�#�d�)�)�n�n� � ���n�$�$�T�_�d�G�D�D����,�,� �N� /� /�T� /� B� B� � ���� ��[�[��%�%�F��!� 8��/�/��7�7���F�F���|�%� #� #� #��!� #��t�y�y�{�{���V�Q�U�]�F�F�F�F�F�F������|�$� !� !� !��#�a�&�&�[�F�F�F�F�F�F����� !���� � � )��)�)�X�t�X�6�7�7�C� �M�M�#�s�x� (� (� (�� s$�H:�:J3�.J�J3�J.�.J3r)�__name__� __module__� __qualname__rsr� user_options�boolean_options� sub_commandsrrr(r-r r%r$r&rDrCrrrrrs ������L�K� �-� -� O�1 � �L� $�3�70�70�70�0�O��/�/�0�1�L���� C�C�C� !� !� !����$�$�$�"5�5�5�;�;�;�x?�x?�x?�t���87�7�7�7�7�7rr)�__doc__r^r�� urllib.parser:�urllib.request�warningsr�distutils.corer�distutils.errors� distutilsrrrrr�r�s��������� � � � �#�#�#�#�#�#�#�#�������(�(�(�(�(�(�����������_�_�_�_�_�}�_�_�_�_�_r