ó Àfc@sódZddlmZddlmZddlmZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlmZddlmZmZddlmZd d lmZd „Zd efd „ƒYZdS(spupload_docs Implements a Distutils 'upload_docs' subcommand (upload documentation to PyPI's pythonhosted.org). iÿÿÿÿ(tstandard_b64encode(tlog(tDistutilsOptionErrorN(tsix(t http_clientturllib(titer_entry_pointsi(tuploadcCs%tjrdnd}|jd|ƒS(Ntsurrogateescapetstrictsutf-8(RtPY3tencode(tsterrors((sB/usr/lib/python2.7/site-packages/setuptools/command/upload_docs.pyt_encodest upload_docscBsŸeZdZdZdddejfddgZejZd „Zd efgZ d „Z d „Z d „Z d„Z ed„ƒZed„ƒZd„ZRS(shttps://pypi.python.org/pypi/sUpload documentation to PyPIs repository=trsurl of repository [default: %s]s show-responses&display full response text from servers upload-dir=sdirectory to uploadcCs1|jdkr-xtddƒD]}tSWndS(Nsdistutils.commandst build_sphinx(t upload_dirtNoneRtTrue(tselftep((sB/usr/lib/python2.7/site-packages/setuptools/command/upload_docs.pyt has_sphinx/sRcCs#tj|ƒd|_d|_dS(N(Rtinitialize_optionsRRt target_dir(R((sB/usr/lib/python2.7/site-packages/setuptools/command/upload_docs.pyR6s  cCsÃtj|ƒ|jdkrs|jƒrF|jdƒ}|j|_qŒ|jdƒ}tj j |j dƒ|_n|j dƒ|j|_d|j kr«tjdƒn|jd|jƒdS(NRtbuildtdocsRspypi.python.orgs3Upload_docs command is deprecated. Use RTD instead.sUsing upload directory %s(Rtfinalize_optionsRRRtget_finalized_commandtbuilder_target_dirRtostpathtjoint build_basetensure_dirnamet repositoryRtwarntannounce(RRR((sB/usr/lib/python2.7/site-packages/setuptools/command/upload_docs.pyR;s    c Csýtj|dƒ}zÙ|j|jƒxÂtj|jƒD]®\}}}||jkry| ryd}t||jƒ‚nxj|D]b}tjj||ƒ}|t |jƒj tjj ƒ} tjj| |ƒ} |j || ƒq€Wq8WWd|j ƒXdS(Ntws'no files found in upload directory '%s'(tzipfiletZipFiletmkpathRRtwalkRR R!tlentlstriptseptwritetclose( Rtfilenametzip_filetroottdirstfilesttmpltnametfulltrelativetdest((sB/usr/lib/python2.7/site-packages/setuptools/command/upload_docs.pytcreate_zipfileKs" "cCsŽx!|jƒD]}|j|ƒq Wtjƒ}|jjjƒ}tjj |d|ƒ}z|j |ƒ|j |ƒWdt j |ƒXdS(Ns%s.zip(tget_sub_commandst run_commandttempfiletmkdtempt distributiontmetadatatget_nameRR R!R;t upload_filetshutiltrmtree(Rtcmd_namettmp_dirR7R2((sB/usr/lib/python2.7/site-packages/setuptools/command/upload_docs.pytrun[s  ccs¸|\}}d|}t|tƒs1|g}nx€|D]x}t|tƒrl|d|d7}|d}n t|ƒ}|Vt|ƒVdV|V|r8|ddkr8dVq8q8WdS( Ns* Content-Disposition: form-data; name="%s"s; filename="%s"iis iÿÿÿÿs s (t isinstancetlistttupleR(titemt sep_boundarytkeytvaluesttitletvalue((sB/usr/lib/python2.7/site-packages/setuptools/command/upload_docs.pyt _build_partis       c Csd}d|}|d}|df}tj|jd|ƒ}t||jƒƒ}tjj|ƒ}tj||ƒ} d|jdƒ} dj | ƒ| fS( s= Build up the MIME payload for the POST data s3--------------GHSKFJDLGDS7543FJKLFHRE75642756743254s --s--s RMs multipart/form-data; boundary=%stasciit( t functoolstpartialRRtmaptitemst itertoolstchaint from_iterabletdecodeR!( tclstdatatboundaryRMt end_boundaryt end_itemstbuildert part_groupstpartst body_itemst content_type((sB/usr/lib/python2.7/site-packages/setuptools/command/upload_docs.pyt_build_multipart}s     cCsÿt|dƒ}|jƒ}WdQX|jj}idd6|jƒd6tjj|ƒ|fd6}t|j d|j ƒ}t |ƒ}t j r¤|jdƒ}nd|}|j|ƒ\}} d |j} |j| tjƒtjj|jƒ\} } } }}}| d kr(tj| ƒ}n.| d krFtj| ƒ}ntd | ƒ‚d }yw|jƒ|jd| ƒ| }|jd|ƒ|jdtt|ƒƒƒ|jd|ƒ|j ƒ|j!|ƒWn0t"j#k r}|jt|ƒtj$ƒdSX|j%ƒ}|j&dkrMd|j&|j'f} |j| tjƒn†|j&dkrª|j(dƒ}|dkrŠd|jƒ}nd|} |j| tjƒn)d|j&|j'f} |j| tj$ƒ|j*rûdd|jƒddfGHndS(Ntrbt doc_uploads:actionR7tcontentt:RSsBasic sSubmitting documentation to %sthttpthttpssunsupported schema RTtPOSTs Content-typesContent-lengtht AuthorizationiÈsServer response (%s): %si-tLocationshttps://pythonhosted.org/%s/sUpload successful. Visit %ssUpload failed (%s): %st-iK(+topentreadR@RARBRR tbasenameRtusernametpasswordRRR R\RgR$R&RtINFORtparseturlparseRtHTTPConnectiontHTTPSConnectiontAssertionErrortconnectt putrequestt putheadertstrR,t endheaderstsendtsocketterrortERRORt getresponsetstatustreasont getheaderRt show_response(RR1tfRjtmetaR^t credentialstauthtbodytcttmsgtschematnetlocturltparamstqueryt fragmentstconnRfteRtlocation((sB/usr/lib/python2.7/site-packages/setuptools/command/upload_docs.pyRCs`      '        N(s show-responseNs&display full response text from server(s upload-dir=Nsdirectory to upload(t__name__t __module__tDEFAULT_REPOSITORYt descriptionRRt user_optionstboolean_optionsRt sub_commandsRRR;RHt staticmethodRRt classmethodRgRC(((sB/usr/lib/python2.7/site-packages/setuptools/command/upload_docs.pyRs"        (t__doc__tbase64Rt distutilsRtdistutils.errorsRRRƒR(R>RDRYRUtsetuptools.externRtsetuptools.extern.six.movesRRt pkg_resourcesRRRR(((sB/usr/lib/python2.7/site-packages/setuptools/command/upload_docs.pyts