관리-도구
편집 파일: upload_docs.cpython-37.pyc
B ��Re2 � @ s� d Z ddlmZ ddlmZ ddlmZ ddlZddlZddl Z ddl Z ddlZddlZddl Z ddlZddlZddlmZ ddlmZ d d � ZG dd� de�ZdS ) z|upload_docs Implements a Distutils 'upload_docs' subcommand (upload documentation to sites other than PyPi such as devpi). � )�standard_b64encode)�log)�DistutilsOptionErrorN)�iter_entry_points� )�uploadc C s | � dd�S )Nzutf-8�surrogateescape)�encode)�s� r ��/builddir/build/BUILDROOT/alt-python37-setuptools-58.3.0-4.el8.x86_64/opt/alt/python37/lib/python3.7/site-packages/setuptools/command/upload_docs.py�_encode s r c @ s� e Zd ZdZdZdddej fddgZejZdd � Zd efgZ dd� Z d d� Zdd� Zdd� Z edd� �Zedd� �Zdd� ZdS )�upload_docszhttps://pypi.python.org/pypi/z;Upload documentation to sites other than PyPi such as devpizrepository=�rzurl of repository [default: %s])z show-responseNz&display full response text from server)zupload-dir=Nzdirectory to uploadc C s$ | j d kr xtdd�D ]}dS W d S )Nzdistutils.commands�build_sphinxT)� upload_dirr )�self�epr r r � has_sphinx- s zupload_docs.has_sphinxr c C s t �| � d | _d | _d S )N)r �initialize_optionsr � target_dir)r r r r r 4 s zupload_docs.initialize_optionsc C s� t �| � | jd krV| �� r8| �d�}t|j�d | _qh| �d�}tj � |jd�| _n| �d� | j| _d| j kr|t�d� | �d| j � d S ) Nr �html�buildZdocsr zpypi.python.orgz<Upload_docs command is deprecated for PyPi. Use RTD instead.zUsing upload directory %s)r �finalize_optionsr r �get_finalized_command�dictZbuilder_target_dirsr �os�path�join� build_base�ensure_dirname� repositoryr �warn�announce)r r r r r r r 9 s zupload_docs.finalize_optionsc C s� t �|d�}z�| �| j� x�t�| j�D ]|\}}}|| jkrR|sRd}t|| j ��xP|D ]H}tj�||�}|t | j�d � � tjj�} tj�| |�} |�|| � qXW q(W W d |� � X d S )N�wz'no files found in upload directory '%s')�zipfile�ZipFile�mkpathr r �walkr r r �len�lstrip�sep�write�close)r �filename�zip_file�root�dirs�files�tmpl�name�full�relative�destr r r �create_zipfileI s zupload_docs.create_zipfilec C sl x| � � D ]}| �|� q W t�� }| jj�� }tj� |d| �}z| � |� | �|� W d t� |� X d S )Nz%s.zip)�get_sub_commands�run_command�tempfile�mkdtemp�distribution�metadata�get_namer r r r8 �upload_file�shutil�rmtree)r �cmd_nameZtmp_dirr4 r/ r r r �runY s zupload_docs.runc c s� | \}}d| }t |t�s |g}xn|D ]f}t |t�rN|d|d 7 }|d }nt|�}|V t|�V dV |V |r&|dd � dkr&dV q&W d S ) Nz* Content-Disposition: form-data; name="%s"z; filename="%s"r r s ���� � )� isinstance�list�tupler )�item�sep_boundary�key�values�title�valuer r r �_build_partg s zupload_docs._build_partc C sn d}d|� d� }|d }|df}tj| j|d�}t||�� �}tj�|�}t�||�} d| } d� | �| fS ) z= Build up the MIME payload for the POST data z3--------------GHSKFJDLGDS7543FJKLFHRE75642756743254s --�asciis --rG )rL z multipart/form-data; boundary=%s� ) r � functools�partialrQ �map�items� itertools�chain� from_iterabler )�cls�data�boundaryrL Zend_boundaryZ end_itemsZbuilderZpart_groups�partsZ body_items�content_typer r r �_build_multipart{ s zupload_docs._build_multipartc C s> t |d��}|�� }W d Q R X | jj}d|�� tj�|�|fd�}t| j d | j �}t|��d�}d| }| � |�\}} d| j } | �| tj� tj�| j�\}}} }}}|s�|s�|r�t�|dkr�tj�|�}n"|d kr�tj�|�}ntd | ��d}yZ|�� |�d| � | }|�d |� |�dtt|��� |�d|� |�� |� |� W n8 t!j"k �r� } z| �t|�tj#� d S d }~X Y nX |�$� }|j%dk�r�d|j%|j&f } | �| tj� nb|j%dk�r|�'d�}|d k�r�d|�� }d| } | �| tj� nd|j%|j&f } | �| tj#� | j(�r:t)d|�� d� d S )N�rbZ doc_upload)z:actionr4 �content�:rR zBasic zSubmitting documentation to %s�http�httpszunsupported schema � �POSTzContent-typezContent-length� Authorization�� zServer response (%s): %si- ZLocationzhttps://pythonhosted.org/%s/zUpload successful. Visit %szUpload failed (%s): %szK---------------------------------------------------------------------------)*�open�readr= r>