???<!-- GIF89;a -->
123123123123
.....................................................................................................................................???<!-- GIF89;a -->
123123123123
.....................................................................................................................................3
i                 @   s   d 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m	Z	m
Z
 ddlmZ ddlmZmZ ddlmZ ddlmZ dd	lmZ G d
d deZdS )zm
distutils.command.upload

Implements the Distutils 'upload' subcommand (upload package to a package
index).
    N)standard_b64encode)urlopenRequest	HTTPError)urlparse)DistutilsErrorDistutilsOptionError)PyPIRCCommand)spawn)logc               @   sJ   e Zd ZdZejddg Zejdg Zdd	 Zd
d Zdd Z	dd Z
dS )uploadzupload binary package to PyPIsignssign files to upload using gpg	identity=iGPG identity used to sign filesc             C   s,   t j|  d| _d| _d| _d| _d | _d S )N r   F)r	   initialize_optionsusernamepasswordshow_responser   identity)self r   0/usr/lib64/python3.6/distutils/command/upload.pyr       s    
zupload.initialize_optionsc             C   sv   t j|  | jr | j r td| j }|i krX|d | _|d | _|d | _|d | _	| j rr| j
jrr| j
j| _d S )Nz.Must use --sign for --identity to have meaningr   r   
repositoryrealm)r	   finalize_optionsr   r   r   Z_read_pypircr   r   r   r   distribution)r   configr   r   r   r   (   s    




zupload.finalize_optionsc             C   s>   | j jsd}t|x$| j jD ]\}}}| j||| qW d S )NzHMust create and upload files in one command (e.g. setup.py sdist upload))r   Z
dist_filesr   upload_file)r   msgcommand	pyversionfilenamer   r   r   run:   s
    z
upload.runc       &   )   C   s^  t | j\}}}}}}	|s"|s"|	r0td| j |d2krDtd| | jr|ddd|g}
| jrnd| jg|
d	d	< t|
| jd
 t|d}z|j }W d |j	  X | j
j}dd|j |j tjj||f||tj|j d|j |j |j |j |j |j |j |j |j |j |j |j |j  d}ytj!|j }W nP t"k
r } z2d| }| j#|t$j% ddl&m'} | s| W Y d d }~X n
X ||d< d}|dkrt(j) \}}}|rd||f }n|dkrdt(j(dd }||d< | jrtjj|d t|d dj f|d< | j*d | j+ j,d}d t-|j.d }d!}d"|j,d }|d# }t/j0 }x|j1 D ]\}}d$| }t2|t3s|g}xr|D ]j}t4|t5kr|d%|d  7 }|d }nt6|j,d&}|j7| |j7|j,d& |j7d' |j7| qW qjW |j7| |j8 }d(|| jf }| j#|t$j% d)| t6t9||d*} t:| j|| d+}!yt;|!}"|"j< }#|"j=}$W nf t>k
r } z|j?}#|j=}$W Y d d }~X n8 t@k
r } z| j#t6|t$jA  W Y d d }~X nX |#d,kr8| j#d-|#|$f t$j% | jBrZ| jC|"}%d.jDd/d0 |%d/d0 f}| j#|t$j% n"d1|#|$f }| j#|t$jA tE|d S )3NzIncompatible url %shttphttpszunsupported schema Zgpgz--detach-signz-az--local-user   )dry_runrbZfile_upload1z1.0)z:actionZprotocol_versionnameversioncontentZfiletyper$   Zsha256_digestZmetadata_versionZsummaryZ	home_pageZauthorZauthor_emaillicensedescriptionkeywordsplatformZclassifiersZdownload_urlZprovidesZrequiresZ	obsoletesz#calculating md5 checksum failed: %sr   )get_fips_modeZ
md5_digestr   Z	bdist_rpmzbuilt for %s %sZ
bdist_dumbzbuilt for %s   )Ztersecommentz.ascZgpg_signature:asciizBasic z3--------------GHSKFJDLGDS7543FJKLFHRE75642756743254s   
--s   --
z+
Content-Disposition: form-data; name="%s"z; filename="%s"zutf-8s   

zSubmitting %s to %sz multipart/form-data; boundary=%s)zContent-typezContent-lengthZAuthorization)dataheaders   zServer response (%s): %s
-K   zUpload failed (%s): %s)r'   r(   )Fr   r   AssertionErrorr   r   r
   r*   openreadcloser   ZmetadataZget_nameZget_versionospathbasenamehashlibZsha256Z	hexdigestZ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_obsoletesZmd5
ValueErrorZannouncer   INFOZ_hashlibr4   r3   distr   r   encoder   decodeioBytesIOitems
isinstancelisttypetuplestrwritegetvaluelenr   r   Zgetcoder"   r   codeOSErrorZERRORr   Z_read_pypi_responsejoinr   )&r   r#   r$   r%   ZschemaZnetlocZurlZparamsZqueryZ	fragmentsZgpg_argsfr/   metar9   Zdigester"   r4   r6   rI   r.   idZ	user_passZauthboundaryZsep_boundaryZend_boundaryZbodykeyvaluetitler:   ZrequestresultZstatusreasontextr   r   r   r!   B   s    













zupload.upload_fileN)r   r   r   )r   r   r   )__name__
__module____qualname__r1   r	   Zuser_optionsZboolean_optionsr   r   r&   r!   r   r   r   r   r      s    r   )__doc__rC   rL   r3   rF   base64r   Zurllib.requestr   r   r   Zurllib.parser   Zdistutils.errorsr   r   Zdistutils.corer	   Zdistutils.spawnr
   Z	distutilsr   r   r   r   r   r   <module>   s   