Your IP : 13.59.217.1


Current Path : /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/setuptools/command/__pycache__/upload_docs.cpython-36.pyc

3

9��f��@s�dZddlmZddlmZddlmZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlmZddlmZmZddlmZd	d
lmZdd�ZGd
d�de�ZdS)zpupload_docs

Implements a Distutils 'upload_docs' subcommand (upload documentation to
PyPI's pythonhosted.org).
�)�standard_b64encode)�log)�DistutilsOptionErrorN)�six)�http_client�urllib)�iter_entry_points�)�uploadcCstjr
dnd}|jd|�S)N�surrogateescape�strictzutf-8)r�PY3�encode)�s�errors�r�!/usr/lib/python3.6/upload_docs.py�_encodesrc@s�eZdZdZdZdddejfddgZejZdd�Zd
efgZ	dd�Z
dd�Zdd�Zdd�Z
edd��Zedd��Zdd�ZdS)�upload_docszhttps://pypi.python.org/pypi/zUpload documentation to PyPIzrepository=�rzurl of repository [default: %s]�
show-responseN�&display full response text from server�upload-dir=�directory to uploadcCs$|jdkr xtdd�D]}dSWdS)Nzdistutils.commands�build_sphinxT)�
upload_dirr)�selfZeprrr�
has_sphinx/s
zupload_docs.has_sphinxrcCstj|�d|_d|_dS)N)r
�initialize_optionsr�
target_dir)rrrrr6s
zupload_docs.initialize_optionscCs�tj|�|jdkrN|j�r0|jd�}|j|_q`|jd�}tjj	|j
d�|_n|jd�|j|_d|jkrtt
jd�|jd|j�dS)Nr�buildZdocsrzpypi.python.orgz3Upload_docs command is deprecated. Use RTD instead.zUsing upload directory %s)r
�finalize_optionsrrZget_finalized_commandZbuilder_target_dirr�os�path�joinZ
build_baseZensure_dirname�
repositoryr�warn�announce)rrr rrrr!;s







zupload_docs.finalize_optionscCs�tj|d�}z�|j|j�x�tj|j�D]~\}}}||jkrT|rTd}t||j��xP|D]H}tjj||�}|t	|j�d�j
tjj�}	tjj|	|�}
|j||
�qZWq(WWd|j
�XdS)N�wz'no files found in upload directory '%s')�zipfileZZipFileZmkpathrr"�walkrr#r$�len�lstrip�sep�write�close)r�filename�zip_file�root�dirs�filesZtmpl�nameZfullZrelative�destrrr�create_zipfileKs
zupload_docs.create_zipfilecCslx|j�D]}|j|�q
Wtj�}|jjj�}tjj	|d|�}z|j
|�|j|�Wdtj
|�XdS)Nz%s.zip)Zget_sub_commandsZrun_command�tempfileZmkdtemp�distribution�metadata�get_namer"r#r$r7�upload_file�shutilZrmtree)rZcmd_nameZtmp_dirr5r1rrr�run[s
zupload_docs.runccs�|\}}d|}t|t�s |g}xn|D]f}t|t�rN|d|d7}|d}nt|�}|Vt|�VdV|V|r&|dd�dkr&dVq&WdS)	Nz*
Content-Disposition: form-data; name="%s"z; filename="%s"rr	s

�
�
���)�
isinstance�list�tupler)�item�sep_boundary�key�values�title�valuerrr�_build_partis




zupload_docs._build_partcCsnd}d|}|d}|df}tj|j|d�}t||j��}tjj|�}tj||�}	d|jd�}
dj	|	�|
fS)	z=
        Build up the MIME payload for the POST data
        s3--------------GHSKFJDLGDS7543FJKLFHRE75642756743254s
--s--r@)rFz multipart/form-data; boundary=%s�ascii�)
�	functools�partialrK�map�items�	itertools�chain�
from_iterable�decoder$)�cls�data�boundaryrFZend_boundaryZ	end_itemsZbuilderZpart_groups�partsZ
body_items�content_typerrr�_build_multipart}szupload_docs._build_multipartcCsPt|d��}|j�}WdQRX|jj}d|j�tjj|�|fd�}t|j	d|j
�}t|�}tj
rn|jd�}d|}|j|�\}}	d|j}
|j|
tj�tjj|j�\}}}
}}}|r�|r�|s�t�|dkr�tj|�}n |d	kr�tj|�}ntd
|��d}yZ|j�|jd|
�|	}|jd
|�|jdtt|���|jd|�|j �|j!|�Wn6t"j#k
�r�}z|jt|�tj$�dSd}~XnX|j%�}|j&dk�r�d|j&|j'f}
|j|
tj�nb|j&dk�r|j(d�}|dk�r�d|j�}d|}
|j|
tj�nd|j&|j'f}
|j|
tj$�|j)�rLt*dd|j�dd�dS)N�rbZ
doc_upload)z:actionr5�content�:rLzBasic zSubmitting documentation to %sZhttpZhttpszunsupported schema �ZPOSTzContent-typezContent-lengthZ
Authorization��zServer response (%s): %si-ZLocationzhttps://pythonhosted.org/%s/zUpload successful. Visit %szUpload failed (%s): %s�-�K)+�open�readr9r:r;r"r#�basenamerZusernameZpasswordrrr
rUr[r%r'r�INFOr�parseZurlparse�AssertionErrorrZHTTPConnectionZHTTPSConnectionZconnectZ
putrequestZ	putheader�strr+Z
endheaders�send�socket�errorZERRORZgetresponseZstatus�reasonZ	getheaderZ
show_response�print)rr0�fr]�metarWZcredentialsZauthZbodyZct�msgZschemaZnetlocZurlZparamsZqueryZ	fragmentsZconnrZ�er�locationrrrr<�s`



zupload_docs.upload_file)rNr)rNr)�__name__�
__module__�__qualname__ZDEFAULT_REPOSITORY�descriptionr
Zuser_optionsZboolean_optionsrZsub_commandsrr!r7r>�staticmethodrK�classmethodr[r<rrrrrs"

r)�__doc__�base64rZ	distutilsrZdistutils.errorsrr"rkr)r8r=rRrNZsetuptools.externrZsetuptools.extern.six.movesrrZ
pkg_resourcesrr
rrrrrr�<module>s 

?>