eaiovnaovbqoebvqoeavibavo  fc@sdZddlmZddlmZddlmZddlZddlZddl 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_docscBseZdZdZdddejfddgZejZd Zd efgZ d Z d Z d Z dZ edZedZdZRS(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-xtddD]}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  cCstj||jdkrs|jrF|jd}|j|_q|jd}tj j |j d|_n|j d|j|_d|j krtjdn|jd|jdS(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 Cstj|d}z|j|jxtj|jD]\}}}||jkry| ryd}t||jnxj|D]b}tjj||}|t |jj tjj } tjj| |} |j || qWq8WWd|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" "cCsx!|jD]}|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|ts1|g}nx|D]x}t|trl|d|d7}|d}n t|}|Vt|VdV|V|r8|ddkr8dVq8q8WdS( Ns* Content-Disposition: form-data; name="%s"s; filename="%s"iis is 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     cCst|d}|j}WdQX|jj}idd6|jd6tjj||fd6}t|j d|j }t |}t j r|jd}nd|}|j|\}} d |j} |j| tjtjj|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| tjn|j&dkr|j(d}|dkrd|j}nd|} |j| tjn)d|j&|j'f} |j| tj$|j*rdd|jddfGHndS(Ntrbt doc_uploads:actionR7tcontentt:RSsBasic sSubmitting documentation to %sthttpthttpssunsupported schema RTtPOSTs Content-typesContent-lengtht AuthorizationisServer 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.errorsRRRR(R>RDRYRUtsetuptools.externRtsetuptools.extern.six.movesRRt pkg_resourcesRRRR(((sB/usr/lib/python2.7/site-packages/setuptools/command/upload_docs.pyts